Coder Social home page Coder Social logo

node-treelib's Introduction

Build Status

treelib : create trees as easy as .path('a/b/c')

const Treelib = require('treelib');
var tree = new Treelib;
tree.path('a/b/c').setValue('foobar');

// { a : { b : { c : 'foobar' }}}

about

This provides a simple way to generate trees.

API

var tree = new Treelib;

starts a new tree object

var tree = new Treelib(obj)

starts a new tree object starting with obj

.path(string)

takes in a string such as "a/b/c"

.pathList(array)

takes in an array such as ["a", "b", "c"]

.pathAndSetValue(string,value)

takes in a string and sets a value there

.pathAndSetValue("a/b/c", "hello");
// { a : { b : { c : "hello" } } }

.pathListAndSetArray(array, value)

.pathListAndSetValue(["a", "b", "c"], "hello");
// { a : { b : { c : "hello" } } }

.getValue(string)

takes in a string and returns value there

.getValue('a/b/c')
// returns "hello"

.getListValue(list)

takes in a list and returns value there

.getListValue(["a","b","c"])
// returns "hello"

.get()

returns the tree

.setValue(value)

sets value at current branch

and that's it!

license

node-treelib Copyright (c) 2010-2017 David Wee [email protected] MIT Free software provided under the MIT License http://opensource.org/licenses/mit-license.php

node-treelib's People

Contributors

rook2pawn avatar papandreou avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.