Skip to main content

@terascope/utils / booleans

booleans

Functions

isBoolean()

isBoolean(input): input is boolean

Returns true if the input is a boolean

Parameters

ParameterType
inputunknown

Returns

input is boolean

Source

packages/utils/src/booleans.ts:57


isBooleanLike()

isBooleanLike(input): boolean

Returns true if the input is like a boolean. Use toBoolean to convert it to one.

Parameters

ParameterType
inputunknown

Returns

boolean

Example

isBooleanLike(); // false
isBooleanLike(null); // true
isBooleanLike(0); // true
isBooleanLike('0'); // true
isBooleanLike('false'); // true
isBooleanLike('no'); // true

Source

packages/utils/src/booleans.ts:74


isFalsy()

isFalsy(input): boolean

Returns true if the value is a falsy like value

Parameters

ParameterType
inputunknown

Returns

boolean

Source

packages/utils/src/booleans.ts:48


isTruthy()

isTruthy(input): boolean

Returns true if the value is a truthy like value

Parameters

ParameterType
inputunknown

Returns

boolean

Source

packages/utils/src/booleans.ts:39


toBoolean()

toBoolean(input): boolean

Convert any input into a boolean, this will work with stringified boolean

Parameters

ParameterType
inputunknown

Returns

boolean

Example

toBoolean(1); // true
toBoolean(0); // false
toBoolean('1'); // true
toBoolean('0'); // false
toBoolean('yes'); // true
toBoolean('NO'); // false
toBoolean('true'); // true
toBoolean('FALSE'); // false

Source

packages/utils/src/booleans.ts:17


toBooleanOrThrow()

toBooleanOrThrow(input): boolean

Will throw if input is not booleanLike, converts input to a Boolean

Parameters

ParameterType
inputunknown

Returns

boolean

Source

packages/utils/src/booleans.ts:79