UNPKG

pragmatic-fp-ts

Version:

Opinionated functional programming library with easy use in mind

22 lines (21 loc) 774 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.insertAll = void 0; const main_1 = require("./main"); function insertAll(position, values, coll) { if (arguments.length === 1) { return function (values, theColl) { return arguments.length === 1 ? insertAll(position, values) : insertAll(position, values, theColl); }; } else if (arguments.length === 2) { return (theColl) => insertAll(position, values, theColl); } const arr = (0, main_1.getValueOr)([], coll); const prefix = arr.slice(0, position); const suffix = arr.slice(position); return [...prefix, ...(0, main_1.getValueOr)([], values), ...suffix]; } exports.insertAll = insertAll;