Options
All
  • Public
  • Public/Protected
  • All
Menu

Module castArray

Index

References

Functions Lang

References

Renames and re-exports castArray

Lang Functions

  • castArray<T>(array: T): T
  • Casts value as an array if it's not one.

    since

    5.0.0

    example
    castArray(1)
    // => [1]

    castArray({ 'a': 1 })
    // => [{ 'a': 1 }]

    castArray('abc')
    // => ['abc']

    castArray(null)
    // => [null]

    castArray(undefined)
    // => [undefined]

    castArray()
    // => []

    const array = [1, 2, 3]
    console.log(castArray(array) === array)
    // => true

    Type parameters

    • T: any[]

    Parameters

    • array: T

    Returns T

    Returns the cast array.