ixfx
    Preparing search index...

    Module @ixfx/guards - v0.42.0

    Functions

    arrayIndexTest

    Throws if index is an invalid array index for array, and if array itself is not a valid array.

    arrayStringsTest

    Returns true if parameter is an array of strings

    arrayTest

    Throws an error if parameter is not an array

    functionTest
    getErrorMessage
    ifNaN

    Returns fallback if v is NaN, otherwise returns v.

    integerArrayTest
    integerParse

    Parses value as an integer, returning it if it meets the range criteria. If not, defaultValue is returned.

    integerTest

    Checks if value an integer and meets additional criteria. See numberTest for guard details, or use that if integer checking is not required.

    isDefined
    isFunction
    isInteger

    Returns true if value is an integer in number or string form

    isPowerOfTwo

    Returns true if x is a power of two

    nullUndefTest
    numberDecimalTest

    Compares two numbers with a given number of decimal places

    numberInclusiveRangeTest
    numberTest

    Checks if t is not a number or within specified range. Returns [false, reason:string] if invalid or [true] if valid.

    percentTest

    Returns test of value being in the range of 0-1. Equiv to number(value, percentage);

    rangeIntegerTest
    rangeTest

    Inclusive range 4-6 = 4, 5, 6 Exclusive range 4-6 = 5

    resultErrorToString

    Returns the error as a string.

    resultFirstFail_

    Returns the first failed result, or undefined if there are no fails

    resultIsError

    Returns true if result is an error

    resultIsOk

    Returns true if result is OK and has a value

    resultsCollate

    Returns first failed result or final value.

    resultThrow

    If any of results is an error, throws it, otherwise ignored.

    resultThrowSingle
    resultToError

    Gets the result as an Error

    resultToValue

    Unwraps the result, returning its value if OK. If not, an exception is thrown.

    resultWithFail

    If result is an error, calls callback, passing the error. Otherwise does nothing

    stringTest

    Throws an error if parameter is not an string

    testPlainObject

    Tests_if value is a plain object

    testPlainObjectOrPrimitive

    Tests if value is primitive value (bigint,number,string or boolean) or plain object

    throwIfFailed

    Throws an error if any result is a failure. Error message will be the combined from all errors.

    Type Aliases

    ExpectedOpts
    NumberGuardRange
    Result
    ResultError
    ResultOk
    ResultOrFunction
    StringGuardRange