Éter is a conglomerate of lightweight collections for JavaScript running on node and browser.
For node, install the package and include it
vareter=require('eter');For the browser, just include the modules you want. You could use Bower to install the package
bower install eter --save
And include the script
<scriptsrc="path/to/eter/dist/eter.js"></script>If you use TypeScript, typings are included
import{Stack}from'eter';lets: Stack<number>=newStack();A Stack is a Last-In-First-Out (LIFO) data structure.
vars=neweter.Stack();s.push(1);s.push(2);s.pop();//2s.pop();//1s.isEmpty();//trues.pop();//Error "Empty stack"A Queue is a First-In-First-Out (FIFO) data structure.
varq=neweter.Queue();q.enqueue(1);q.enqueue(2);q.dequeue();//1q.dequeue();//2q.isEmpty();//trueq.dequeue();//Error "Empty queue"A Linked List is a data structure consisting of a group of nodes which together represent a sequence.
varl=neweter.LinkedList();l.add(1);l.get(0);//1l.remove(0);l.isEmpty();//truel.get(0);//Error "Index 0 out of bounds"A Trie is an ordered tree data structure that is used to store a dynamic set or associative array where the keys are usually strings.
vart=neweter.Trie();t.insert('one');t.insert('oh');t.insert('on');t.contains('one');//truet.insert('foo');t.remove('foo');t.contains('foo');//falseA Hash Map is a data structure used to implement an associative array, a structure that can map keys to values.
varm=neweter.HashMap();m.put('key','value');m.get('key');//valuem.contains('key');//truem.remove('key');m.contains('key');//falseA Binary Tree is a data structure used for logarithmic search access.
vart=neweter.BinaryTree();t.insert(10,'value');t.get(10);//valuet.remove(10);t.get(10);//null