{"id":30180926,"url":"https://github.com/streamich/sonic-forest","last_synced_at":"2025-08-12T08:06:18.400Z","repository":{"id":234673611,"uuid":"789365180","full_name":"streamich/sonic-forest","owner":"streamich","description":"High performance tree and sorted map implementations for JavaScript in TypeScript","archived":false,"fork":false,"pushed_at":"2025-08-10T14:14:27.000Z","size":2276,"stargazers_count":22,"open_issues_count":7,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-10T16:22:12.281Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://streamich.github.io/sonic-forest/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/streamich.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"streamich"}},"created_at":"2024-04-20T10:42:05.000Z","updated_at":"2025-08-04T16:20:48.000Z","dependencies_parsed_at":"2024-04-20T11:20:26.977Z","dependency_job_id":"1b66579f-b563-40ff-b352-61090e28931e","html_url":"https://github.com/streamich/sonic-forest","commit_stats":null,"previous_names":["streamich/sonic-forest"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/streamich/sonic-forest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamich%2Fsonic-forest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamich%2Fsonic-forest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamich%2Fsonic-forest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamich%2Fsonic-forest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/streamich","download_url":"https://codeload.github.com/streamich/sonic-forest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/streamich%2Fsonic-forest/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270024697,"owners_count":24514054,"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","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-08-12T08:06:07.737Z","updated_at":"2025-08-12T08:06:18.385Z","avatar_url":"https://github.com/streamich.png","language":"TypeScript","funding_links":["https://github.com/sponsors/streamich"],"categories":[],"sub_categories":[],"readme":"# Sonic Forest\n\nHigh performance (binary) tree and sorted map implementation for JavaScript in TypeScript.\n\n## Features\n\n- AVL tree implementation\n- AVL sorted map implementation\n- AVL sorted set implementation\n- Red-black (RB) tree implementation\n- Red-black (RB) tree sorted map implementation\n- Left-leaning Red-black (LLRB) tree implementation\n- Radix tree implementation (string keys)\n- Binary radix tree implementation (Uint8Array keys)\n- Splay tree implementation\n- Various utility methods for binary trees\n\nThis package implements the fastest insertion into self-balancing binary tree out of any\nNPM package. Both, AVL and Red-black tree insertion implementations of `sonic-forest` a faster\nthan inserts in [`js-sdsl`](https://www.npmjs.com/package/js-sdsl) implementation.\n\nHowever, deletions from a binary tree are faster in `js-sdsl`. But, deletions in `sonic-forest`\ndelete exactly the node, which contains the key. Unlike, in `js-sdsl` and all other\nbinary tree libraries, where those libraries find the in-order-sucessor or -predecessor, which\nis a leaf node, and delete that instead. As such, one can keep pointers to `sonic-forest` AVL\nand Red-black tree nodes, and those pointers will stay valid even after deletions.\n\n## Binary Radix Tree\n\nThe binary radix tree implementation supports `Uint8Array` keys, making it suitable for binary data like:\n\n- Binary protocol routing\n- File system paths as binary data\n- Cryptographic hashes\n- Network packet classification\n- Any binary blob keys\n\n### Key Features\n\n- **Efficient slicing**: Uses `Slice` class to reference portions of `Uint8Array` without copying data\n- **Prefix compression**: Automatically compresses common prefixes to save memory\n- **Binary-safe**: Works with any byte sequence, including null bytes\n- **Same API**: Provides similar interface to the string-based radix tree\n\n### Usage Example\n\n```typescript\nimport { BinaryRadixTree } from 'sonic-forest';\n\nconst tree = new BinaryRadixTree\u003cstring\u003e();\n\n// Insert binary keys\ntree.set(new Uint8Array([0x47, 0x45, 0x54, 0x20]), 'GET ');     // \"GET \"\ntree.set(new Uint8Array([0x50, 0x4F, 0x53, 0x54]), 'POST');      // \"POST\"\ntree.set(new Uint8Array([0x50, 0x55, 0x54, 0x20]), 'PUT ');      // \"PUT \"\n\n// Retrieve values\nconsole.log(tree.get(new Uint8Array([0x47, 0x45, 0x54, 0x20]))); // \"GET \"\n\n// Delete keys\ntree.delete(new Uint8Array([0x50, 0x4F, 0x53, 0x54])); // Remove POST\n\nconsole.log(tree.size); // 2\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstreamich%2Fsonic-forest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstreamich%2Fsonic-forest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstreamich%2Fsonic-forest/lists"}