-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
66 lines (56 loc) · 1.72 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
export = LoopQueue
declare class LoopQueue {
/**
* @param loops when greater than 0, limit the maximum loop times; defaults to `0`
* @param capacity when greater than 0, limit the maximum queue length; defaults to `0`
* @param hash function to generate `id` from item; defaults to `item => item`
*/
constructor(loops: number, capacity: number, hash: (item: any) => any)
/**
* Property to retrieve current length of the queue
*/
get length(): number
/**
* Add given item to the end of the queue
* @param item anything except `undefined`
* @return hash value which can be used to get or remove the item
*/
push(item): any
/**
* Same as [Symbol.iterator]
* @return item iterator
*/
values()
/**
* @param id by default, id is the same primitive value or object reference;
* when queue is constructed with a hash function, id is whatever that
* function returns
* @return the saved item
*/
get(id)
/**
* @param id by default, id is the same primitive value or object reference;
* when queue is constructed with a hash function, id is whatever that
* function returns
* @return true if id is found and deleted
*/
remove(id): boolean
/**
* Clear the entire queue
*/
clear()
/**
* Remove the first item in the queue and return it
* @return the first item in the queue
*/
shift(): any
/**
* Loop through the queue and return the next item.
* If `loops` is set, this method checks cyclic number and removes the item
* when reached.
* @param remove a predicate callback or boolean to determine whether to
* remove next item
* @return the next cyclic item
*/
next(remove: (item: any) => boolean | boolean): any
}