Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
javascript standard data structure library which benchmark against C++ STL
The js-sdsl package is a JavaScript library that provides a variety of data structures and algorithms. It is designed to be efficient and easy to use, offering structures like vectors, lists, queues, stacks, and trees, as well as algorithms for sorting, searching, and other operations.
Vector
Vector is a dynamic array that can grow and shrink in size. It provides random access to elements, similar to an array.
const { Vector } = require('js-sdsl');
let vector = new Vector();
vector.pushBack(1);
vector.pushBack(2);
console.log(vector.size()); // Output: 2
LinkedList
LinkedList is a sequence of elements where each element points to the next. It allows for efficient insertion and removal of elements from any position.
const { LinkedList } = require('js-sdsl');
let linkedList = new LinkedList();
linkedList.pushBack(1);
linkedList.pushFront(0);
console.log(linkedList.front()); // Output: 0
Queue
Queue is a first-in-first-out (FIFO) data structure that allows for efficient addition of elements at the end and removal from the front.
const { Queue } = require('js-sdsl');
let queue = new Queue();
queue.push(1);
queue.push(2);
console.log(queue.front()); // Output: 1
Stack
Stack is a last-in-first-out (LIFO) data structure that allows for adding and removing elements from the top of the stack.
const { Stack } = require('js-sdsl');
let stack = new Stack();
stack.push(1);
stack.push(2);
console.log(stack.top()); // Output: 2
Tree
Tree structures like AVLTree are used to store data in a hierarchical manner. AVLTree is a self-balancing binary search tree.
const { AVLTree } = require('js-sdsl');
let tree = new AVLTree();
tree.insert(1);
tree.insert(2);
console.log(tree.find(1)); // Output: true
Immutable.js offers persistent immutable data structures. Unlike js-sdsl, which provides mutable structures, Immutable.js ensures that the data cannot be changed once created.
Lodash is a utility library that provides functions for common programming tasks, including manipulating and testing values, arrays, objects, and strings. It is more focused on utility functions than the data structure implementations provided by js-sdsl.
Underscore.js is a utility library similar to Lodash, offering a range of functions for working with JavaScript collections and arrays. It does not focus on providing data structures but offers many utilities for working with existing ones.
A javascript standard data structure library which benchmark against C++ STL
English | 简体中文
length
directly.unshift
or getting elements by index.We are benchmarking against other popular data structure libraries. In some ways we're better than the best library. See benchmark.
IE / Edge | Firefox | Chrome | Safari | Opera | NodeJs |
---|---|---|---|---|---|
Edge 12 | 36 | 49 | 10 | 36 | 10 |
Download directly by cdn:
Or install js-sdsl using npm:
npm install js-sdsl
Or you can download the isolation packages containing only the containers you want:
You can visit our official website to get more information.
To help you have a better use, we also provide this API document.
For previous versions of the documentation, please visit:
https://js-sdsl.org/js-sdsl/previous/v${version}/index.html
E.g.
https://js-sdsl.org/js-sdsl/previous/v4.1.5/index.html
<script src="https://unpkg.com/js-sdsl/dist/umd/js-sdsl.min.js"></script>
<script>
const {
Vector,
Stack,
Queue,
LinkList,
Deque,
PriorityQueue,
OrderedSet,
OrderedMap,
HashSet,
HashMap
} = sdsl;
const myOrderedMap = new OrderedMap();
myOrderedMap.setElement(1, 2);
console.log(myOrderedMap.getElementByKey(1)); // 2
</script>
// esModule
import { OrderedMap } from 'js-sdsl';
// commonJs
const { OrderedMap } = require('js-sdsl');
const myOrderedMap = new OrderedMap();
myOrderedMap.setElement(1, 2);
console.log(myOrderedMap.getElementByKey(1)); // 2
We use karma and mocha frame to do unit tests and synchronize to coveralls. You can run yarn test:unit
command to reproduce it.
We tested most of the functions for efficiency. You can go to gh-pages/performance.md
to see our running results or reproduce it with yarn test:performance
command.
You can also visit here to get the result.
Use Gitpod, a free online dev environment for GitHub.
Or clone locally:
$ git clone https://github.com/js-sdsl/js-sdsl.git
$ cd js-sdsl
$ npm install
$ npm run dev # development mode
Then you can see the output in dist/cjs
folder.
Feel free to dive in! Open an issue or submit PRs. It may be helpful to read the Contributor Guide.
Thanks goes to these wonderful people:
Takatoshi Kondo 💻 ⚠️ | noname 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!
The special thanks to these sponsors or backers because they provided support at a very early stage:
Thanks also give to these sponsors or backers:
[4.4.2] - 2023.07.21
isAccessible
function to iterators for iterable containers.FAQs
javascript standard data structure library which benchmark against C++ STL
The npm package js-sdsl receives a total of 2,780,194 weekly downloads. As such, js-sdsl popularity was classified as popular.
We found that js-sdsl demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.