Gathering detailed insights and metrics for traverse
Gathering detailed insights and metrics for traverse
Gathering detailed insights and metrics for traverse
Gathering detailed insights and metrics for traverse
json-schema-traverse
Traverse JSON Schema passing each schema object to callback
@babel/traverse
The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes
babel-traverse
The Babel Traverse module maintains the overall tree state, and is responsible for replacing, removing, and adding nodes
@types/babel__traverse
TypeScript definitions for @babel/traverse
npm install traverse
Typescript
Module System
Min. Node Version
Node Version
NPM Version
97.1
Supply Chain
99.1
Quality
77.5
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
56 Stars
231 Commits
9 Forks
4 Watchers
5 Branches
10 Contributors
Updated on Jul 14, 2025
Latest Version
0.6.11
Package Id
traverse@0.6.11
Unpacked Size
84.33 kB
Size
25.49 kB
File Count
32
NPM Version
10.9.2
Node Version
23.6.0
Published on
Jan 16, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Traverse and transform objects by visiting every node on a recursive walk.
negative.js
1var traverse = require('traverse'); 2var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ]; 3 4traverse(obj).forEach(function (x) { 5 if (x < 0) this.update(x + 128); 6}); 7 8console.dir(obj);
Output:
[ 5, 6, 125, [ 7, 8, 126, 1 ], { f: 10, g: 115 } ]
leaves.js
1var traverse = require('traverse'); 2 3var obj = { 4 a : [1,2,3], 5 b : 4, 6 c : [5,6], 7 d : { e : [7,8], f : 9 }, 8}; 9 10var leaves = traverse(obj).reduce(function (acc, x) { 11 if (this.isLeaf) acc.push(x); 12 return acc; 13}, []); 14 15console.dir(leaves);
Output:
[ 1, 2, 3, 4, 5, 6, 7, 8, 9 ]
scrub.js:
1var traverse = require('traverse'); 2 3var obj = { a : 1, b : 2, c : [ 3, 4 ] }; 4obj.c.push(obj); 5 6var scrubbed = traverse(obj).map(function (x) { 7 if (this.circular) this.remove() 8}); 9console.dir(scrubbed);
output:
{ a: 1, b: 2, c: [ 3, 4 ] }
Each method that takes an fn
uses the context documented below in the context
section.
Execute fn
for each node in the object and return a new object with the
results of the walk. To update nodes in the result use this.update(value)
.
Execute fn
for each node in the object but unlike .map()
, when
this.update()
is called it updates the object in-place.
For each node in the object, perform a
left-fold
with the return value of fn(acc, node)
.
If acc
isn't specified, acc
is set to the root object for the first step
and the root element is skipped.
Return an Array
of every possible non-cyclic path in the object.
Paths are Array
s of string keys.
Return an Array
of every node in the object.
Create a deep clone of the object.
Get the element at the array path
.
Set the element at the array path
to value
.
Return whether the element at the array path
exists.
Each method that takes a callback has a context (its this
object) with these
attributes:
The present node on the recursive walk
An array of string keys from the root to the present node
The context of the node's parent.
This is undefined
for the root node.
The name of the key of the present node in its parent.
This is undefined
for the root node.
Whether the present node is the root node
Whether or not the present node is a leaf node (has no children)
Depth of the node within the traversal
If the node equals one of its parents, the circular
attribute is set to the
context of that parent and the traversal progresses no deeper.
Set a new value for the present node.
All the elements in value
will be recursively traversed unless stopHere
is
true.
Remove the current element from the output. If the node is in an Array it will be spliced off. Otherwise it will be deleted from its parent.
Delete the current element from its parent in the output. Calls delete
even on
Arrays.
Call this function before any of the children are traversed.
You can assign into this.keys
here to traverse in a custom order.
Call this function after any of the children are traversed.
Call this function before each of the children are traversed.
Call this function after each of the children are traversed.
Using npm do:
$ npm install traverse
MIT
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
security policy file detected
Details
Reason
Found 3/30 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More