utils-extend
Advanced tools
Comparing version 1.0.6 to 1.0.7
30
index.js
@@ -112,2 +112,32 @@ /** | ||
/** | ||
* @description | ||
* Return a copy of the object with list keys | ||
* @example | ||
* util.pick({ key: 'value' }, 'key', 'key1'); | ||
* util.pick(obj, function(value, key, object) { }); | ||
*/ | ||
exports.pick = function(obj, iteratee) { | ||
var result = {}; | ||
if (exports.isFunction(iteratee)) { | ||
for (var key in obj) { | ||
var value = obj[key]; | ||
if (iteratee(value, key, obj)) { | ||
result[key] = value; | ||
} | ||
} | ||
} else { | ||
var keys = Array.prototype.slice.call(arguments, 1); | ||
keys.forEach(function(key) { | ||
if (key in obj) { | ||
result[key] = obj[key]; | ||
} | ||
}); | ||
} | ||
return result; | ||
}; | ||
exports.path = {}; | ||
@@ -114,0 +144,0 @@ |
{ | ||
"name": "utils-extend", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "Extend nodejs util api, and it is light weight and simple", | ||
@@ -31,2 +31,2 @@ "main": "index.js", | ||
} | ||
} | ||
} |
@@ -1,3 +0,4 @@ | ||
## utils-extend | ||
Extend nodejs util api, and it is light weight and simple | ||
# utils-extend | ||
[![NPM](https://nodei.co/npm/utils-extend.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/utils-extend/) | ||
Extend nodejs util api, and it is light weight and simple. | ||
``` | ||
@@ -11,2 +12,5 @@ var util = require('utils-extend'); | ||
## API | ||
### util | ||
Extend api in nodejs util module, | ||
### util.extend | ||
@@ -57,2 +61,8 @@ Deep clone soure object to target | ||
``` | ||
### util.pick | ||
Return a copy of the object with list keys | ||
```js | ||
util.pick({ key: 'value' }, 'key'); | ||
util.pick({ key: 'value' }, function(value, key, object) { }); | ||
``` | ||
@@ -78,3 +88,1 @@ ### util.escape | ||
Normalize \ paths to / paths. | ||
@@ -17,3 +17,3 @@ var assert = require('assert'); | ||
var source = { k: 'v2' }; | ||
var source2 = { k: 'v3' } | ||
var source2 = { k: 'v3' }; | ||
@@ -20,0 +20,0 @@ util.extend(target, source, source2); |
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
8820
8
248
86