JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q34545F
  • License MIT

typescript implementation of the prefix trie data structure

Package Exports

  • js-trie

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (js-trie) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

JS Trie

A typescript implementation of the Prefix Trie data structure.

Build Status Coverage Status npm version

Installation

npm i js-trie --save

Usage


const { Trie } = require('js-trie');

let trie = new Trie();

trie.insert("apple");
trie.search("apple");   // returns true
trie.search("app");     // returns false
trie.startsWith("app"); // returns true
trie.insert("app");   
trie.search("app");     // returns true

API

The library exposes the following functions:

  • insert(word : string) : void

Inserts an word into the prefix trie

  • search(word : string) : boolean

Returns true if the word exists in the prefix trie, otherwise false.

  • startsWith(prefix : string) : boolean

Returns true if there exists a word that starts with part, otherwise false.