@llblab/uniqueue 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,10 +24,10 @@ npm install @llblab/uniqueue
|
|
|
24
24
|
### Basic Example (Max Heap)
|
|
25
25
|
|
|
26
26
|
```javascript
|
|
27
|
-
import {
|
|
27
|
+
import { Uniqueue } from "@llblab/uniqueue";
|
|
28
28
|
|
|
29
29
|
// Create a max-heap for leaderboard scores
|
|
30
|
-
const leaderboard = new
|
|
30
|
+
const leaderboard = new Uniqueue({
|
|
31
31
|
compare: (a, b) => b.score - a.score, // Sort by score descending
|
|
32
32
|
extractKey: (item) => item.playerId, // Unique by playerId
|
|
33
33
|
maxSize: 3, // Keep only top 3 scores
|
|
@@ -60,7 +60,7 @@ for (const player of leaderboard) {
|
|
|
60
60
|
|
|
61
61
|
## API
|
|
62
62
|
|
|
63
|
-
### `new
|
|
63
|
+
### `new Uniqueue(options)`
|
|
64
64
|
|
|
65
65
|
Creates a new priority queue instance.
|
|
66
66
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface UniqueueOptions<T> {
|
|
2
2
|
data?: T[];
|
|
3
3
|
maxSize?: number;
|
|
4
4
|
compare?: (a: T, b: T) => number;
|
|
5
5
|
extractKey?: (item: T) => string;
|
|
6
6
|
}
|
|
7
|
-
export declare class
|
|
7
|
+
export declare class Uniqueue<T> {
|
|
8
8
|
#private;
|
|
9
9
|
data: T[];
|
|
10
10
|
indexes: Map<string, number>;
|
|
11
|
-
constructor({ data, maxSize, compare, extractKey, }?:
|
|
11
|
+
constructor({ data, maxSize, compare, extractKey, }?: UniqueueOptions<T>);
|
|
12
12
|
push(item: T): T | undefined;
|
|
13
13
|
pop(): T | undefined;
|
|
14
14
|
peek(): T | undefined;
|
package/dist/index.js
CHANGED