Socket
Socket
Sign inDemoInstall

traverse

Package Overview
Dependencies
0
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.1 to 0.5.2

main.js

6

index.js

@@ -125,6 +125,7 @@ module.exports = Traverse;

},
'delete' : function () {
'delete' : function (stopHere) {
delete state.parent.node[state.key];
if (stopHere) keepGoing = false;
},
remove : function () {
remove : function (stopHere) {
if (Array_isArray(state.parent.node)) {

@@ -136,2 +137,3 @@ state.parent.node.splice(state.key, 1);

}
if (stopHere) keepGoing = false;
},

@@ -138,0 +140,0 @@ keys : null,

{
"name" : "traverse",
"version" : "0.5.1",
"version" : "0.5.2",
"description" : "Traverse and transform objects by visiting every node on a recursive walk",

@@ -5,0 +5,0 @@ "author" : "James Halliday",

@@ -100,2 +100,26 @@ var assert = require('assert');

exports.removeNoStop = function() {
var obj = { a : 1, b : 2, c : { d: 3, e: 4 }, f: 5 };
var keys = [];
Traverse(obj).forEach(function (x) {
keys.push(this.key)
if (this.key == 'c') this.remove();
});
assert.deepEqual(keys, [undefined, 'a', 'b', 'c', 'd', 'e', 'f'])
}
exports.removeStop = function() {
var obj = { a : 1, b : 2, c : { d: 3, e: 4 }, f: 5 };
var keys = [];
Traverse(obj).forEach(function (x) {
keys.push(this.key)
if (this.key == 'c') this.remove(true);
});
assert.deepEqual(keys, [undefined, 'a', 'b', 'c', 'f'])
}
exports.removeMap = function () {

@@ -130,2 +154,26 @@ var obj = { a : 1, b : 2, c : [ 3, 4 ] };

exports.deleteNoStop = function() {
var obj = { a : 1, b : 2, c : { d: 3, e: 4 } };
var keys = [];
Traverse(obj).forEach(function (x) {
keys.push(this.key)
if (this.key == 'c') this.delete();
});
assert.deepEqual(keys, [undefined, 'a', 'b', 'c', 'd', 'e'])
}
exports.deleteStop = function() {
var obj = { a : 1, b : 2, c : { d: 3, e: 4 } };
var keys = [];
Traverse(obj).forEach(function (x) {
keys.push(this.key)
if (this.key == 'c') this.delete(true);
});
assert.deepEqual(keys, [undefined, 'a', 'b', 'c'])
}
exports.deleteRedux = function () {

@@ -132,0 +180,0 @@ var obj = { a : 1, b : 2, c : [ 3, 4, 5 ] };

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc