JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q39482F
  • License MPL-2.0

an imperative implementation

Package Exports

  • imperative-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 (imperative-trie) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

NPM Package Build Status Coverage Status

js-standard-style

SYNOPSIS

This is an Imperative Trie implementation. functional-trie is the functional version.

USAGE

const Vertex = require('imperative-trie')

// to start with, the graph is just a single vertex
const vertex = new Vertex()

// now lets add an edge to the vertex named "bob" that points to another vertex with the value "alice"
vertex.set('friend', new Vertex('alice'))

// if paths have more than one name in them they can arrays
vertex.set(['friend', 'brother'], new Vertex('bob'))
// now the graph looks like:
// [vertex]---friend--->[alice]---brother-->[bob]

// path names and vertex values can be anything
vertex.set([new Buffer('friend'), 5, true, {}, new Date()], new Vertex(['an array of some stuff']))

// edges are stored in a Map
vertex.edges // Map{}

// you can also iterate a path
let vertices = [...vertex.walkPath(['friend', 'brother'])]

// or the entire trie
vertices = [...vertex]

// delete an edge
vertex = vertex.delete('friend')
// now the vertex is empty
vertex.isEmpty // true

API

./docs/

LICENSE

MPL-2.0