Comparing version 0.1.6 to 0.2.0
17
index.js
@@ -19,17 +19,14 @@ /*! | ||
var seg = (/^(.+)\.(.+)$/).exec(path); | ||
if (seg) { | ||
create(obj, seg[1])[seg[2]] = val; | ||
} else { | ||
obj[unescape(path)] = val; | ||
if (seg !== null) { | ||
create(obj, seg[1], seg[2], val); | ||
return obj; | ||
} | ||
obj[unescape(path)] = val; | ||
return obj; | ||
}; | ||
function create(obj, path) { | ||
function create(obj, path, child, val) { | ||
if (!path) return obj; | ||
var arr = path.split('.'); | ||
var len = arr.length, i = 0; | ||
while (len--) { | ||
@@ -42,3 +39,6 @@ var key = unescape(arr[i++]); | ||
} | ||
return obj; | ||
if (typeof child === 'string') { | ||
child = unescape(child); | ||
} | ||
return (obj[child] = val); | ||
} | ||
@@ -59,1 +59,2 @@ | ||
} | ||
{ | ||
"name": "set-value", | ||
"description": "Create nested values and any intermediaries using dot notation (`'a.b.c'`) paths.", | ||
"version": "0.1.6", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/jonschlinkert/set-value", | ||
@@ -6,0 +6,0 @@ "author": { |
@@ -1,6 +0,6 @@ | ||
# 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) | ||
# 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) | ||
> Create nested values and any intermediaries using dot notation (`'a.b.c'`) paths. | ||
## Install with [npm](npmjs.org) | ||
Install with [npm](https://www.npmjs.com/) | ||
@@ -23,10 +23,12 @@ ```bash | ||
## Related projects | ||
* [has-own-deep](https://github.com/jonschlinkert/has-own-deep): Returns true if an object has an own, nested property. | ||
* [get-value](https://github.com/jonschlinkert/get-value): Use property paths (`a.b.c`) get a nested value from an object. | ||
* [has-value](https://github.com/jonschlinkert/has-value): Returns true if a value exists, false if empty. Works with deeply nested values using object paths. | ||
* [has-any](https://github.com/jonschlinkert/has-any): Returns true if an object has any of the specified keys. | ||
* [has-any-deep](https://github.com/jonschlinkert/has-any-deep): Return true if `key` exists deeply on the given object. | ||
* [any](https://github.com/jonschlinkert/any): Returns `true` if a value exists in the given string, array or object. | ||
* [any](https://github.com/jonschlinkert/any): Returns `true` if a value exists in the given string, array or object. | ||
* [get-value](https://github.com/jonschlinkert/get-value): Use property paths (` a.b.c`) get a nested value from an object. | ||
* [has-own-deep](https://github.com/jonschlinkert/has-own-deep): Returns true if an object has an own, nested property using dot notation paths ('a.b.c'). | ||
* [has-value](https://github.com/jonschlinkert/has-value): Returns true if a value exists, false if empty. Works with deeply nested values using… [more](https://github.com/jonschlinkert/has-value) | ||
* [has-any](https://github.com/jonschlinkert/has-any): Returns true if an object has any of the specified keys. | ||
* [has-any-deep](https://github.com/jonschlinkert/has-any-deep): Return true if `key` exists deeply on the given object. | ||
## Running tests | ||
Install dev dependencies: | ||
@@ -39,4 +41,5 @@ | ||
## Contributing | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/set-value/issues) | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/set-value/issues/new) | ||
## Author | ||
@@ -47,12 +50,13 @@ | ||
+ [github/jonschlinkert](https://github.com/jonschlinkert) | ||
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
## License | ||
Copyright (c) 2015 Jon Schlinkert | ||
Released under the MIT license | ||
Copyright (c) 2015 Jon Schlinkert | ||
Released under the MIT license. | ||
*** | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on April 02, 2015._ | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on May 12, 2015._ | ||
<!-- deps: mocha should --> | ||
<!-- deps: mocha should --> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5255
50
59