Typed Structures
Typed Structures is an MIT-licensed on-going open source project meant to bring a fullset of data structures to the awesome TypeScript 🎉
Motivation
With the rise in popularity of Typescript, we think that having the same kind of data structures as the standard libraries of widely used strongly typed languages would be helpful to anyone planning to implement complex features. We believe in the power of open-source and we want this project to be driven by the ones who need it.
How to install
npm install typed-structures
How to import
;
Documentation 📝
Complete API available here.
Structures (Examples) 📕📗📘
Doubly linked list
Generic doubly linked list.
;;;
Map
Generic plain data map.
;; ; map.put'todo', new Stack;map.put'in-progress', new Stack;map.put'done', new Stack; ;;todo.stackfirstTask;map.replace'todo', todo; ;inProgress.stackmap.get'todo'.unstack;map.replace'in-progress', inProgress; ;done.stackmap.get'in-progress'.unstack;map.replace'done', done;
Set
Generic set.
; ; set.add'first';set.add'second'; console.logset.contains'first'; // true for of set.keys console.logkey; // first, second
Stack
Simple and generic stack.
;; ; taskStack.stacknew Task'taskName'; console.logtaskStack.peek.name; // taskName console.logtaskStack.empty; // false console.logtaskStack.length; // 1 console.logtaskStack.unstack.name; //taskName console.logtaskStack.empty; // true
Queue
;;; ;;;; channel.enqueueemiter1.emit'Hi !';channel.enqueueemiter2.emit'Hey, How are you doing ?';/* ... */ while !channel.empty
Binary tree
; ; tree.add'Find me ^^'; console.logtree.findtree.root, 'Find me ^^'; // Find me ^^console.logtree.findtree.root, '404'; // undefined
Buffer
Generic buffer.
; ; b.put1; b.put2; b.rewind; console.logb.get; // 1 console.logb.get; // 2
RingBuffer
Generic ring buffer.
; ;b.put1;b.put2; console.logb.get; // 1
TsQ (LinQ inspired)
Minimalist implementation of .NET's LinQ for TypedStructures.
;; ;;;;; ;unknowns.addfirstUnknown;unknowns.addsecondUnknown;unknowns.addthirdUnknown;unknowns.addfourthUnknown;unknowns.addfifthUnknown; TsQ.fromunknowns .select"name" .wheree.name.length > 4 .order_by"id", "desc" .fetch; TsQ.fromunknowns .group_by"group" .fetch;
Questions 💬
For questions and support feel free to open an issue
Issues 🔎
See CONTRIBUTING.md
Contribution 🛠
Feel free to contribute and enhance typed structures 🎉💛
License
2018-present Anthony & Thibaud