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.
npm install neotraverseVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use the modern `Traverse` class to recursively update negative numbers within an object/array structure in-place.
For CJS or ES5 environments, use `require('neotraverse/legacy')`. For older Node.js versions (>=10, <18), use `neotraverse/legacy` with ESM or CJS imports.Always use the `ctx` argument for methods like `ctx.update()`, `ctx.isLeaf()`, etc., in the modern build. Example: `new Traverse(obj).forEach((ctx, x) => { if (x < 0) ctx.update(x + 128); });`Remove `@types/traverse` from your project's dependencies.
Change your callback function signature to accept `ctx` as the first argument, e.g., `(ctx, x) => { ctx.update(newValue); }`.If your project is CJS, use `const traverse = require('neotraverse/legacy');`. If you intend to use ESM, ensure your `package.json` specifies `"type": "module"` or use `.mjs` file extensions.No dependency data recorded yet.