(store: Store, value: Uint8Array | string, maxQueueSize: number)
| 55 | |
| 56 | /** Insert into the end of the store */ |
| 57 | export function push(store: Store, value: Uint8Array | string, maxQueueSize: number): Promise<void> { |
| 58 | return store(store => { |
| 59 | return keys(store).then(keys => { |
| 60 | if (keys.length >= maxQueueSize) { |
| 61 | return; |
| 62 | } |
| 63 | |
| 64 | // We insert with an incremented key so that the entries are popped in order |
| 65 | store.put(value, Math.max(...keys, 0) + 1); |
| 66 | return promisifyRequest(store.transaction); |
| 67 | }); |
| 68 | }); |
| 69 | } |
| 70 | |
| 71 | /** Insert into the front of the store */ |
| 72 | export function unshift(store: Store, value: Uint8Array | string, maxQueueSize: number): Promise<void> { |
no test coverage detected