Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

traverse

Package Overview
Dependencies
Maintainers
0
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

traverse - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

2

lib/traverse.js

@@ -116,3 +116,3 @@ module.exports = Traverse;

key : path.slice(-1)[0],
isRoot : node === root,
isRoot : path.length === 0,
level : path.length,

@@ -119,0 +119,0 @@ circular : null,

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

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

@@ -1,3 +0,1 @@

#!/usr/bin/env node
var sys = require('sys');
var Traverse = require('traverse');

@@ -11,3 +9,3 @@

var scrubbed = Traverse(obj).map(function (x) {
if (x instanceof Function) {
if (typeof x === 'function') {
callbacks[id] = { id : id, f : x, path : this.path };

@@ -17,3 +15,3 @@ this.update('[Function]');

}
}).value;
}).get();

@@ -24,26 +22,28 @@ assert.equal(

);
assert.equal(
scrubbed.foo[3], '[Function]',
'obj.foo[3] replaced with "[Function]"'
)
assert.equal(
JSON.stringify(scrubbed),
'{"moo":"[Function]","foo":[2,3,4,"[Function]"]}',
'Full JSON string matches'
);
assert.equal(
assert.eql(scrubbed, {
moo : '[Function]',
foo : [ 2, 3, 4, "[Function]" ]
}, 'Full JSON string matches');
assert.eql(
typeof obj.moo, 'function',
'Original obj.moo still a function'
);
assert.equal(
assert.eql(
typeof obj.foo[3], 'function',
'Original obj.foo[3] still a function'
);
assert.equal(
sys.inspect(callbacks),
"{ '54': { id: 54, f: [Function], path: [ 'moo' ] }\n"
+ ", '55': { id: 55, f: [Function], path: [ 'foo', '3' ] }\n}",
'Check the generated callbacks list'
);
assert.eql(callbacks, {
54: { id: 54, f : obj.moo, path: [ 'moo' ] },
55: { id: 55, f : obj.foo[3], path: [ 'foo', '3' ] },
}, 'Check the generated callbacks list');
};
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc