Skip to content

Commit

Permalink
Merge branch 'main' into typed-arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
scagood authored Mar 19, 2024
2 parents 83f0e45 + 0f1e6f1 commit a0208b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down Expand Up @@ -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;
};

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit a0208b8

Please sign in to comment.