Socket
Socket
Sign inDemoInstall

set-value

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

set-value - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

39

index.js

@@ -14,7 +14,6 @@ /*!

module.exports = function set(obj, path, val) {
module.exports = function setValue(obj, path, val) {
if (path == null) {
return obj;
}
path = escape(path);

@@ -26,3 +25,3 @@ var seg = (/^(.+)\.(.+)$/).exec(path);

} else {
obj[path] = val;
obj[unescape(path)] = val;
return obj;

@@ -34,7 +33,8 @@ }

function create(obj, path) {
if (!path) {
return obj;
}
forEach(path.split('.'), function (key) {
key = unescape(key);
if (!path) return obj;
var arr = path.split('.');
var len = arr.length, i = 0;
while (len--) {
var key = unescape(arr[i++]);
if (!obj[key] || !isObject(obj[key])) {

@@ -44,21 +44,9 @@ obj[key] = {};

obj = obj[key];
});
}
return obj;
}
function forEach(arr, fn, thisArg) {
if (arr == null) {
return;
}
var len = arr.length;
var i = 0;
while (i < len) {
if (fn.call(thisArg, arr[i++], i, arr) === false) {
break;
}
}
}
/**
* Escape => `\\.`
*/
function escape(str) {

@@ -68,4 +56,7 @@ return str.split('\\.').join(nc[1]);

/**
* Unescaped dots
*/
function unescape(str) {
return str.split(nc[1]).join('.');
}
{
"name": "set-value",
"description": "Create nested values and any intermediaries dot notation (`'a.b.c'`) paths.",
"version": "0.1.2",
"version": "0.1.3",
"homepage": "https://github.com/jonschlinkert/set-value",

@@ -6,0 +6,0 @@ "author": {

@@ -26,3 +26,3 @@ # set-value [![NPM version](https://badge.fury.io/js/set-value.svg)](http://badge.fury.io/js/set-value) [![Build Status](https://travis-ci.org/jonschlinkert/set-value.svg)](https://travis-ci.org/jonschlinkert/set-value)

## Running tests
Install dev dependencies.
Install dev dependencies:

@@ -36,3 +36,3 @@ ```bash

**Jon Schlinkert**
+ [github/jonschlinkert](https://github.com/jonschlinkert)

@@ -48,2 +48,2 @@ + [twitter/jonschlinkert](http://twitter.com/jonschlinkert)

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on March 25, 2015._
<!-- deps: mocha should -->
<!-- deps: mocha should -->
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc