{"id":29425876,"url":"https://github.com/shortwave/trie","last_synced_at":"2025-09-18T16:53:37.676Z","repository":{"id":46772278,"uuid":"398002103","full_name":"shortwave/trie","owner":"shortwave","description":"A fast trie implementation for typescript","archived":false,"fork":false,"pushed_at":"2023-03-16T05:38:10.000Z","size":4593,"stargazers_count":101,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-31T04:02:22.287Z","etag":null,"topics":["autocomplete","javascript","trie","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@shortwave/trie","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/shortwave.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-08-19T16:09:38.000Z","updated_at":"2025-05-07T09:37:03.000Z","dependencies_parsed_at":"2025-08-31T04:02:27.390Z","dependency_job_id":null,"html_url":"https://github.com/shortwave/trie","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/shortwave/trie","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shortwave%2Ftrie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shortwave%2Ftrie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shortwave%2Ftrie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shortwave%2Ftrie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shortwave","download_url":"https://codeload.github.com/shortwave/trie/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shortwave%2Ftrie/sbom","scorecard":{"id":820749,"data":{"date":"2025-08-11","repo":{"name":"github.com/shortwave/trie","commit":"f9990c714e690d87c70b6e7d37ff5eb909f03846"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/21 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Vulnerabilities","score":0,"reason":"24 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-67mh-4wv8-2f99","Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5","Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97","Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j","Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-353f-5xf4-qw67","Warn: Project is vulnerable to: GHSA-c24v-8rfc-w8vw","Warn: Project is vulnerable to: GHSA-8jhw-289h-jh2g","Warn: Project is vulnerable to: GHSA-64vr-g452-qvp3","Warn: Project is vulnerable to: GHSA-9cwx-2883-4wfx","Warn: Project is vulnerable to: GHSA-vg6x-rcgg-rjx6","Warn: Project is vulnerable to: GHSA-x574-m823-4x7w","Warn: Project is vulnerable to: GHSA-4r4m-qw57-chr8","Warn: Project is vulnerable to: GHSA-xcj6-pq6g-qj4x","Warn: Project is vulnerable to: GHSA-356w-63v5-8wf4","Warn: Project is vulnerable to: GHSA-859w-5945-r5v3"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T15:29:23.553Z","repository_id":46772278,"created_at":"2025-08-23T15:29:23.553Z","updated_at":"2025-08-23T15:29:23.553Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272936419,"owners_count":25018160,"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-31T02:00:09.071Z","response_time":79,"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":["autocomplete","javascript","trie","typescript"],"created_at":"2025-07-12T10:16:19.238Z","updated_at":"2025-09-18T16:53:32.634Z","avatar_url":"https://github.com/shortwave.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"A fast weighted auto-completion trie.\n\n\u003ca href=\"https://badge.fury.io/js/%40shortwave%2Ftrie\"\u003e\u003cimg src=\"https://badge.fury.io/js/%40shortwave%2Ftrie.svg\" alt=\"npm version\" height=\"18\"\u003e\u003c/a\u003e\n\nUsage\n=====\n\n```typescript\n\nimport Trie from '@shortwave/trie';\n\nconst trie = new Trie\u003cContact\u003e();\n\ntrie.add({\n    key: \"richard\",\n    value: {name: \"Richard\", ...},\n    score: 5\n});\n\ntrie.add({\n    key: \"rachael\",\n    value: {name: \"Rachael\", ...},\n    score: 1\n});\n\ntrie.add({\n    key: \"sarah\",\n    value: {name: \"Sarah\", ...},\n    score: 3\n});\n\ntrie.add({\n    key: \"sam\",\n    value: {name: \"Sam\", ...},\n    score: 2\n});\n\n// The limit option limits the number of results.\n// The unique option returns only the first result for each key\n// (the trie can store multiple values per key)\ntrie.prefixSearch('r', {limit: 3, unique: true})\n//=\u003e [{name: \"Richard\", ...} , {name: \"Rachael\", ...}]\n\n\n// You can also remove nodes from the tree.\ntrie.remove({key: \"sarah\"});\n```\n\nEfficiency\n==========\n\nThe problem with building a search tree for contacts is that the order of\nresults is orthogonal from the search.\n\nIf I type \"R\", my dad (\"Richard\") should be the first auto-completion result, not\nmy friend \"Rachael\" who I haven't spoken to for a year.\n\nTo do this nodes in the trie have their highest score attached:\n\n```\n                     + (4) rachael\n           + (4) r --+ (1) richard\n  root ----+\n           + (3) s ---+ (3) a ---+ (3) sarah\n                                 + (2) sam\n```\n\nTo improve indexing time, sub-nodes are not sorted; so on the first access to\neach section of the tree you have to pay the cost of sorting the sub-nodes (\nthis is usually a very small sort, \u003c5 entries, per node in the tree).\n\nThere's also a special case for nodes with one child, where we don't expand\nthem out letter by letter. (An exercise for the reader would be to use a\nfully compressed trie, which would give us this optimization as a side-effect)\n\nThe search algorithm maintains a queue of nodes to visit based on score, and is\ntruncated to the limit. The most expensive part of the search is merging the\ncurrent node's children into the priority queue, and so the efficiency of lookup\nis dominated by the limit parameter, with some additional cost due to having to\ntraverse many intermediate nodes (see note about implementing a compressed trie).\n\nMeta-fu\n=======\n\nThis code base started out as the trie implementation from\nhttps://github.com/superhuman/trie-ing with changes for typescript and deletion.\n\nSee LICENSE for original copyright holder, changes are also released under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshortwave%2Ftrie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshortwave%2Ftrie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshortwave%2Ftrie/lists"}