UNPKG

lazzy.ts

Version:

Fast and lightweight library for lazy operations with iterable objects.

25 lines 974 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getNumericSelector = exports.isIterable = exports.isPrimitive = exports.InvalidArgumentsMessage = void 0; exports.InvalidArgumentsMessage = "Invalid arguments."; function isPrimitive(value) { return ["string", "number", "boolean"].includes(typeof value); } exports.isPrimitive = isPrimitive; const isIterable = (it) => { const type = typeof it; return type === "string" || ((typeof it === "object" || typeof it === "function") && it != null && typeof Reflect.get(it, Symbol.iterator) === "function"); }; exports.isIterable = isIterable; function getNumericSelector(value, ...select) { if (typeof value === "number") { return (v) => v; } else if (select[0] !== undefined) { return select[0]; } throw new TypeError(exports.InvalidArgumentsMessage); } exports.getNumericSelector = getNumericSelector; //# sourceMappingURL=helpers.js.map