Skip to content
You must be logged in to sponsor zrwusa

Become a sponsor to zrwusa

Who am I

I am a software development engineer with 15 years of experience. After graduating from university, I have worked in various industries, including some well-known companies.

Current Situation

I moved to Malaysia for my child to receive formal education and hold a 10-year residency visa. However, this visa does not allow me to be employed by Malaysian companies. Due to my passion for programming and the absence of a standard data structures library in JavaScript/TypeScript, I decided to implement my own set of data structures - data-structure-typed in the open-source community.

NPM

Github

Project Introduction

Ultimate Goal

  • Become a part of the standard library in JS/TS.

Pain Points Addressed

Lack of Native Data Structures in JS/TS

  • Queue: Many people use Array to simulate Queue and Deque, but the time complexity of Array.shift is O(n). We have implemented a Queue and Deque with O(1) time complexity for enqueue and dequeue operations.

  • HashMap: If you wish to use a pure HashMap to speed up your algorithms instead of the built-in Map (technically a LinkedHashMap), which the performance is compromised due to the need to consider insertion order. We have independently implemented a HashMap.

  • Stack: In JS, simulating a Stack with an Array is acceptable, and its performance is not inferior to a genuine Stack.

Missing Built-in Data Structures in JS/TS

  • Heap / Priority Queue: The algorithm with O(log n) time complexity has been popular for improving efficiency since the advent of computers. A Heap supports insertion, deletion, and search with O(log n) time complexity, along with the ability to obtain the minimum value in O(1) time.

  • Red Black Tree: Developers familiar with databases, file systems, Linux virtual memory management, and network routing tables often have some understanding of Red-Black Tree. It's the least operation-intensive among all balanced binary search trees and offer the best performance balance in CRUD operations.

  • Linked List: For scenarios where insertion or deletion of elements is required at a specific index in an ordered collection, JS lacks a provided data structure. We need a LinkedList to implement this functionality.

Advantages

Performance:

  • The performance of some data structures has surpassed JS's built-in data structures (Queue, Deque, HashMap), while most are close to or surpass those in other languages. Some are still not up to standard (Graph, AVL Tree).

Uniformity

    1. Implement or constrain forEach, filter, map, every, some, reduce, find, has, hasValue, get, print, isEmpty, clear, clone methods in the base class.
    1. Use generators to uniformly implement [Symbol.iterator], entries, keys, values. Delay iterator execution to prevent performance loss and provide control during traversal.
    1. All deletion methods uniformly use the commonly used delete in ES6. Addition methods uniformly use add. Compatibility with some specifications in Java.
    1. The first parameter for all constructors is data, and the second parameter is configuration, maintaining uniformity. The first parameter accepts any iterable type for free conversion between data structures.
    1. Uniform return types, e.g., add method uniformly returns a boolean.

Convenience and Simplicity of APIs

  • Inspired by ES6, Java, ESNext, TypeScript, Python, e.g., forEach, filter, map, every, some, reduce, find, has, hasValue, get

Use Commonly Understood Industry Standard Naming

  • enqueue, dequeue, push, pop, poll, addLast, addFirst, pollFirst, pollLast, isEmpty, clear, print, clone

Implement Customizable Features Whenever Possible

  • Such as providing callback functions (lambda expressions) for all traversal methods.

Comprehensive Documentation

  • Documentation not only explains the purpose of methods but also annotates time and space complexity across the entire series.

Community Activity

  • In terms of the community, NPM download count npm, GitHub stars GITHUB Star, contributors GitHub contributors

Sponsor Us

  • In terms of software engineering standards, our project has already achieved at least 75% completeness. With your sponsorship, we believe we can quickly raise the completion of this project to 95%, which is a form of assistance to my family and encouragement to our project team. We also hope to achieve the goal of becoming part of the JS/TS standard library as soon as possible.

Featured work

  1. zrwusa/data-structure-typed

    Javascript Data Structure & TypeScript Data Structure. Heap, Binary Tree, Red Black Tree, Linked List, Deque, Trie, HashMap, Directed Graph, Undirected Graph, Binary Search Tree, AVL Tree, Priority…

    TypeScript 135
  2. zrwusa/vivid-algorithm

    Examples of data-structure-typed, Javascript Data Structure, TypeScript Data Structure Library. And 150+ algorithms. Meticulously crafted to empower developers with a versatile set of essential dat…

    TypeScript 6

Select a tier

$ one time

Choose a custom amount.