Improve IndexableBoolean
type
This commit is contained in:
parent
809e34b0f4
commit
c6904476f4
1 changed files with 7 additions and 2 deletions
|
@ -6,7 +6,12 @@
|
|||
// 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 = 1 | 0;
|
||||
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 ? 1 : 0;
|
||||
value ? INDEXABLE_TRUE : INDEXABLE_FALSE;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue