Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

Literal: Name<symbol> | Name<string> | Name<number> | Name<boolean> | Name<undefined> | Name<Function> | Name<object>
Name<T>: T extends symbol ? "symbol" : T extends string ? "string" : T extends number ? "number" : T extends boolean ? "boolean" : T extends undefined ? "undefined" : T extends Function ? "function" : "object"

Type parameters

  • T

Primitive: P

Functions

  • as<T>(instance: object, type: new (...params: any[]) => T): T | null
  • Returns null if the target does not match the type (instanceof). Otherwise returns the target as the type.

    Type parameters

    • T

    Parameters

    • instance: object
    • type: new (...params: any[]) => T
        • new (...params: any[]): T
        • Parameters

          • Rest ...params: any[]

          Returns T

    Returns T | null

  • asIterable(instance: string): null
  • asIterable(instance: string, allowString: false): null
  • asIterable(instance: string, allowString: true): string
  • asIterable<T>(instance: Iterable<T> | ArrayLike<T>, allowString?: boolean): Iterable<T> | null
  • asIterable<T>(instance: unknown, allowString?: boolean): Iterable<T> | null
  • Ensures an object is iterable if possible. Returns null if unable to convert to iterable.

    Parameters

    • instance: string

    Returns null

  • Ensures an object is iterable if possible. Returns null if unable to convert to iterable.

    Parameters

    • instance: string
    • allowString: false

    Returns null

  • Ensures an object is iterable if possible. Returns null if unable to convert to iterable.

    Parameters

    • instance: string
    • allowString: true

    Returns string

  • Ensures an object is iterable if possible. Returns null if unable to convert to iterable.

    Type parameters

    • T

    Parameters

    • instance: Iterable<T> | ArrayLike<T>
    • Optional allowString: boolean

    Returns Iterable<T> | null

  • Ensures an object is iterable if possible. Returns null if unable to convert to iterable.

    Type parameters

    • T = unknown

    Parameters

    • instance: unknown
    • Optional allowString: boolean

    Returns Iterable<T> | null

  • hasMember<T, K>(instance: unknown, property: K, verify?: boolean): instance is { [ P in PropertyKey]: unknown } & T
  • Will detect if a member exists (using 'in'). Returns true if a property or method exists on the object or its prototype.

    Type parameters

    • T = unknown

    • K: PropertyKey = keyof T

    Parameters

    • instance: unknown
    • property: K

      Name of the member.

    • verify: boolean = false

      When true, if the member exists but is undefined, it will return false.

    Returns instance is { [ P in PropertyKey]: unknown } & T

  • hasMemberOfType<T, K>(instance: unknown, property: K, type: "string"): instance is { [ P in PropertyKey]: string } & T
  • hasMemberOfType<T, K>(instance: unknown, property: K, type: "number"): instance is { [ P in PropertyKey]: number } & T
  • hasMemberOfType<T, K>(instance: unknown, property: K, type: "boolean"): instance is { [ P in PropertyKey]: boolean } & T
  • hasMemberOfType<T, K>(instance: unknown, property: K, type: "object"): instance is { [ P in PropertyKey]: object } & T
  • hasMemberOfType<T, K>(instance: unknown, property: K, type: "function"): instance is { [ P in PropertyKey]: Function } & T
  • Returns true if the member is a string.

    Type parameters

    • T = unknown

    • K: PropertyKey = keyof T

    Parameters

    • instance: unknown
    • property: K
    • type: "string"

    Returns instance is { [ P in PropertyKey]: string } & T

    & T}

  • Returns true if the member is a number.

    Type parameters

    • T = unknown

    • K: PropertyKey = keyof T

    Parameters

    • instance: unknown
    • property: K
    • type: "number"

    Returns instance is { [ P in PropertyKey]: number } & T

    & T}

  • Returns true if the member is a boolean.

    Type parameters

    • T = unknown

    • K: PropertyKey = keyof T

    Parameters

    • instance: unknown
    • property: K
    • type: "boolean"

    Returns instance is { [ P in PropertyKey]: boolean } & T

    & T}

  • Returns true if the member is a object.

    Type parameters

    • T = unknown

    • K: PropertyKey = keyof T

    Parameters

    • instance: unknown
    • property: K
    • type: "object"

    Returns instance is { [ P in PropertyKey]: object } & T

    & T}

  • Returns true if the member is a Function.

    Type parameters

    • T = unknown

    • K: PropertyKey = keyof T

    Parameters

    • instance: unknown
    • property: K
    • type: "function"

    Returns instance is { [ P in PropertyKey]: Function } & T

    & T}

  • hasMethod<T, K>(instance: unknown, name: K): instance is { [ P in PropertyKey]: (...params: any[]) => unknown } & T
  • Tests to see if an object has a function of the specified name.

    Type parameters

    • T = unknown

    • K: PropertyKey = keyof T

    Parameters

    • instance: unknown
    • name: K

    Returns instance is { [ P in PropertyKey]: (...params: any[]) => unknown } & T

    & T}

  • is<T>(instance: object, type: new (...params: any[]) => T): instance is T
  • Returns true if the target matches the type (instanceof).

    Type parameters

    • T: object

    Parameters

    • instance: object
    • type: new (...params: any[]) => T
        • new (...params: any[]): T
        • Parameters

          • Rest ...params: any[]

          Returns T

    Returns instance is T

  • isArrayLike<T>(instance: unknown): instance is ArrayLikeWritable<T>
  • Checks to see if object is an array or something with length property that isn't a function.

    Type parameters

    • T = unknown

    Parameters

    • instance: unknown

    Returns instance is ArrayLikeWritable<T>

  • isBoolean(value: unknown): value is boolean
  • Returns true if the value parameter is a boolean.

    Parameters

    • value: unknown

    Returns value is boolean

  • isFunction(value: unknown): value is (...params: any[]) => unknown
  • Returns true if the value parameter is a function.

    Parameters

    • value: unknown

    Returns value is (...params: any[]) => unknown

  • isIterable<T>(instance: unknown): instance is Iterable<T>
  • Checks to see if [Symbol.iterator] is a function.

    Type parameters

    • T = unknown

    Parameters

    • instance: unknown

    Returns instance is Iterable<T>

  • isNullOrUndefined(value: unknown): value is undefined | null
  • Returns true if the value parameter is null or undefined.

    Parameters

    • value: unknown

    Returns value is undefined | null

  • isNumber(value: unknown, ignoreNaN?: boolean): value is number
  • Returns true if the value parameter is a number.

    Parameters

    • value: unknown
    • ignoreNaN: boolean = false

      Default is false. When true, NaN is not considered a number and will return false.

    Returns value is number

  • isObject(value: unknown): value is object
  • isObject(value: unknown, allowNull: false): value is object
  • isObject(value: unknown, allowNull: boolean): value is null | object
  • Returns true if the value parameter is an object.

    Parameters

    • value: unknown

    Returns value is object

  • Returns true if the value parameter is an object.

    Parameters

    • value: unknown
    • allowNull: false

      If false (default) null is not considered an object.

    Returns value is object

  • Parameters

    • value: unknown
    • allowNull: boolean

    Returns value is null | object

  • isPrimitive(value: unknown): value is NullablePrimitive
  • isPrimitive(value: unknown, allowUndefined: false): value is NullablePrimitive
  • isPrimitive(value: unknown, allowUndefined: boolean): value is undefined | NullablePrimitive
  • Returns true if the value is a boolean, string, number, or null.

    Parameters

    • value: unknown

    Returns value is NullablePrimitive

  • Returns true if the value is a boolean, string, number, null, or undefined.

    Parameters

    • value: unknown
    • allowUndefined: false

    Returns value is NullablePrimitive

  • Returns true if the value is a boolean, string, number, null, or undefined.

    Parameters

    • value: unknown
    • allowUndefined: boolean

      if set to true will return true if the value is undefined.

    Returns value is undefined | NullablePrimitive

  • isPrimitiveOrSymbol(value: unknown): value is symbol | NullablePrimitive
  • isPrimitiveOrSymbol(value: unknown, allowUndefined: false): value is symbol | NullablePrimitive
  • isPrimitiveOrSymbol(value: unknown, allowUndefined: boolean): value is undefined | symbol | NullablePrimitive
  • For detecting if the value can be used as a key.

    Parameters

    • value: unknown

    Returns value is symbol | NullablePrimitive

  • For detecting if the value can be used as a key.

    Parameters

    • value: unknown
    • allowUndefined: false

    Returns value is symbol | NullablePrimitive

  • For detecting if the value can be used as a key.

    Parameters

    • value: unknown
    • allowUndefined: boolean

    Returns value is undefined | symbol | NullablePrimitive

  • isPropertyKey(value: unknown): value is PropertyKey
  • Returns true if the value is a string, number, or symbol.

    Parameters

    • value: unknown

    Returns value is PropertyKey

  • isString(value: unknown): value is string
  • Returns true if the value parameter is a string.

    Parameters

    • value: unknown

    Returns value is string

  • isTrueNaN(value: unknown): value is number
  • Returns true if is a number and is NaN.

    Parameters

    • value: unknown

    Returns value is number

  • numberOrNaN(value: unknown): number
  • Guarantees a number value or NaN instead.

    Parameters

    • value: unknown

    Returns number

Generated using TypeDoc