ancient-oak
Advanced tools
Comparing version 0.3.4 to 0.3.5
{ | ||
"name": "ancient-oak", | ||
"version": "0.3.4", | ||
"main": "dist/ancient-oak-0.3.4.js", | ||
"version": "0.3.5", | ||
"main": "dist/ancient-oak-0.3.5.js", | ||
"ignore": [ | ||
@@ -6,0 +6,0 @@ "spec", |
{ | ||
"name": "ancient-oak", | ||
"repository": "brainshave/ancient-oak", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"scripts": [ | ||
@@ -6,0 +6,0 @@ "lib/**/*.js" |
@@ -25,2 +25,8 @@ # Feature ideas | ||
to have empty space in left-most leaf, the maximum start offset is | ||
only 31 (because leaf size is 32). | ||
only 31 (because leaf size is 32). | ||
## I.parse | ||
Use Ancient Oak as JSON.parse reviver. | ||
vide: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse |
@@ -92,2 +92,3 @@ "use strict"; | ||
get.map = map; | ||
get.nmap = nmap; | ||
get.filter = filter; | ||
@@ -242,2 +243,9 @@ | ||
function nmap (fn) { | ||
return reduce(function (result, value, key) { | ||
result[key] = fn(value, key, get); | ||
return result; | ||
}, new_dump()); | ||
} | ||
function reduce (fn, init) { | ||
@@ -244,0 +252,0 @@ var result = init; |
@@ -11,3 +11,3 @@ { | ||
], | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"scripts": { | ||
@@ -14,0 +14,0 @@ "dist": "scripts/dist", |
@@ -59,3 +59,3 @@ # Ancient Oak: The Immutable Tree | ||
As with regular objects in JavaScript, keys are not guarantied to | ||
As with regular objects in JavaScript, keys are not guaranteed to | ||
be sorted. | ||
@@ -145,3 +145,3 @@ | ||
=> I({a: 1}).update(function (v) { return v + 1 }) | ||
=> I({a: 1}).update('a', function (v) { return v + 1 }) | ||
<= I({a: 2}) | ||
@@ -188,2 +188,6 @@ | ||
### `.nmap(fn(value,key))` | ||
Same as `map` but returns native object/array. | ||
### `.filter(fn(value, key))` | ||
@@ -241,2 +245,2 @@ | ||
MIT, see [COPYING](COPYING). | ||
MIT, see [COPYING](COPYING). |
@@ -136,2 +136,22 @@ "use strict"; | ||
}); | ||
describe(".nmap", function () { | ||
it("maps to native array", function () { | ||
var result = store([1, 2, 3]).nmap(function (x) { | ||
return x * 2; | ||
}); | ||
expect(result instanceof Array).toBe(true, 'result instanceof Array'); | ||
expect(result).toEqual([2, 4, 6]); | ||
}); | ||
it("maps to native object", function () { | ||
var result = store({a: 1, b: 2, c: 3}).nmap(function (x) { | ||
return x * 2; | ||
}); | ||
expect(result instanceof Array).toBe(false, 'result instanceof Array'); | ||
expect(result).toEqual({a: 2, b: 4, c: 6}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
74180
1510
243