functional-trie

0.0.2 • Public • Published

SYNOPSIS

NPM Package Build Status Coverage Status

js-standard-style

This is a Functional Trie implementation. imerative-trie is the imperative version.

USAGE

const Vertex = require('functional-trie')
 
// to start with the graph is just a single vertex
var vertex = new Vertex()
 
// now lets add an edge to the vertex named "bob" that points to another vertex with the value "alice"
vertex = vertex.set('friend', new Vertex('alice'))
 
// if paths have more than one name in them they can arrays
vertex = 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 = 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
vertices = [...vertex.walkPath(['friend', 'brother'])]
 
// delete an edge
vertex = vertex.delete('friend')
// now the vertex is empty
vertex.isEmpty // true

API

./docs/

LICENSE

MPL-2.0

Readme

Keywords

Package Sidebar

Install

npm i functional-trie

Weekly Downloads

1

Version

0.0.2

License

MPL-2.0

Unpacked Size

112 kB

Total Files

21

Last publish

Collaborators

  • null_radix