{"id":13515432,"url":"https://github.com/MetaCorp/trie","last_synced_at":"2025-03-31T04:37:03.049Z","repository":{"id":143334555,"uuid":"113324145","full_name":"MetaCorp/trie","owner":"MetaCorp","description":"Blazing fast, \u003c1kb search for Javascript","archived":false,"fork":false,"pushed_at":"2017-12-22T14:38:25.000Z","size":57,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-08T09:35:43.118Z","etag":null,"topics":["fast","javascript","prefix-tree","search"],"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/MetaCorp.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}},"created_at":"2017-12-06T14:05:39.000Z","updated_at":"2023-10-13T23:06:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"ff2a4747-636e-4761-9ace-02af228ad4ee","html_url":"https://github.com/MetaCorp/trie","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MetaCorp%2Ftrie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MetaCorp%2Ftrie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MetaCorp%2Ftrie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MetaCorp%2Ftrie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MetaCorp","download_url":"https://codeload.github.com/MetaCorp/trie/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246418657,"owners_count":20773934,"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":["fast","javascript","prefix-tree","search"],"created_at":"2024-08-01T05:01:11.271Z","updated_at":"2025-03-31T04:37:02.539Z","avatar_url":"https://github.com/MetaCorp.png","language":"JavaScript","readme":"# Trie\n\nBlazing fast \u003c1kb search\n\n[![Build Status](https://travis-ci.org/MetaCorp/trie.svg?branch=master)](https://travis-ci.org/MetaCorp/trie)\n\n### Installation\n\nNPM\n\n```sh\nnpm install @metacorp/trie\n```\n\nCDN\n\n```html\n\u003cscript src=\"https://unpkg.com/@metacorp/trie\"\u003e\u003c/script\u003e\n```\n\n### Usage\n\nInitialize Trie with an array of data.\n\n```js\nconst trie = new Trie(['Apple', 'Lemon', 'Orange', 'Tomato'])\n```\n\nNow you can search for a query within the data, and Trie will return results.\n\n```js\ntrie.search('App')\n/*\n['Apple']\n*/\n```\n\nOr add word to the data.\n\n```js\ntrie.addWord('Kiwi')\n```\n\n### About\n\nThis repo is heavily inspired from [Wade](https://github.com/kbrsh/wade).\nIt's a simpler version of it without the ability to score the results, but is therefore significantly faster, and allow to add word after initialisation.\n\nTrie comes in two implementations of [prefix tree](https://en.wikipedia.org/wiki/Trie).\n\nVersion 1:\n- bundle size: 1.55kb(min) - 757b(gzip)\n- init speed: 12.24 Ops/sec\n- search speed: 79,000 Ops/sec\n\nVersion 2:\n- bundle size: 1.94kb(min) - 831b(gzip)\n- init speed: 3.07 Ops/sec\n- search speed: 94,000 Ops/sec\n\nCheck jsperf here:\n- [init](https://jsperf.com/metacorp-trie-init)\n- [search](https://jsperf.com/metacorp-trie-search)\n\nAnd bundle size: [here](https://bundlephobia.com/result?p=@metacorp/trie)\n\n### Processors\n\nTrie uses a set of processors to preprocess data and search queries. By default, these will:\n\n* Make everything lowercase\n* Remove punctuation\n* Remove stop words\n\nA process consists of different functions that process a string and modify it in some way, and return the transformed string.\n\nYou can easily modify the processors as they are available in `Trie.config.processors`, for example:\n\n```js\n// Don't preprocess at all\nTrie.config.processors = []\n\n// Add custom processor to remove periods\nTrie.config.processors.push(function(str) {\n  return str.replace(/\\./g, '')\n})\n```\n\nAll functions will be executed in the order of the array (0-n) and they will be used on each document in the data.\n\nThe stop words can be configured to include any words you like, and you can access the array of stop words by using:\n\n```js\nTrie.config.stopWords = [/* array of stop words */]\n```\n\nThe punctuation regular expression used to remove punctuation can be configured with:\n\n```js\nTrie.config.punctuationRE = /[.!]/g // should contain punctuation to remove\n```\n\n### License\n\nLicensed under the [MIT License](https://github.com/MetaCorp/trie/blob/master/LICENSE)\n\nCopyright (c) Meta l.szabatura@gmail.com\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMetaCorp%2Ftrie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMetaCorp%2Ftrie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMetaCorp%2Ftrie/lists"}