Skip to main content

@terascope/core-utils / booleans

booleans

Functions​

isBoolean()​

isBoolean(input): input is boolean

Defined in: packages/core-utils/src/booleans.ts:57

Returns true if the input is a boolean

Parameters​

ParameterType
inputunknown

Returns​

input is boolean


isBooleanLike()​

isBooleanLike(input): boolean

Defined in: packages/core-utils/src/booleans.ts:74

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

isFalsy()​

isFalsy(input): boolean

Defined in: packages/core-utils/src/booleans.ts:48

Returns true if the value is a falsy like value

Parameters​

ParameterType
inputunknown

Returns​

boolean


isTruthy()​

isTruthy(input): boolean

Defined in: packages/core-utils/src/booleans.ts:39

Returns true if the value is a truthy like value

Parameters​

ParameterType
inputunknown

Returns​

boolean


toBoolean()​

toBoolean(input): boolean

Defined in: packages/core-utils/src/booleans.ts:17

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

toBooleanOrThrow()​

toBooleanOrThrow(input): boolean

Defined in: packages/core-utils/src/booleans.ts:79

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

Parameters​

ParameterType
inputunknown

Returns​

boolean