Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tomdionysus/stringtree-js
StringTree in NodeJS
https://github.com/tomdionysus/stringtree-js
Last synced: 1 day ago
JSON representation
StringTree in NodeJS
- Host: GitHub
- URL: https://github.com/tomdionysus/stringtree-js
- Owner: tomdionysus
- License: 0bsd
- Created: 2020-05-23T03:37:40.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T06:43:39.000Z (about 2 years ago)
- Last Synced: 2024-12-18T22:28:47.590Z (about 1 month ago)
- Language: JavaScript
- Size: 184 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# stringtree
[![Build Status](https://img.shields.io/travis/tomdionysus/stringtree-js/master.svg)](https://travis-ci.org/tomdionysus/stringtree-js)
[![Coverage Status](https://coveralls.io/repos/github/tomdionysus/stringtree-js/badge.svg?branch=master)](https://coveralls.io/github/tomdionysus/stringtree-js?branch=master)
[![NPM version](https://img.shields.io/npm/v/stringtree.svg)](https://www.npmjs.com/package/stringtree)stringtree is a package to enable fast, forward only parsing of text, partial matches, typeahead search, and other functionality by building a prefix tree or *trie* from a set of key/value pairs.
## Installation
```bash
npm install stringtree-js
```## Examples
```javascript
const { StringTree } = require('stringtree')var st = new StringTree()
// Loading The Tree
st.set('relief',10)
st.set('sentence',20)
st.set('expect',20)
st.set('fisherman',30)
st.set('avenue',40)
st.set('path',50)
st.set('expected',60)
st.set('expectation',70)// Simple Search
console.log('fisherman',st.get('fisherman'))
// > fisherman 30// Prefix Search (typeahead)
console.log('fish',st.prefix('fish'))
console.log('exp',st.prefix('exp'))
// > fish { fisherman: 30 }
// > exp { expect: 20, expected: 60, expectation: 70 }
```