mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-25 02:48:23 +01:00
Rename files
This commit is contained in:
22
ts/types/IndexedDB.std.ts
Normal file
22
ts/types/IndexedDB.std.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright 2018 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
// IndexedDB doesn’t support boolean indexes so we map `true` to 1 and `false`
|
||||
// to `0`, i.e. `IndexableBoolean`.
|
||||
// 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`,
|
||||
// i.e. `IndexablePresence`.
|
||||
export type IndexableBoolean = IndexableFalse | IndexableTrue;
|
||||
export type IndexablePresence = undefined | IndexableTrue;
|
||||
|
||||
type IndexableFalse = 0;
|
||||
type IndexableTrue = 1;
|
||||
|
||||
export const INDEXABLE_FALSE: IndexableFalse = 0;
|
||||
export const INDEXABLE_TRUE: IndexableTrue = 1;
|
||||
|
||||
export const toIndexableBoolean = (value: boolean): IndexableBoolean =>
|
||||
value ? INDEXABLE_TRUE : INDEXABLE_FALSE;
|
||||
|
||||
export const toIndexablePresence = (value: boolean): IndexablePresence =>
|
||||
value ? INDEXABLE_TRUE : undefined;
|
||||
Reference in New Issue
Block a user