Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace type

Index

Type aliases

Literal

Literal: Name<symbol> | Name<string> | Name<number> | Name<boolean> | Name<undefined> | Name<Function> | Name<object>

Primitive

Primitive: P

Functions

as

  • as<T>(instance: object, type: {}): 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: {}

    Returns T | null

asIterable

  • asIterable(instance: string): null
  • asIterable(instance: string, allowString: false): null
  • asIterable(instance: string, allowString: true): string
  • asIterable<T>(instance: Iterable<T> | ArrayLike<T>, allowString?: undefined | false | true): Iterable<T> | null
  • asIterable<T>(instance: unknown, allowString?: undefined | false | true): 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: undefined | false | true

    Returns Iterable<T> | null

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

    Type parameters

    • T

    Parameters

    • instance: unknown
    • Optional allowString: undefined | false | true

    Returns Iterable<T> | null

hasMember

  • hasMember<T, K>(instance: unknown, property: K, verify?: boolean): instance is {} & 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

    • K: PropertyKey

    Parameters

    • instance: unknown
    • property: K

      Name of the member.

    • Default value verify: boolean = false

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

    Returns instance is {} & T

hasMemberOfType

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

    Type parameters

    • T

    • K: PropertyKey

    Parameters

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

    Returns instance is {} & T

    & T}

  • Returns true if the member is a number.

    Type parameters

    • T

    • K: PropertyKey

    Parameters

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

    Returns instance is {} & T

    & T}

  • Returns true if the member is a boolean.

    Type parameters

    • T

    • K: PropertyKey

    Parameters

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

    Returns instance is {} & T

    & T}

  • Returns true if the member is a object.

    Type parameters

    • T

    • K: PropertyKey

    Parameters

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

    Returns instance is {} & T

    & T}

  • Returns true if the member is a Function.

    Type parameters

    • T

    • K: PropertyKey

    Parameters

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

    Returns instance is {} & T

    & T}

hasMethod

  • hasMethod<T, K>(instance: unknown, name: K): instance is {} & T
  • Tests to see if an object has a function of the specified name.

    Type parameters

    • T

    • K: PropertyKey

    Parameters

    • instance: unknown
    • name: K

    Returns instance is {} & T

    & T}

is

  • is<T>(instance: object, type: {}): instance is T
  • Returns true if the target matches the type (instanceof).

    Type parameters

    • T: object

    Parameters

    • instance: object
    • type: {}

    Returns instance is T

isArrayLike

  • 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

    Parameters

    • instance: unknown

    Returns instance is ArrayLikeWritable<T>

isBoolean

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

    Parameters

    • value: unknown

    Returns value is boolean

isFunction

  • 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

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

    Type parameters

    • T

    Parameters

    • instance: unknown

    Returns instance is Iterable<T>

isNullOrUndefined

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

    Parameters

    • value: unknown

    Returns value is null | undefined

isNumber

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

    Parameters

    • value: unknown
    • Default value ignoreNaN: boolean = false

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

    Returns value is number

isObject

  • isObject(value: unknown): value is object
  • isObject(value: unknown, allowNull: false): value is object
  • isObject(value: unknown, allowNull: boolean): value is object | null
  • 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 object | null

isPrimitive

  • isPrimitive(value: unknown): value is NullablePrimitive
  • isPrimitive(value: unknown, allowUndefined: false): value is NullablePrimitive
  • isPrimitive(value: unknown, allowUndefined: boolean): value is NullablePrimitive | undefined
  • 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

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

    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 NullablePrimitive | undefined

isPrimitiveOrSymbol

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

    Parameters

    • value: unknown

    Returns value is NullablePrimitive | symbol

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

    Parameters

    • value: unknown
    • allowUndefined: false

    Returns value is NullablePrimitive | symbol

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

    Parameters

    • value: unknown
    • allowUndefined: boolean

    Returns value is NullablePrimitive | symbol | undefined

isPropertyKey

  • 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

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

    Parameters

    • value: unknown

    Returns value is string

isTrueNaN

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

    Parameters

    • value: unknown

    Returns value is number

numberOrNaN

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

    Parameters

    • value: unknown

    Returns number

Generated using TypeDoc