set-object-path
Advanced tools
Comparing version 0.0.0 to 0.0.1-security
{ | ||
"name": "set-object-path", | ||
"version": "0.0.0", | ||
"description": "functions for setting values deep insde nested objects", | ||
"version": "0.0.1-security", | ||
"description": "", | ||
"main": "index.js", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"tape": "~2.3.2", | ||
"markdown-code-blocks": "0.0.1" | ||
}, | ||
"scripts": { | ||
"test": "markdown-code-blocks -t javascript < README.md | node" | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/grncdr/js-update-path.git" | ||
"url": "git+https://github.com/npm/security-holder.git" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"bugs": { | ||
"type": "git", | ||
"url": "git://github.com/grncdr/js-update-path/issues" | ||
"url": "https://github.com/npm/security-holder/issues" | ||
}, | ||
"homepage": "https://github.com/grncdr/js-update-path", | ||
"keywords": [], | ||
"author": "Stephen Sugden <me@stephensugden.com>", | ||
"license": "MIT" | ||
} | ||
"homepage": "https://github.com/npm/security-holder#readme" | ||
} |
@@ -1,94 +0,9 @@ | ||
# set-object-path | ||
# Security holding package | ||
Functions for setting values deep insde nested objects. | ||
This package name is not currently in use, but was formerly occupied | ||
by a popular package. To avoid malicious use, npm is hanging on to | ||
the package name, but loosely, and we'll probably give it to you if | ||
you want it. | ||
I use this for generating callbacks that can modify data in a restricted scope | ||
of a larger object. | ||
## Synopsis | ||
```javascript | ||
var test = require('tape') | ||
var setPath = require('./') | ||
test('use .call to pass root object', function (t) { | ||
var o = {} | ||
setPath.call(o, 'a.b.c', 2) | ||
t.deepEqual(o, {a: {b: {c: 2}}}) | ||
t.end() | ||
}) | ||
test('use array-paths instead of dot-separated strings', function (t) { | ||
var o = {} | ||
setPath.call(o, ['people', 'Mr. Jones'], "is back") | ||
t.deepEqual(o, { | ||
people: { | ||
'Mr. Jones': 'is back' | ||
} | ||
}) | ||
t.end() | ||
}) | ||
test('use .setter to pass path implicitly', function (t) { | ||
var setName = setPath.setter('name') | ||
var my = {} | ||
setName.call(my, 'Stephen') | ||
t.equal(my.name, 'Stephen') | ||
t.end() | ||
}) | ||
test('use .bind to pass root implicitly', function (t) { | ||
var my = {} | ||
var set = setPath.bind(my) | ||
set('name', 'Stephen') | ||
t.equal(my.name, 'Stephen') | ||
t.end() | ||
}) | ||
test('chain .bind and .setter for awesomeness', function (t) { | ||
var my = {} | ||
var setMyName = setPath.setter('name').bind(my) | ||
setMyName('Stephen') | ||
t.equal(my.name, 'Stephen') | ||
// or do it the other way around | ||
setPath.bind(my).setter('name')('Still Stephen') | ||
t.equal(my.name, 'Still Stephen') | ||
t.end() | ||
}) | ||
test('use .prefix to limit the scope of allowed changes', function (t) { | ||
var model = {} | ||
var setApples = setPath.prefix('apples').bind(model) | ||
var setOranges = setPath.prefix('oranges').bind(model) | ||
setApples('count', 1) | ||
setOranges('count', 2) | ||
t.deepEqual(model, { | ||
apples: { count: 1 }, | ||
oranges: { count: 2 }, | ||
}) | ||
t.end() | ||
}) | ||
test('chain .bind, .prefix, .setter', function (t) { | ||
var model = {} | ||
var setAppleCount = setPath.bind(model).prefix('apples').setter('count') | ||
var setOrangeCount = setPath.bind(model).prefix('oranges').setter('count') | ||
setAppleCount(3) | ||
setOrangeCount(4) | ||
t.deepEqual(model, { | ||
apples: { count: 3 }, | ||
oranges: { count: 4 }, | ||
}) | ||
t.end() | ||
}) | ||
``` | ||
## Install | ||
npm install set-object-path | ||
## License | ||
MIT | ||
You may adopt this package by contacting support@npmjs.com and | ||
requesting the name. |
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
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
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
0
808
2
0
2
2
10
1