A set of common JavaScript predicates. The functions in this library either take one input and return true
/false
, or return a customized function that does so.
yarn add @shopify/predicates
isPositiveNumericString
Returnstrue
when its input is a positive numeric string andfalse
otherwise.isNumericString
Returnstrue
when its input is a numeric string andfalse
otherwise.isEmpty
Returnstrue
when its input isnull
,undefined
, or haslength
0.isEmptyString
Returnstrue
when it's input is an empty string or contains only whitespace.notEmpty
Returnstrue
when its input is notnull
,undefined
or haslength
0.notNumericString
Returnstrue
when its input is not a numeric string andfalse
otherwise.
lengthMoreThan
Given a number, returns a function that returns true when that input has length more than that number and false otherwise.lengthLessThan
Given a number, returns a function that returns true when that input has length less than that number and false otherwise.
not
Given a function that returns a boolean, returns a function that returns a boolean in the opposite cases.