diff --git a/index.js b/index.js index 79c9f79..ce507da 100644 --- a/index.js +++ b/index.js @@ -106,10 +106,14 @@ function copy(src) { return src; } -function walk(root, cb, immutable) { +var emptyNull = { __proto__: null }; + +function walk(root, cb) { var path = []; var parents = []; var alive = true; + var options = arguments.length > 2 ? arguments[2] : emptyNull; + var immutable = !!options.immutable; return (function walker(node_) { var node = immutable ? copy(node_) : node_; @@ -268,12 +272,14 @@ Traverse.prototype.set = function (ps, value) { return value; }; +var immutableOpts = { __proto__: null, immutable: true }; + Traverse.prototype.map = function (cb) { - return walk(this.value, cb, true); + return walk(this.value, cb, immutableOpts); }; Traverse.prototype.forEach = function (cb) { - this.value = walk(this.value, cb, false); + this.value = walk(this.value, cb); return this.value; }; diff --git a/package.json b/package.json index c476a73..223335e 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "in-publish": "^2.0.1", "npmignore": "^0.3.1", "safe-publish-latest": "^2.0.0", - "tape": "^5.7.2" + "tape": "^5.7.5" }, "scripts": { "prepack": "npmignore --auto --commentLines=autogenerated", @@ -93,8 +93,8 @@ }, "dependencies": { "gopd": "^1.0.1", - "typedarray.prototype.slice": "^1.0.1", - "which-typed-array": "^1.1.11" + "typedarray.prototype.slice": "^1.0.2", + "which-typed-array": "^1.1.15" }, "engines": { "node": ">= 0.4"