UNPKG

@monstermann/fn

Version:

A utility library for TypeScript.

25 lines (23 loc) 545 B
import { dfdlT } from "@monstermann/dfdl"; //#region src/function/isIterable.ts /** * `isIterable(value)` * * Checks if a value is iterable by testing for the presence of `Symbol.iterator`. * * ```ts * isIterable([1, 2, 3]); // true * isIterable("hello"); // true * isIterable(42); // false * ``` * * ```ts * pipe([1, 2, 3], isIterable()); // true * pipe(42, isIterable()); // false * ``` */ const isIterable = dfdlT((value) => { return value != null && typeof value[Symbol.iterator] === "function"; }, 1); //#endregion export { isIterable };