weaktree

0.2.0 • Public • Published

Switzerland

WeakMap implementation that allows for composite keys in a tree formation.

Travis   npm   License MIT   code style: prettier

npm: npm install weaktree

Getting Started

Use the array notation to set keys for your WeakTree.

You can perform the same operations on a WeakTree as you can on a WeakMap, such as set, get, has and delete. However WeakTree also has an additional function slice to take a slice of the tree which will give you a sub-tree.

import WeakTree from 'weaktree';

const tree = new WeakTree();

const a = {};
const b = {};

const x = {};
const y = {};
const z = {};

tree.set([a, b, x], `Life without love is like a tree without blossoms or fruit.`);
tree.set([a, b, y], `If you don't like how things are, change it! You're not a tree.`);
tree.set([a, b, z], `I looked up my family tree and found out I was the sap.`);

tree.get([a, b, x]); // Life without love is like a tree without blossoms or fruit.

const subTree = tree.slice([a, b]);
subTree.get([x]); // If you don't like how things are, change it! You're not a tree.

Readme

Keywords

none

Package Sidebar

Install

npm i weaktree

Weekly Downloads

0

Version

0.2.0

License

MIT

Unpacked Size

546 kB

Total Files

96

Last publish

Collaborators

  • wildhoney