Files
Signal-Desktop/ts/types/IndexedDB.ts
2018-04-25 15:24:51 -04:00

18 lines
593 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @prettier
*/
// IndexedDB doesnt support boolean indexes so we map `true` to 1 and `false`
// to `0`.
// N.B. Using `undefined` allows excluding an entry from an index. Useful
// when index size is a consideration or one only needs to query for `true`.
export type IndexableBoolean = IndexableFalse | IndexableTrue;
type IndexableTrue = 1;
type IndexableFalse = 0;
export const INDEXABLE_FALSE: IndexableFalse = 0;
export const INDEXABLE_TRUE: IndexableTrue = 1;
export const toIndexableBoolean = (value: boolean): IndexableBoolean =>
value ? INDEXABLE_TRUE : INDEXABLE_FALSE;