
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
@js-sdsl/ordered-map
Advanced tools
javascript standard data structure library which benchmark against C++ STL
@js-sdsl/ordered-map is a JavaScript library that provides an ordered map data structure. This data structure maintains the order of elements based on their keys, allowing for efficient insertion, deletion, and access operations. It is particularly useful for scenarios where the order of elements is important and you need to perform frequent updates.
Insertion
This feature allows you to insert key-value pairs into the ordered map. The elements are stored in the order they are inserted.
const { OrderedMap } = require('@js-sdsl/ordered-map');
const map = new OrderedMap();
map.set('a', 1);
map.set('b', 2);
map.set('c', 3);
console.log(map);
Access
This feature allows you to access the value associated with a specific key in the ordered map.
const { OrderedMap } = require('@js-sdsl/ordered-map');
const map = new OrderedMap();
map.set('a', 1);
map.set('b', 2);
map.set('c', 3);
console.log(map.get('b')); // Output: 2
Deletion
This feature allows you to delete a key-value pair from the ordered map based on the key.
const { OrderedMap } = require('@js-sdsl/ordered-map');
const map = new OrderedMap();
map.set('a', 1);
map.set('b', 2);
map.set('c', 3);
map.delete('b');
console.log(map);
Iteration
This feature allows you to iterate over the key-value pairs in the ordered map in the order they were inserted.
const { OrderedMap } = require('@js-sdsl/ordered-map');
const map = new OrderedMap();
map.set('a', 1);
map.set('b', 2);
map.set('c', 3);
for (const [key, value] of map) {
console.log(key, value);
}
The 'immutable' package provides immutable data structures, including OrderedMap. It ensures that data cannot be changed once created, which can help prevent bugs and improve performance in certain scenarios. Compared to @js-sdsl/ordered-map, 'immutable' focuses on immutability and offers a broader range of data structures.
The 'sorted-map' package provides a sorted map data structure that maintains the order of elements based on their keys. It offers similar functionality to @js-sdsl/ordered-map but focuses on sorting elements by key rather than maintaining insertion order.
The 'bintrees' package provides various binary tree data structures, including a Red-Black Tree, which can be used to implement ordered maps. It offers more control over the underlying tree structure compared to @js-sdsl/ordered-map, which abstracts these details away.
A javascript standard data structure library which benchmark against C++ STL
English | 简体中文
We are benchmarking against other popular data structure libraries. In some ways we're better than the best library. See benchmark.
Download directly
Or install js-sdsl using npm
npm install js-sdsl
You can visit our official website to get more information.
To help you have a better use, we also provide this API document.
<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
You can pull this repository and run yarn build
to rebuild this library.
We use jest library to write unit tests, you can see test coverage on 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.
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!
MIT © ZLY201
[4.1.5] - 2022.09.30
find
, remove
, updateItem
and toArray
functions to PriorityQueue
.FAQs
javascript standard data structure library which benchmark against C++ STL
The npm package @js-sdsl/ordered-map receives a total of 8,312,994 weekly downloads. As such, @js-sdsl/ordered-map popularity was classified as popular.
We found that @js-sdsl/ordered-map 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.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.