From c6904476f4ae7ec2e3a1bcfd38d3e7cc8f7b21f8 Mon Sep 17 00:00:00 2001 From: Daniel Gasienica Date: Sat, 14 Apr 2018 21:08:36 -0400 Subject: [PATCH] Improve `IndexableBoolean` type --- ts/types/IndexedDB.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ts/types/IndexedDB.ts b/ts/types/IndexedDB.ts index 43080c78b..150ad6431 100644 --- a/ts/types/IndexedDB.ts +++ b/ts/types/IndexedDB.ts @@ -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;