Options
All
  • Public
  • Public/Protected
  • All
Menu

predicat - v1.1.2

Index

Type aliases

Predicate

Predicate<T>: (param: T) => boolean

Type parameters

  • T

Type declaration

    • (param: T): boolean
    • A statement that may be true or false depending on the values of its variable.

      Parameters

      • param: T

        (optional if T is void) The predicate's parameter

      Returns boolean

      A boolean result, making a statement about the given parameter.

Functions

Const allOf

Const always

  • always(param: void): boolean
  • A predicate that always verifies.

    Parameters

    • param: void

    Returns boolean

    true.

every

  • Combine predicates, verifying only if they all do.

    Type parameters

    • T

    Parameters

    • Rest ...predicates: (boolean | Predicate<T>)[]

    Returns Predicate<T>

    true if all given predicates also do, false otherwise.

isArray

  • isArray(subject: unknown): subject is any[]
  • Check if the subject is an Array (can be used as a type guard).

    Parameters

    • subject: unknown

      the variable to check.

    Returns subject is any[]

    true the given parameter is an Array, false otherwise.

isBoolean

  • isBoolean(subject: unknown): subject is boolean
  • Check if the subject is a boolean (can be used as a type guard).
    Will return false if the subject is a Boolean object.

    Parameters

    • subject: unknown

      the variable to check.

    Returns subject is boolean

    true the given parameter is a boolean, false otherwise.

Const isFalse

  • isFalse(param: any): boolean
  • A predicate that verifies if the subject is false.
    Will return false if the subject is new Boolean(false).

    Parameters

    • param: any

    Returns boolean

    true the subject is false, false otherwise.

Const isFalsy

  • isFalsy(param: any): boolean
  • A predicate that verifies if the subject is falsy.
    Will return false if the subject is new Boolean(false).

    Parameters

    • param: any

    Returns boolean

    true the subject is falsy, false otherwise.

isMap

  • isMap(subject: unknown): subject is Map<any, any>
  • Check if the subject is a Map (can be used as a type guard).

    Parameters

    • subject: unknown

      the variable to check.

    Returns subject is Map<any, any>

    true the given parameter is a Map, false otherwise.

isNill

  • isNill(subject: unknown): boolean
  • Check if the subject is undefined or null.

    Parameters

    • subject: unknown

      the variable to check.

    Returns boolean

    true the given parameter is undefined or null, false otherwise.

isNull

  • isNull(subject: unknown): subject is null
  • Check if the subject is null (can be used as a type guard).

    Parameters

    • subject: unknown

      the variable to check.

    Returns subject is null

    true the given parameter is null, false otherwise.

isNumber

  • isNumber(subject: unknown): subject is number
  • Check if the subject is a number (can be used as a type guard).
    Will return true if the subject is NaN.

    Parameters

    • subject: unknown

      the variable to check.

    Returns subject is number

    true the given parameter is a number, false otherwise.

isRegExp

  • isRegExp(subject: unknown): subject is RegExp
  • Check if the subject is a RegExp (can be used as a type guard).

    Parameters

    • subject: unknown

      the variable to check.

    Returns subject is RegExp

    true the given parameter is a RegExp, false otherwise.

isSet

  • isSet(subject: unknown): subject is Set<any>
  • Check if the subject is a Set (can be used as a type guard).

    Parameters

    • subject: unknown

      the variable to check.

    Returns subject is Set<any>

    true the given parameter is a Set, false otherwise.

isString

  • isString(subject: unknown): subject is string
  • Check if the subject is a string (can be used as a type guard).

    Parameters

    • subject: unknown

      the variable to check.

    Returns subject is string

    true the given parameter is a string, false otherwise.

Const isTrue

  • isTrue(param: any): boolean
  • A predicate that verifies if the subject is true.
    Will return false if the subject is new Boolean(true).

    Parameters

    • param: any

    Returns boolean

    true the subject is true, false otherwise.

Const isTruthy

  • isTruthy(param: any): boolean
  • A predicate that verifies if the subject is truthy.
    Will return true if the subject is new Boolean(false).

    Parameters

    • param: any

    Returns boolean

    true the subject is truthy, false otherwise.

isUndefined

  • isUndefined(subject: unknown): subject is undefined
  • Check if the subject is undefined (can be used as a type guard).

    Parameters

    • subject: unknown

      the variable to check.

    Returns subject is undefined

    true the given parameter is undefined, false otherwise.

Const never

  • never(param: void): boolean

Const nok

  • nok(param: void): boolean

Const not

  • not(param: any): boolean

Const ok

  • ok(param: void): boolean

Const oneOf

some

  • Combine predicates, verifying if one or more do.

    Type parameters

    • T

    Parameters

    • Rest ...predicates: (boolean | Predicate<T>)[]

    Returns Predicate<T>

    true if one or more given predicates also do, false otherwise.

Generated using TypeDoc