{"id":16252385,"url":"https://github.com/remarkablemark/trieste","last_synced_at":"2026-05-20T14:38:35.319Z","repository":{"id":57379891,"uuid":"205301901","full_name":"remarkablemark/trieste","owner":"remarkablemark","description":":evergreen_tree:Trie generator.","archived":false,"fork":false,"pushed_at":"2020-07-13T22:31:21.000Z","size":56,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-25T21:39:05.456Z","etag":null,"topics":["javascript","npm","package","trie","trie-node","trie-structure","trie-tree","tries"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/trieste","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/remarkablemark.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":[],"patreon":"remarkablemark","open_collective":null,"ko_fi":"remarkablemark","tidelift":null,"community_bridge":null,"liberapay":"remarkablemark","issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-08-30T04:03:47.000Z","updated_at":"2023-04-11T15:26:56.000Z","dependencies_parsed_at":"2022-09-05T13:50:37.661Z","dependency_job_id":null,"html_url":"https://github.com/remarkablemark/trieste","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/remarkablemark/trieste","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkablemark%2Ftrieste","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkablemark%2Ftrieste/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkablemark%2Ftrieste/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkablemark%2Ftrieste/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remarkablemark","download_url":"https://codeload.github.com/remarkablemark/trieste/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remarkablemark%2Ftrieste/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263995282,"owners_count":23541361,"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":["javascript","npm","package","trie","trie-node","trie-structure","trie-tree","tries"],"created_at":"2024-10-10T15:13:31.094Z","updated_at":"2026-05-20T14:38:35.251Z","avatar_url":"https://github.com/remarkablemark.png","language":"JavaScript","funding_links":["https://patreon.com/remarkablemark","https://ko-fi.com/remarkablemark","https://liberapay.com/remarkablemark"],"categories":[],"sub_categories":[],"readme":"# trieste\n\n[![NPM](https://nodei.co/npm/trieste.png)](https://nodei.co/npm/trieste/)\n\n[![NPM version](https://img.shields.io/npm/v/trieste.svg)](https://www.npmjs.com/package/trieste)\n[![Build Status](https://travis-ci.org/remarkablemark/trieste.svg?branch=master)](https://travis-ci.org/remarkablemark/trieste)\n[![Coverage Status](https://coveralls.io/repos/github/remarkablemark/trieste/badge.svg?branch=master)](https://coveralls.io/github/remarkablemark/trieste?branch=master)\n\n[Trie](https://wikipedia.org/wiki/Trie) generator.\n\n[Repl.it](https://repl.it/@remarkablemark/trieste) | [JSFiddle](https://jsfiddle.net/remarkablemark/fjm2xyp0/) | [Examples](https://github.com/remarkablemark/trieste/tree/master/examples)\n\n## Installation\n\n[NPM](https://www.npmjs.com/package/trieste):\n\n```sh\n$ npm install trieste --save\n```\n\n[Yarn](https://yarnpkg.com/package/trieste):\n\n```sh\n$ yarn add trieste\n```\n\n[CDN](https://unpkg.com/trieste/):\n\n```html\n\u003cscript src=\"https://unpkg.com/trieste@latest/dist/trieste.min.js\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\n### Module\n\nImport the module:\n\n```js\n// CommonJS\nconst trieste = require('trieste');\n\n// ES Modules\nimport trieste from 'trieste';\n```\n\n### Trie\n\nCreate a trie instance:\n\n```js\nconst trie = trieste();\n```\n\nThis can also be done by instantiating the constructor:\n\n```js\nconst Trie = require('trieste/lib/trie');\nconst trie = new Trie();\n```\n\n#### Options\n\nOptions can be set for each instance:\n\n```js\nconst options = {\n  endKey: 'END_OF_STRING_KEY',\n  endValue: 'END_OF_STRING_VALUE'\n};\nconst trie = trieste(options);\n```\n\nThis can also be achieved with the constructor:\n\n```js\nconst Trie = require('trieste/lib/trie');\n\nconst trie = new Trie({\n  endKey: 'END_OF_STRING_KEY',\n  endValue: 'END_OF_STRING_VALUE'\n});\n```\n\nOptions are found on the instance's `options` property:\n\n```js\ntrie.options;\n```\n\nThe default options are:\n\n```js\n{\n  endKey: '$$',\n  endValue: 1\n}\n```\n\nOptions have a direct effect on the trie's [data](#data) and methods like [add](#add) and [get](#add).\n\n#### Data\n\nData can be found on the instance's `data` property:\n\n```js\ntrie.data;\n```\n\nData is a POJO (Plain Old JavaScript Object), which means it can be converted to [JSON](https://www.json.org/):\n\n```js\nJSON.stringify(trie.data);\n```\n\nAs an example, the following is the output of `trieste().add('a').data`:\n\n```js\n{ a: { '$$': 1 } }\n```\n\n### Methods\n\n#### Add\n\nAdd a string to the trie:\n\n```js\ntrie.add('foo');\n```\n\nAdd multiple strings to the trie:\n\n```js\ntrie.add('foo', 'bar');\n```\n\nAdd an array of strings to the trie:\n\n```js\ntrie.add.apply(trie, ['foo', 'bar']);\n```\n\nAdd a string with a value to the trie:\n\n```js\ntrie.add({ answer: 42 });\n```\n\nThis is useful if you want to store value(s) other than the default. See method [get](#get) on how to retrieve a string value.\n\nSince the method returns its own instance, method chaining is possible:\n\n```js\ntrie.add('foo').add('bar');\n```\n\nArguments that are not type `string` will be skipped.\n\n#### Contains\n\nCheck if a string is found in the trie:\n\n```js\ntrie.contains('foo');\n```\n\nThe method returns a `boolean` value.\n\nArguments that are not type `string` will return `false`.\n\n#### Get\n\nGet a string value from the trie:\n\n```js\ntrie.get('foo');\n```\n\nThe value comes from `options.endValue`, which is `1` by default:\n\n```js\ntrie.add('foo').get('foo'); // 1\n```\n\nThe value can be set using the [add](#add) method:\n\n```js\ntrie.add({ foo: 'bar' }).get('foo'); // 'bar'\n```\n\nThe value can also be set in [options](#options):\n\n```js\nconst trie = trieste({ endValue: null });\ntrie.add('foo').get('foo'); // null\n```\n\nArguments that are not type `string` will return `undefined`.\n\n#### Remove\n\nRemove a string from the trie:\n\n```js\ntrie.remove('foo');\n```\n\nRemove multiple strings from the trie:\n\n```js\ntrie.remove('foo', 'bar');\n```\n\nRemove an array of strings from the trie:\n\n```js\ntrie.remove.apply(trie, ['foo', 'bar']);\n```\n\nSince the method returns its own instance, method chaining is possible:\n\n```js\ntrie.remove('foo').remove('bar');\n```\n\nArguments that are not type `string` will be skipped.\n\n## Testing\n\nRun tests:\n\n```sh\n$ npm test\n```\n\nRun tests in watch mode:\n\n```sh\n$ npm run test:watch\n```\n\nRun tests with coverage:\n\n```sh\n$ npm run test:coverage\n```\n\nView coverage in browser:\n\n```sh\n$ npm run test:coverage:report\n$ open coverage/index.html\n```\n\nLint files:\n\n```sh\n$ npm run lint\n```\n\nFix lint errors:\n\n```sh\n$ npm run lint:fix\n```\n\n## Release\n\nOnly collaborators with credentials can release and publish:\n\n```sh\n$ npm run release\n$ git push --follow-tags \u0026\u0026 npm publish\n```\n\n## License\n\n[MIT](https://github.com/remarkablemark/trieste/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremarkablemark%2Ftrieste","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremarkablemark%2Ftrieste","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremarkablemark%2Ftrieste/lists"}