js-sdsl is a comprehensive JavaScript library providing various standard data structures, designed to offer high performance comparable to C++ STL. It includes implementations for structures like Stack, Queue, PriorityQueue, Vector, LinkedList, Deque, OrderedSet, OrderedMap, HashSet, and HashMap. The library is currently on stable version 4.4.2, actively maintained with a regular release cadence as seen by frequent updates within the 4.x series. Its key differentiators include optimized performance that often surpasses other popular JavaScript data structure libraries (e.g., Denque), a lightweight footprint (~9KB compressed), and a lack of external dependencies. It also provides C++ STL-like bidirectional iterators and ships with full TypeScript type definitions, making it suitable for modern JavaScript and TypeScript projects that require efficient, robust data management.
npm install js-sdslVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the instantiation and basic operations of OrderedMap, Deque, and Vector, including adding, retrieving, iterating, and modifying elements.
Rename `Set` to `OrderedSet` and `Map` to `OrderedMap` in your code. Update method calls from `eraseElementByValue` to `eraseElementByKey` for affected containers.
Benchmark critical sections of your application to determine if `js-sdsl` provides a meaningful performance improvement for your specific use case, especially for smaller datasets.
Refactor your module imports to use ESM `import { Name } from 'js-sdsl';` syntax. If you are in a pure CommonJS environment, consider using dynamic `import('js-sdsl').then(...)` or ensure your build setup correctly transpiles ESM to CJS with named exports.If experiencing unexpected iterator behavior, review the `CHANGELOG.md` for your specific `js-sdsl` version regarding iterator updates and adjust custom iterator logic or assumptions accordingly.
Ensure you are using `import { OrderedMap } from 'js-sdsl';` in ESM or `const { OrderedMap } = require('js-sdsl');` in CJS. For v4+, ESM is highly recommended.Verify that `container` is correctly initialized, for example: `const container = new OrderedMap<KeyType, ValueType>();`. Also, ensure you are calling the correct method for the specific data structure (e.g., `OrderedSet` uses `add` instead of `set`).
Always check iterator validity before dereferencing or using it. Ensure that modifications to the container do not invalidate active iterators that are subsequently used. The library implements C++ STL-like iterators, so similar rules regarding iterator invalidation apply.
No dependency data recorded yet.