{"library":"neotraverse","title":"Object Traversal and Transformation","description":"neotraverse is a JavaScript/TypeScript library designed for deep traversal and in-place transformation of JavaScript objects and arrays through a recursive walk. It stands as a TypeScript rewrite and fork of the popular `js-traverse` package, aiming for API compatibility while introducing significant modernizations. The current stable version is 0.6.18, with recent patch releases indicating active maintenance. Key differentiators include its zero-dependency architecture, minimal footprint (as low as 1.38KB min+brotli for the modern build), native TypeScript support (eliminating the need for `@types/traverse`), and an ESM-first approach. It provides three distinct builds: a default ESM-only build compatible with the original `traverse` API, a 'modern' ESM-only build offering an improved API with context passed as an explicit argument, and a 'legacy' build supporting ES5 and CommonJS for broader compatibility.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install neotraverse"],"cli":null},"imports":["import traverse from 'neotraverse';","import { Traverse } from 'neotraverse/modern';","const traverse = require('neotraverse/legacy');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { Traverse } from 'neotraverse/modern';\n\nconst obj = [5, 6, -3, [7, 8, -2, 1], { f: 10, g: -13 }];\n\n// Create a new Traverse instance for the object\nconst traverser = new Traverse(obj);\n\n// Iterate over all nodes and update negative numbers in-place\ntraverser.forEach(function (ctx, x) {\n  if (typeof x === 'number' && x < 0) {\n    ctx.update(x + 128);\n  }\n});\n\nconsole.log(obj);\n// Expected output: [ 5, 6, 125, [ 7, 8, 126, 1 ], { f: 10, g: 115 } ]","lang":"typescript","description":"Demonstrates how to use the modern `Traverse` class to recursively update negative numbers within an object/array structure in-place.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}