New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

normaltree

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

normaltree

normalized tree for efficient lookup

latest
Source
npmnpm
Version
0.2.1
Version published
Maintainers
1
Created
Source

NormalTree/FlatTree

npm install normaltree

const FlatTree = require('normaltree');

let sharedStorage = {};
let primaryKey = model => model.id;
//Both of these are optional parameters.
let ft = new FlatTree(sharedStorage, primaryKey);
ft.index("name", model => model.name);
ft.addChild({id: 1, name: "John Doe"});
More:
ft.getByIndexedValue("name", "John Doe"); //[FlatTreeNode]
ft.getByIndexOneOrNone("name", "John Doe"); //FlatTreeNode
ft.get({id: 1}) // FlatTreeNode
ft.get({id: 1}) === ft.getByIndexOneOrNone("name", "John Doe"); // true
ft.getByKey(1); //FlatTreeNode
ft.getByKey(1).addChild({id: 2, name: "Alice Bailey"}); //new FlatTreeNode

ft.getByKey(1).children // [FlatTreeNode Alice]

ft.getByKey(1).delete();
ft.getByKey(1); //undefined

FlatTree is pass by value.

Cannot Index Null Values

Built-in uid function might lead to hash collisions

MIT

FAQs

Package last updated on 24 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts