Socket
Socket
Sign inDemoInstall

union-value

Package Overview
Dependencies
25
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.1 to 0.2.0

utils.js

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._
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc