Skip to content
🌳 Simple and dynamic tree data structures in TypeScript
TypeScript JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
dist
docs
spec
src
.editorconfig
.eslintrc.json
.gitattributes
.gitignore
LICENSE
README.md
jsdoc.json
package-lock.json
package.json
rollup.config.js
tsconfig.json
tsconfig.lint.json

README.md

Quercus

Simple and dynamic tree data structures in TypeScript

Introduction

Quercus allows you to create tree data structures of any size and depth. The Quercus class extends Map,meaning you can use methods like forEach or values on it. Even though the examples use strings as path items, any data type accepted as a Map key can be used.

Docs

Usage

npm install quercus

Example

import {Quercus} from "quercus";

const tree = new Quercus();

tree.setPath(["foo", "bar"], 5);
tree.setPath(["foo", "bizz"], 12);
tree.setPath(["bar", "fazz"], 560);

Creates a tree like this:

        tree
        /  \
      foo   bar
      / \     \
    bar bizz  fazz
     |   |      |
     5   12    560

You could also create the paths in the constructor:

import {Quercus} from "quercus";

const tree = new Quercus([
    [["foo", "bar"], 5],
    [["foo", "bizz"], 12],
    [["bar", "fazz"], 560]
]);
You can’t perform that action at this time.