MCPcopy Create free account
hub / github.com/getsentry/sentry-javascript / unshift

Function unshift

packages/browser/src/transports/offline.ts:72–84  ·  view source on GitHub ↗
(store: Store, value: Uint8Array | string, maxQueueSize: number)

Source from the content-addressed store, hash-verified

70
71/** Insert into the front of the store */
72export function unshift(store: Store, value: Uint8Array | string, maxQueueSize: number): Promise<void> {
73 return store(store => {
74 return keys(store).then(keys => {
75 if (keys.length >= maxQueueSize) {
76 return;
77 }
78
79 // We insert with an decremented key so that the entries are popped in order
80 store.put(value, Math.min(...keys, 0) - 1);
81 return promisifyRequest(store.transaction);
82 });
83 });
84}
85
86/** Pop the oldest value from the store */
87export function shift(store: Store): Promise<Uint8Array | string | undefined> {

Callers 2

offline.test.tsFile · 0.90
createIndexedDbStoreFunction · 0.85

Calls 4

promisifyRequestFunction · 0.85
putMethod · 0.80
keysFunction · 0.70
thenMethod · 0.45

Tested by

no test coverage detected