{"_id":"async-traverse-tree","_rev":"7-3dd9e55dab393827f7afde655a4447c6","name":"async-traverse-tree","dist-tags":{"latest":"1.1.3"},"versions":{"1.0.0":{"name":"async-traverse-tree","version":"1.0.0","keywords":["traverse","walk","recursive","map","deep"],"author":{"name":"Ben Zörb","email":"ben@sommerlaune.com"},"license":"MIT","_id":"async-traverse-tree@1.0.0","maintainers":[{"name":"bezoerb","email":"ben@sommerlaune.com"}],"dist":{"shasum":"9067bdf5b3f21ceffc0369b28d1c1a27a8797871","tarball":"https://registry.npmjs.org/async-traverse-tree/-/async-traverse-tree-1.0.0.tgz","fileCount":5,"integrity":"sha512-1JA6oDXgnbvbk+5P95uTpVphbvGll+OQB0llQ8amlSDdA52RqIPWcdUPRCiPcKp4tZJFe2gVKEgwyLnertbIQA==","signatures":[{"sig":"MEUCIQD3/mfBI9axPwFebnRY6DuG2BAeGBHtdYpIgoa7mzMZ1AIgb3Hjzt7XjvP/fxj29NaFiHA9bAP8B/sepgTh1YXeFdU=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6239},"type":"module","types":"./index.d.ts","engines":{"node":">=16"},"exports":"./index.js","gitHead":"26893b2e75710a82538eb574a98a2a4b9ab5c77d","scripts":{"test":"c8 ava"},"_npmUser":{"name":"bezoerb","email":"ben@sommerlaune.com"},"_npmVersion":"9.6.7","description":"Asynchronously iterates and transforms tree-like structures.","directories":{},"_nodeVersion":"18.17.1","_hasShrinkwrap":false,"devDependencies":{"c8":"^8.0.1","ava":"^5.3.1"},"_npmOperationalInternal":{"tmp":"tmp/async-traverse-tree_1.0.0_1697926294661_0.22960340591175932","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"async-traverse-tree","version":"1.0.1","keywords":["traverse","walk","recursive","map","deep"],"author":{"name":"Ben Zörb","email":"ben@sommerlaune.com"},"license":"MIT","_id":"async-traverse-tree@1.0.1","maintainers":[{"name":"bezoerb","email":"ben@sommerlaune.com"}],"homepage":"https://github.com/bezoerb/async-traverse-tree#readme","bugs":{"url":"https://github.com/bezoerb/async-traverse-tree/issues"},"dist":{"shasum":"92f706fcfaeddd051bbff722b256f7cfe0e05680","tarball":"https://registry.npmjs.org/async-traverse-tree/-/async-traverse-tree-1.0.1.tgz","fileCount":5,"integrity":"sha512-QhYIU/rysoEJSLTHte1Zi2JzQl5jtiC/FWKOMUo08yvqNJhp3V20Np3GrSCmUPutyqCcEEy4o2zdcMZaOc3yCQ==","signatures":[{"sig":"MEUCIQCMALIVc/nBNjAWkhvQXRQBD8FwVa/loBtEU464cyYdGAIgUrPUuwjpTO15LxeiTncOu0Vyf84/wfQLM1mRZl7evOk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6964},"type":"module","types":"./index.d.ts","engines":{"node":">=16"},"exports":"./index.js","gitHead":"a92715c85ecd8bca2d86330bff10e64a1e712c28","scripts":{"test":"c8 ava","test:ci":"npm run test && npm run coverage","coverage":"c8 report --reporter=lcov"},"_npmUser":{"name":"bezoerb","email":"ben@sommerlaune.com"},"repository":{"url":"git+https://github.com/bezoerb/async-traverse-tree.git","type":"git"},"_npmVersion":"8.15.0","description":"Asynchronously iterates and transforms tree-like structures.","directories":{},"_nodeVersion":"16.17.0","_hasShrinkwrap":false,"devDependencies":{"c8":"^8.0.1","ava":"^5.3.1"},"_npmOperationalInternal":{"tmp":"tmp/async-traverse-tree_1.0.1_1698927354406_0.9087467124808182","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"async-traverse-tree","version":"1.0.2","keywords":["traverse","walk","recursive","map","deep"],"author":{"name":"Ben Zörb","email":"ben@sommerlaune.com"},"license":"MIT","_id":"async-traverse-tree@1.0.2","maintainers":[{"name":"bezoerb","email":"ben@sommerlaune.com"}],"homepage":"https://github.com/bezoerb/async-traverse-tree#readme","bugs":{"url":"https://github.com/bezoerb/async-traverse-tree/issues"},"dist":{"shasum":"e5865561b57d16d1330d5225b02f5911768ac5bd","tarball":"https://registry.npmjs.org/async-traverse-tree/-/async-traverse-tree-1.0.2.tgz","fileCount":5,"integrity":"sha512-K2zGn/xo+iNL71dbxlR5b5Qa/rI0AGyEwQejpECrxQJkDW8LUS/Un3vmnmAaODlye4p7o9d0pnIGrVioSMHsmQ==","signatures":[{"sig":"MEUCIHZa1a+b65JWs+eEypTg3GWUkIpGmKo7B/jOEJ5IjuG9AiEAjv9fZFp87+36jxV0Dg7PlKRCDFvGfsXP7bfsZ1FUKC8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":7018},"type":"module","types":"./index.d.ts","engines":{"node":">=16"},"exports":"./index.js","gitHead":"010263f0792ba96aeef2fc35d701a9287e92a630","scripts":{"test":"c8 ava","test:ci":"npm run test && npm run coverage","coverage":"c8 report --reporter=lcov"},"_npmUser":{"name":"bezoerb","email":"ben@sommerlaune.com"},"repository":{"url":"git+https://github.com/bezoerb/async-traverse-tree.git","type":"git"},"_npmVersion":"9.3.1","description":"Asynchronously iterates and transforms tree-like structures.","directories":{},"_nodeVersion":"18.14.0","_hasShrinkwrap":false,"devDependencies":{"c8":"^8.0.1","ava":"^5.3.1"},"_npmOperationalInternal":{"tmp":"tmp/async-traverse-tree_1.0.2_1723588938616_0.13245306648672717","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"async-traverse-tree","version":"1.1.0","keywords":["traverse","walk","recursive","map","deep"],"author":{"name":"Ben Zörb","email":"ben@sommerlaune.com"},"license":"MIT","_id":"async-traverse-tree@1.1.0","maintainers":[{"name":"bezoerb","email":"ben@sommerlaune.com"}],"homepage":"https://github.com/bezoerb/async-traverse-tree#readme","bugs":{"url":"https://github.com/bezoerb/async-traverse-tree/issues"},"dist":{"shasum":"0c5dc8f651d7ffa03719a38e633ce3d4b932b2f7","tarball":"https://registry.npmjs.org/async-traverse-tree/-/async-traverse-tree-1.1.0.tgz","fileCount":5,"integrity":"sha512-T5djGloPIHzq6fyK7FY5x4ei6ovCkIdqHXx6FSAwXby3MXxfHi6BU3EETU/IUYDXcJO4CCmsppZe+nuq9qc/Bw==","signatures":[{"sig":"MEQCIF/VYAH1iTYvr0DOCbvt8jObs8dW1rnXMvOzwoTIWDJlAiAhd6ZYmtFxgZE/MxU4pXwfPQavMdp2up15N8tcsB80QQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":8102},"type":"module","types":"./index.d.ts","engines":{"node":">=16"},"exports":"./index.js","gitHead":"59cc501c8eaf74bcaf1c8ffd0c1ea6554f867bf6","scripts":{"test":"c8 ava","test:ci":"npm run test && npm run coverage","coverage":"c8 report --reporter=lcov"},"_npmUser":{"name":"bezoerb","email":"ben@sommerlaune.com"},"repository":{"url":"git+https://github.com/bezoerb/async-traverse-tree.git","type":"git"},"_npmVersion":"9.3.1","description":"Asynchronously iterates and transforms tree-like structures.","directories":{},"_nodeVersion":"18.14.0","_hasShrinkwrap":false,"devDependencies":{"c8":"^8.0.1","ava":"^5.3.1"},"_npmOperationalInternal":{"tmp":"tmp/async-traverse-tree_1.1.0_1723847383824_0.7397878551097754","host":"s3://npm-registry-packages"}},"1.1.1":{"name":"async-traverse-tree","version":"1.1.1","keywords":["traverse","walk","recursive","map","deep"],"author":{"name":"Ben Zörb","email":"ben@sommerlaune.com"},"license":"MIT","_id":"async-traverse-tree@1.1.1","maintainers":[{"name":"bezoerb","email":"ben@sommerlaune.com"}],"homepage":"https://github.com/bezoerb/async-traverse-tree#readme","bugs":{"url":"https://github.com/bezoerb/async-traverse-tree/issues"},"dist":{"shasum":"1eb61069678e91fe8d6f2ae55213d2a787834bd5","tarball":"https://registry.npmjs.org/async-traverse-tree/-/async-traverse-tree-1.1.1.tgz","fileCount":5,"integrity":"sha512-AJw7KsD1E58qU5RUJo2hNMNNSedRaR3OXKqZWRdW7iEpaqW5ApWXcDMCDvCMXiCRNBCdoqMvUEV2i/U87rD9fw==","signatures":[{"sig":"MEUCIQCdR7W/ggUQGq2oW3T0iAxIaQL7DNjgokC4OVRSYfS7cAIgfJ2cahetemVIE9lqJMWyKe+JBHuXHtfKMYLQ0B5/oCE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":8346},"type":"module","types":"./index.d.ts","engines":{"node":">=16"},"exports":"./index.js","gitHead":"dee4a5ff5c30d6f018bf66e4682cbb761f9caf98","scripts":{"test":"c8 ava","test:ci":"npm run test && npm run coverage","coverage":"c8 report --reporter=lcov"},"_npmUser":{"name":"bezoerb","email":"ben@sommerlaune.com"},"repository":{"url":"git+https://github.com/bezoerb/async-traverse-tree.git","type":"git"},"_npmVersion":"11.6.2","description":"Asynchronously iterates and transforms tree-like structures.","directories":{},"_nodeVersion":"24.12.0","_hasShrinkwrap":false,"devDependencies":{"c8":"^8.0.1","ava":"^5.3.1"},"_npmOperationalInternal":{"tmp":"tmp/async-traverse-tree_1.1.1_1772406922437_0.5842590642581815","host":"s3://npm-registry-packages-npm-production"}},"1.1.2":{"name":"async-traverse-tree","version":"1.1.2","keywords":["traverse","walk","recursive","map","deep"],"author":{"name":"Ben Zörb","email":"ben@sommerlaune.com"},"license":"MIT","_id":"async-traverse-tree@1.1.2","maintainers":[{"name":"bezoerb","email":"ben@sommerlaune.com"}],"homepage":"https://github.com/bezoerb/async-traverse-tree#readme","bugs":{"url":"https://github.com/bezoerb/async-traverse-tree/issues"},"dist":{"shasum":"4da4b0b40268f5742b13191187f9218195a9b23c","tarball":"https://registry.npmjs.org/async-traverse-tree/-/async-traverse-tree-1.1.2.tgz","fileCount":5,"integrity":"sha512-UY/TxWZV5XIxr+dSlKxepPRwx8Qpu+92pUQF+2tV+kmlReG3+K+DoeNUFD4igwpXfcGrQq9e5r/1p7UeMH+mbw==","signatures":[{"sig":"MEQCIF1o1CW816OdFEHvQSZUXcfAPqMxuOH94X/wa85P4i7hAiApPA4gBQBMW7MjqqR16NrCMfUkGSWTVpWypnEIS5oulA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIQDyIesYsGtPSxBlzN2ZSuXoGuSYdkxsmK7KFBtwD/dRsgIgDKq2XkRC97TkzQ3AxzE6SA9Bj/PUgc/OpE3knR/G18c=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":9612},"type":"module","types":"./index.d.ts","engines":{"node":">=16"},"exports":"./index.js","gitHead":"6fbeffd7ca56f641fbf1d60f8c2d0aa574aca00a","scripts":{"test":"c8 ava","audit":"npm audit","test:ci":"npm run test && npm run coverage","coverage":"c8 report --reporter=lcov","benchmark":"node benchmark.js","audit:runtime":"npm audit --omit=dev --audit-level=low"},"_npmUser":{"name":"bezoerb","email":"ben@sommerlaune.com"},"repository":{"url":"git+https://github.com/bezoerb/async-traverse-tree.git","type":"git"},"_npmVersion":"10.9.4","description":"Asynchronously iterates and transforms tree-like structures.","directories":{},"_nodeVersion":"22.22.0","_hasShrinkwrap":false,"packageManager":"npm@11.19.1","devDependencies":{"c8":"^12.0.0","ava":"^8.1.1"},"_npmOperationalInternal":{"tmp":"tmp/async-traverse-tree_1.1.2_1792741848719_0.7157915762450704","host":"s3://npm-registry-packages-npm-production"}},"1.1.3":{"_id":"async-traverse-tree@1.1.3","bugs":{"url":"https://github.com/bezoerb/async-traverse-tree/issues"},"dist":{"shasum":"41ca3f044e89dc071bc529be69dece8dfacae70e","tarball":"https://registry.npmjs.org/async-traverse-tree/-/async-traverse-tree-1.1.3.tgz","fileCount":5,"integrity":"sha512-H0EpMenUMxsN0m/gob4yWZmmVPB01T3yPFS0BxcVHsinZecB1tIyiOLCY1Gkvd3dJeMV7hYxFvvnTblghpZKUg==","signatures":[{"sig":"MEUCIQD5WyMF7p8H2Yl7/59Csj1dITrV7JCeD18Sw+awiMcXpgIgY+KzsWkcUJGjdvc4NYeQWJcrB9+KP3fVkR9as/ohuaY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCqD0Sujnka481uUlJgCLmg6kNm+KvfAuI/eqHQ91osmwIhAKyqxAHlA5PTBl9Hw7lwf0mIjdHywpiBTVBoc1QiFVAh"}],"unpackedSize":10022},"name":"async-traverse-tree","type":"module","types":"./index.d.ts","author":{"name":"Ben Zörb","email":"ben@sommerlaune.com"},"engines":{"node":">=16"},"exports":"./index.js","gitHead":"c23add3064d3ea2e316e399584610f4b5930045b","license":"MIT","scripts":{"test":"node --test","audit":"npm audit","test:ci":"npm run coverage","coverage":"node --test --experimental-test-coverage --test-coverage-include=index.js --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=lcov.info index.test.js","benchmark":"node benchmark.js","audit:runtime":"npm audit --omit=dev --audit-level=low"},"version":"1.1.3","_npmUser":{"name":"bezoerb","email":"ben@sommerlaune.com"},"homepage":"https://github.com/bezoerb/async-traverse-tree#readme","keywords":["traverse","walk","recursive","map","deep"],"repository":{"url":"git+https://github.com/bezoerb/async-traverse-tree.git","type":"git"},"_npmVersion":"10.9.4","description":"Asynchronously iterates and transforms tree-like structures.","directories":{},"maintainers":[{"name":"bezoerb","email":"ben@sommerlaune.com"}],"_nodeVersion":"22.22.0","_hasShrinkwrap":false,"packageManager":"npm@11.19.1","_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/async-traverse-tree_1.1.3_1793658931702_0.39991315994761645"}}},"time":{"created":"2023-10-21T22:11:34.660Z","modified":"2026-11-02T22:35:31.952Z","1.0.0":"2023-10-21T22:11:34.873Z","1.0.1":"2023-11-02T12:15:54.607Z","1.0.2":"2024-08-13T22:42:18.890Z","1.1.0":"2024-08-16T22:29:44.026Z","1.1.1":"2026-03-01T23:15:22.566Z","1.1.2":"2026-10-23T07:50:48.835Z","1.1.3":"2026-11-02T22:35:31.788Z"},"bugs":{"url":"https://github.com/bezoerb/async-traverse-tree/issues"},"author":{"name":"Ben Zörb","email":"ben@sommerlaune.com"},"license":"MIT","homepage":"https://github.com/bezoerb/async-traverse-tree#readme","keywords":["traverse","walk","recursive","map","deep"],"repository":{"url":"git+https://github.com/bezoerb/async-traverse-tree.git","type":"git"},"description":"Asynchronously iterates and transforms tree-like structures.","maintainers":[{"name":"bezoerb","email":"ben@sommerlaune.com"}],"readme":"# async-traverse-tree\n\n[![npm version](https://img.shields.io/npm/v/async-traverse-tree.svg)](https://www.npmjs.com/package/async-traverse-tree)\n[![Build Status](https://github.com/bezoerb/async-traverse-tree/workflows/CI/badge.svg)](https://github.com/bezoerb/async-traverse-tree/actions?workflow=CI)\n[![Coverage Status](https://coveralls.io/repos/github/bezoerb/async-traverse-tree/badge.svg?branch=main)](https://coveralls.io/github/bezoerb/async-traverse-tree?branch=main)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/bezoerb/async-traverse-tree/blob/main/LICENSE)\n\n`async-traverse-tree` is a lightweight, asynchronous library for traversing and mapping tree-like data structures.\n\n## Features\n\n- Asynchronously traverses and modifies objects and arrays.\n- Easy-to-use API for applying custom functions to each value in the tree.\n- Prevents circular references to maintain data integrity.\n\n## Installation\n\nYou can install `async-traverse-tree` using npm or yarn:\n\n```shell\nnpm install async-traverse-tree\n```\n\nor\n\n```shell\nyarn add async-traverse-tree\n```\n\n## Usage\n\nHere's a simple example of how to use `async-traverse-tree` with the updated implementation:\n\n```javascript\n// Import the 'traverse' function from 'async-traverse-tree'\nimport { traverse } from 'async-traverse-tree';\n\n// Define a custom mapper function\nconst mapper = async (key, value) => {\n  // Apply your custom logic here asynchronously\n  return value;\n};\n\n// Your data structure\nconst data = /* Your data structure here */;\n\n// Asynchronously traverse and map the data\ntraverse(data, mapper)\n  .then(result => {\n    // Process the result\n    console.log(result);\n  })\n  .catch(error => {\n    console.error(error);\n  });\n```\n\n### Controlling Tree Traversal\n\nThe async-traverse-tree module exports two symbols that can be used to control the traversal process:\n\n* **STOP**: Returning STOP from your mapper function will halt traversal of the current branch. No child nodes will be processed.\n* **REMOVE**: Returning REMOVE from your mapper function will remove the current key/value pair from the tree.\n\n\n```javascript\nimport { traverse, STOP, REMOVE } from 'async-traverse-tree';\n\nconst mapper = async (key, value) => {\n\n  // stop traversing deeper into this branch\n  if (skipCondition) {\n    return STOP\n  }\n\n  // remove this key/value completely\n    if (removeCondition) {\n    return REMOVE\n  }\n\n  // Apply your custom logic here asynchronously\n  return value;\n};\n```\n\n## Development\n\nUse Node.js 22.20+ with npm 11.19.1 for development. CI tests Node.js 22, 24, and 26.\nThe library's declared runtime requirement remains Node.js 16+, but CI does not test older releases.\n\n```shell\nnpm ci --ignore-scripts\nnpm run test:ci\nnpm run benchmark\nnpm run audit\n```\n\nDependency install scripts are disabled in `.npmrc`.\n\nTests use `node:test` and `node:assert/strict`, with no third-party test dependencies.\nRun `npm test` for tests alone. `npm run coverage` runs the tests with Node's experimental V8 coverage and writes `lcov.info` for Coveralls.\n`npm run test:ci` runs the same coverage command. Coverage includes the library implementation in `index.js`.\n\nThe benchmark retains the comparison with native JSON and runs without coverage instrumentation. Its speed assertion can fail on different runtimes or runners.\nCI reports benchmark failures separately from the required correctness tests.\n\n## Security considerations\n\nValidate untrusted input before traversal and limit its depth and size. Deep trees can exhaust the JavaScript call stack.\nTraversal has no node budget or timeout. Use a worker with a termination deadline when you need a hard resource limit.\n\nGetters, proxies, and mapper functions can execute application code. Only traverse trusted JavaScript objects or validated JSON data.\nIf a mapper fetches URLs, the caller must enforce URL restrictions and request timeouts.\n\n## Motivation\n\nAn easy way to iterate over an object-like structure is to use `JSON.parse(JSON.stringify(obj), (key, value) => ... )`.\\\nThe problem with this approach is that it can't handle circular references and is synchronous. `async-traverse-tree` can act like an async drop-in replacement for that which can also handle circular references.\n","readmeFilename":"README.md"}