Intro

Installable via npm install --save interface-datastore, it can also be used directly in the browser.

Download

The source is available for download from GitHub. Alternatively, you can install using npm:

$ npm install --save interface-datastore

You can then require() interface-datastore as normal:

const interfaceDatastore = require('interface-datastore')

In the Browser

interface-datastore should work in any ECMAScript 2018 environment out of the box.

Usage:

<script type="text/javascript" src="index.js"></script>

The portable versions of interface-datastore, including index.js and index.min.js, are included in the /dist folder. interface-datastore can also be found on unpkg.com under

A Key represents the unique identifier of an object. Our Key scheme is inspired by file systems and Google App Engine key model. Keys are meant to be unique across a system. Keys are hierarchical, incorporating more and more specific namespaces. Thus keys can be deemed 'children' or 'ancestors' of other keys:

  • new Key('/Comedy')
  • new Key('/Comedy/MontyPython') Also, every namespace can be parametrized to embed relevant object information. For example, the Key name (most specific namespace) could include the object type:
  • new Key('/Comedy/MontyPython/Actor:JohnCleese')
  • new Key('/Comedy/MontyPython/Sketch:CheeseShop')
  • new Key('/Comedy/MontyPython/Sketch:CheeseShop/Character:Mousebender')
new Key(s: any, clean: any)
Parameters
s (any)
clean (any)
Static Members
withNamespaces(list)
random()
Instance Members
toString(encoding)
toBuffer()
toStringTag
clean()
less(key)
reverse()
namespaces()
baseNamespace()
list()
type()
name()
instance(s)
path()
parent()
child(key)
isAncestorOf(other)
isDecendantOf(other)
isTopLevel()
concat(keys)

namespaceType

src/key.js

The first component of a namespace. foo in foo:bar

namespaceType(ns: string): string
Parameters
ns (string)
Returns
string:

namespaceValue

src/key.js

The last component of a namespace, baz in foo:bar:baz.

namespaceValue(ns: string): string
Parameters
ns (string)
Returns
string:

flatten

src/key.js

Flatten array of arrays (only one level)

flatten(arr: Array<Array>): any
Parameters
arr (Array<Array>)
Returns
any: