union-value
Advanced tools
Comparing version 0.1.1 to 0.2.0
15
index.js
'use strict'; | ||
var isObject = require('is-extendable'); | ||
var union = require('arr-union'); | ||
var get = require('get-value'); | ||
var set = require('set-value'); | ||
var utils = require('./utils'); | ||
module.exports = function unionValue(obj, prop, value) { | ||
if (!isObject(obj)) { | ||
if (!utils.isObject(obj)) { | ||
throw new TypeError('union-value expects the first argument to be an object.'); | ||
@@ -17,9 +14,5 @@ } | ||
var arr = arrayify(get(obj, prop) || []); | ||
set(obj, prop, union(arr, arrayify(value || []))); | ||
var arr = utils.arrayify(utils.get(obj, prop)); | ||
utils.set(obj, prop, utils.union(arr, utils.arrayify(value))); | ||
return obj; | ||
}; | ||
function arrayify(val) { | ||
return Array.isArray(val) ? val : [val]; | ||
} |
{ | ||
"name": "union-value", | ||
"description": "Set an array of unique values as the property of an object. Supports setting deeply nested properties using using object-paths/dot notation.", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"homepage": "https://github.com/jonschlinkert/union-value", | ||
@@ -13,3 +13,4 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"files": [ | ||
"index.js" | ||
"index.js", | ||
"utils.js" | ||
], | ||
@@ -25,5 +26,7 @@ "main": "index.js", | ||
"arr-union": "^3.0.0", | ||
"get-value": "^1.1.5", | ||
"cast-to-array": "^0.1.0", | ||
"get-value": "^2.0.0", | ||
"is-extendable": "^0.1.1", | ||
"set-value": "^0.2.0" | ||
"lazy-cache": "^0.2.4", | ||
"set-value": "^0.3.0" | ||
}, | ||
@@ -49,8 +52,10 @@ "devDependencies": { | ||
], | ||
"verbiage": { | ||
"verb": { | ||
"related": { | ||
"list": [ | ||
"assign-value", | ||
"get-value", | ||
"has-value", | ||
"set-value", | ||
"get-value", | ||
"has-value" | ||
"unset-value" | ||
] | ||
@@ -57,0 +62,0 @@ } |
@@ -27,7 +27,9 @@ # union-value [![NPM version](https://badge.fury.io/js/union-value.svg)](http://badge.fury.io/js/union-value) | ||
## Related projects | ||
## Similar projects | ||
* [get-value](https://github.com/jonschlinkert/get-value): Use property paths (` a.b.c`) to 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… [more](https://github.com/jonschlinkert/has-value) | ||
* [set-value](https://github.com/jonschlinkert/set-value): Create nested values and any intermediaries using dot notation (`'a.b.c'`) paths. | ||
* [assign-value](https://www.npmjs.com/package/assign-value): Assign a value or extend a deeply nested property of an object using object path… [more](https://www.npmjs.com/package/assign-value) | [homepage](https://github.com/jonschlinkert/assign-value) | ||
* [get-value](https://www.npmjs.com/package/get-value): Use property paths (` a.b.c`) to get a nested value from an object. | [homepage](https://github.com/jonschlinkert/get-value) | ||
* [has-value](https://www.npmjs.com/package/has-value): Returns true if a value exists, false if empty. Works with deeply nested values using… [more](https://www.npmjs.com/package/has-value) | [homepage](https://github.com/jonschlinkert/has-value) | ||
* [set-value](https://www.npmjs.com/package/set-value): Create nested values and any intermediaries using dot notation (`'a.b.c'`) paths. | [homepage](https://github.com/jonschlinkert/set-value) | ||
* [unset-value](https://www.npmjs.com/package/unset-value): Delete nested properties from an object using dot notation. | [homepage](https://github.com/jonschlinkert/unset-value) | ||
@@ -44,3 +46,3 @@ ## Running tests | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/union-value/issues/new) | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/union-value/issues/new). | ||
@@ -61,2 +63,2 @@ ## Author | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on July 04, 2015._ | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on November 06, 2015._ |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
5877
5
46
61
6
1
+ Addedcast-to-array@^0.1.0
+ Addedlazy-cache@^0.2.4
+ Addedcall-bind@1.0.7(transitive)
+ Addedcast-to-array@0.1.0(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedextend-shallow@2.0.1(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedget-value@2.0.6(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedis-arguments@1.1.1(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedisobject@2.1.0(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedset-value@0.3.3(transitive)
+ Addedto-object-path@0.2.0(transitive)
- Removedget-value@1.3.1(transitive)
- Removedisobject@1.0.2(transitive)
- Removednoncharacters@1.1.0(transitive)
- Removedset-value@0.2.0(transitive)
Updatedget-value@^2.0.0
Updatedset-value@^0.3.0