{"id":17924446,"url":"https://github.com/itpropro/tree-structure-ts","last_synced_at":"2026-02-17T02:34:18.914Z","repository":{"id":64932116,"uuid":"575383498","full_name":"itpropro/tree-structure-ts","owner":"itpropro","description":"Library for creating and interacting with tree structures, written in TypeScript.","archived":false,"fork":false,"pushed_at":"2025-03-15T18:52:09.000Z","size":632,"stargazers_count":3,"open_issues_count":11,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T00:06:36.545Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/itpropro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2022-12-07T11:46:37.000Z","updated_at":"2025-01-16T23:34:52.000Z","dependencies_parsed_at":"2024-01-03T02:07:23.437Z","dependency_job_id":"8ffae776-9f9d-4475-abe9-257716f11bee","html_url":"https://github.com/itpropro/tree-structure-ts","commit_stats":{"total_commits":34,"total_committers":4,"mean_commits":8.5,"dds":0.1470588235294118,"last_synced_commit":"12b7ee92ac76e3230aadc5a79756838d0b8b42b1"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itpropro%2Ftree-structure-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itpropro%2Ftree-structure-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itpropro%2Ftree-structure-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itpropro%2Ftree-structure-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itpropro","download_url":"https://codeload.github.com/itpropro/tree-structure-ts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248317707,"owners_count":21083528,"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":[],"created_at":"2024-10-28T20:48:49.068Z","updated_at":"2026-02-17T02:34:18.907Z","avatar_url":"https://github.com/itpropro.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @itpropro/tree-structure-ts\n\n[![npm (scoped)](https://img.shields.io/npm/v/@itpropro/tree-structure-ts)](https://www.npmjs.com/package/@itpropro/tree-structure-ts)\n![npm bundle size (scoped)](https://img.shields.io/bundlephobia/min/@itpropro/tree-structure-ts)\n[![ci](https://github.com/itpropro/tree-structure-ts/actions/workflows/ci.yml/badge.svg)](https://github.com/itpropro/tree-structure-ts/actions/workflows/ci.yml)\n![Code Coverage](https://img.shields.io/badge/coverage-\u003e95%25-green)\n\n## Introduction\n\nThis module helps interacting with `Tree` structures in TypeScript. It is optimized to work with big trees without causing overflows. Therefore it doesn't use recursion and the implementations for `preOrder` and `postOrder` traversals use `Promise.all` for concurrency to traverse multiple nodes at once.\n\nIt is fully typed and has over 95% test coverage.\n\n- Zero dependency\n- Fully typed\n- Optimized for big trees\n- No recursion -\u003e no memory overflows\n- Small bundle size\n\n## Quick Start\n\n### Installation\n\nTo install the module, run the following command:\n\n```bash\n# bun\nbun add @itpropro/tree-structure-ts\n\n# npm\nnpm install @itpropro/tree-structure-ts\n\n# yarn\nyarn add @itpropro/tree-structure-ts\n```\n\n### Import\n\n```typescript\n// ESM / TypeScript\nimport { Tree } from '@itpropro/tree-structure-ts'\nimport type { TreeNode } from '@itpropro/tree-structure-ts'\n```\n\n## Usage\n\nTo create a new `Tree` instance, use the `Tree` constructor:\n\n```typescript\nconst tree = new Tree('root')\nconst root = tree.root\n```\n\nTo add a child node to a TreeNode, use the `addChild` method:\n\n```typescript\nconst child1 = root.addChild('child1')\nconst child2 = root.addChild('child2')\n```\n\nTo get all nodes in the tree below a TreeNode, use the `all` method:\n\n```typescript\nconst nodes = root.all()\n```\n\nTo traverse a tree, use the `traverse` method:\n\n```typescript\nroot.traverse((node) =\u003e {\n  // This function is called for each node in the tree\n})\n```\n\nYou can specify the traversal order by passing one of the following values to the `traverse` method:\n\n- breadthFirst (the default): visits nodes in breadth-first order\n- depthFirst: visits nodes in depth-first order\n- preOrder: visits the current node, then traverses the left subtree, then traverses the right subtree\n- postOrder: traverses the left subtree, then traverses the right subtree, then visits the current node\n\nFor all available methods and fields, please read the detailed documentation of the `Tree` and `TreeNode` classes: [Class docs](https://github.com/itpropro/tree-structure-ts/blob/main/docs/modules.md).\n\n## Contribution\n\nSee [Contributing Guide](https://github.com/itpropro/tree-structure-ts/blob/main/CONTRIBUTING.md).\n\n## License\n\nMade with :heart:\n\nPublished under [MIT License](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitpropro%2Ftree-structure-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitpropro%2Ftree-structure-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitpropro%2Ftree-structure-ts/lists"}