{"id":17471685,"url":"https://github.com/bezoerb/async-traverse-tree","last_synced_at":"2026-03-02T01:02:08.748Z","repository":{"id":201150915,"uuid":"707075832","full_name":"bezoerb/async-traverse-tree","owner":"bezoerb","description":"Asynchronously iterates and transforms tree-like structures.","archived":false,"fork":false,"pushed_at":"2024-08-16T22:29:47.000Z","size":85,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-04T16:10:04.022Z","etag":null,"topics":["async","deep","map","recursive","traverse","walk"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bezoerb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-19T07:15:02.000Z","updated_at":"2024-08-16T22:29:52.000Z","dependencies_parsed_at":"2024-08-14T01:12:53.250Z","dependency_job_id":"7ba6433c-e513-4637-86d8-d8759238c979","html_url":"https://github.com/bezoerb/async-traverse-tree","commit_stats":null,"previous_names":["bezoerb/async-map-tree","bezoerb/async-traverse-tree"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bezoerb%2Fasync-traverse-tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bezoerb%2Fasync-traverse-tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bezoerb%2Fasync-traverse-tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bezoerb%2Fasync-traverse-tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bezoerb","download_url":"https://codeload.github.com/bezoerb/async-traverse-tree/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248161185,"owners_count":21057552,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","deep","map","recursive","traverse","walk"],"created_at":"2024-10-18T16:52:30.279Z","updated_at":"2026-02-27T11:12:47.822Z","avatar_url":"https://github.com/bezoerb.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"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) =\u003e {\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 =\u003e {\n    // Process the result\n    console.log(result);\n  })\n  .catch(error =\u003e {\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) =\u003e {\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## Motivation\n\nAn easy way to iterate over an object-like structure is to use `JSON.parse(JSON.stringify(obj), (key, value) =\u003e ... )`.\\\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbezoerb%2Fasync-traverse-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbezoerb%2Fasync-traverse-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbezoerb%2Fasync-traverse-tree/lists"}