Skip to content

Commit 4245168

Browse files
committed
📝 Mention SlidingTaskMap type definition in README
1 parent b051f5b commit 4245168

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,17 @@ app.get('/observations/:date', async function (req, res) {
111111
```
112112

113113
**Sliding window**
114+
```typescript
115+
// Type Definition
116+
declare class SlidingTaskMap<K, V extends Deletable> extends TaskMap<K, V> {
117+
constructor(windowSize: number);
118+
set(key: K, value: V): this; // create/override
119+
delete(key: K): boolean; // remove single entry
120+
clear(): void; // removes all entries
121+
pop(): boolean; // removes oldest entry, false for an empty window
122+
shift(): boolean; // removes newest entry, false for an empty window
123+
}
124+
```
114125

115126
When your map size reaches a specified threshold, the oldest values will be
116127
removed. You can be then sure that the size of the map will never overflow your memory.

0 commit comments

Comments
 (0)