Function isTypedArray

  • Checks if the value is a TypedArray adding the correct type guard, that lodash lacks.

    Examples:

    // works on TypeScript if (isTypedArray(unknownValue)) { unknownValue.forEach((val, idx) => {}) unknownValue.copyWithin(0, 1, 2) }

    // TypeScript error: Property 'forEach' does not exist on type 'unknown'. if (_.isTypedArray(unknownValue)) typedArray.forEach((val, idx) => {})

    Parameters

    • val: unknown

    Returns val is TypedArray