Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/liammartens/sorted-linked-map
https://github.com/liammartens/sorted-linked-map
Last synced: 7 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/liammartens/sorted-linked-map
- Owner: LiamMartens
- License: mit
- Created: 2024-02-08T15:34:07.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-03-10T21:13:20.000Z (8 months ago)
- Last Synced: 2024-10-18T16:13:35.444Z (18 days ago)
- Language: TypeScript
- Size: 35.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sorted Linked Map
[![badge](https://img.shields.io/npm/v/sorted-linked-map)](https://www.npmjs.com/package/sorted-linked-map) [![badge](https://img.shields.io/bundlephobia/min/sorted-linked-map)](https://bundlephobia.com/package/sorted-linked-map) ![badge](https://img.shields.io/github/license/LiamMartens/sorted-linked-map)
This is an ordered linked map (like a double linked list) with items reachable by key.
### Usage
```js
import { SortedLinkedMap } from "sorted-linked-map";type UserType = {
id: string;
name: string;
age: number;
};const list = new SortedLinkedMap(
(value) => value.id,
(a, b) => (a.age < b.age ? -1 : 1)
);list.add({
id: "john.doe",
age: 35,
name: "John Doe",
});list.add({
id: "john.smith",
age: 28,
name: "John Smith",
});
```