Library API
    Preparing search index...

    Function asArray

    • Coerces a value into an array. If the value is already an array-like or iterable, it is converted to an array. An optional fill value can be provided to map over the elements.

      Type Parameters

      • T

      Parameters

      • arr: ArrayLike<T> | undefined

        The value to coerce into an array

      Returns T[]

      An array containing the coerced values

      const arr = asArray('hello'); // ['hello']
      
    • Coerces a value into an array. If the value is already an array-like or iterable, it is converted to an array. An optional fill value can be provided to map over the elements.

      Type Parameters

      • T

      Parameters

      • arr: T | Iterable<T, any, any> | undefined

        The value to coerce into an array

      Returns NonNullable<T>[]

      An array containing the coerced values

      const arr = asArray('hello'); // ['hello']
      
    • Coerces a value into an array. If the value is already an array-like or iterable, it is converted to an array. An optional fill value can be provided to map over the elements.

      Type Parameters

      • T
      • K

      Parameters

      • arr: Iterable<T, any, any> | ArrayLike<T>

        The value to coerce into an array

      • fill: K

        Optional value to map over the elements

      Returns K[]

      An array containing the coerced values

      const arr = asArray('hello'); // ['hello']