just-map-values
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -5,5 +5,6 @@ module.exports = map; | ||
// returns a new object with the predicate applied to each value | ||
// like just-map-object, but only the value argument is available | ||
// like just-map-object, but (value, key, object) are passed to the predicate | ||
map({a: 3, b: 5, c: 9}, (value) => value + 1); // {a: 4, b: 6, c: 10} | ||
map({a: 3, b: null, c: undefined}, (value) => Boolean); // {a: 3, b: false, c: false} | ||
map({a: 3, b: 5, c: 9}, (value, key) => value + key); // {a: 3a, b: 5b, c: 9c} | ||
map({a: 3, b: 5, c: 9}, (value, key, object) => object.b); // {a: 5, b: 5, c: 5} | ||
*/ | ||
@@ -17,5 +18,5 @@ | ||
var key = keys[i]; | ||
result[key] = predicate(obj[key]); | ||
result[key] = predicate(obj[key], key, obj); | ||
} | ||
return result; | ||
} |
{ | ||
"name": "just-map-values", | ||
"version": "1.0.0", | ||
"description": "map an object, passing value to predicate", | ||
"version": "1.0.1", | ||
"description": "map an object, passing (value, key, object) to predicate", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -11,6 +11,7 @@ ## just-map-object | ||
// map an object, passing the value to the predicate | ||
// like just-map-object, but only the value argument is available | ||
map({a: 3, b: 5, c: 9}, (value) => value + 1); // {a: 4, b: 6, c: 10} | ||
map({a: 3, b: null, c: undefined}, (value) => Boolean); // {a: 3, b: false, c: false} | ||
// map an object, applying the predicate to the value | ||
// like just-map-object, but (value, key, object) is passed to the predicate | ||
map({a: 3, b: 5, c: 9}, (value) => value + 1); // {a: 4, b: 6, c: 10} | ||
map({a: 3, b: 5, c: 9}, (value, key) => value + key); // {a: 3a, b: 5b, c: 9c} | ||
map({a: 3, b: 5, c: 9}, (value, key, object) => object.b); // {a: 5, b: 5, c: 5} | ||
``` |
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
1736
18
17