Skip to main content
Module

x/rambda/dist/rambda.mjs

Faster and smaller alternative to Ramda
Go to Latest
File
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296
function F() { return false;}
function T() { return true;}
function add(a, b) { if (arguments.length === 1) return _b => add(a, _b); return Number(a) + Number(b);}
function curry(fn, args = []) { return (..._args) => (rest => rest.length >= fn.length ? fn(...rest) : curry(fn, rest))([...args, ..._args]);}
const cloneList = list => { return Array.prototype.slice.call(list);};
function adjustFn(index, replaceFn, list) { const actualIndex = index < 0 ? list.length + index : index; if (index >= list.length || actualIndex < 0) return list; const clone = cloneList(list); clone[actualIndex] = replaceFn(clone[actualIndex]); return clone;}
const adjust = curry(adjustFn);
function all(predicate, list) { if (arguments.length === 1) return _list => all(predicate, _list);
for (let i = 0; i < list.length; i++) { if (!predicate(list[i])) return false; }
return true;}
function allPass(predicates) { return (...input) => { let counter = 0;
while (counter < predicates.length) { if (!predicates[counter](...input)) { return false; }
counter++; }
return true; };}
function always(x) { return () => x;}
function and(a, b) { if (arguments.length === 1) return _b => and(a, _b); return a && b;}
function any(predicate, list) { if (arguments.length === 1) return _list => any(predicate, _list); let counter = 0;
while (counter < list.length) { if (predicate(list[counter], counter)) { return true; }
counter++; }
return false;}
function anyPass(predicates) { return (...input) => { let counter = 0;
while (counter < predicates.length) { if (predicates[counter](...input)) { return true; }
counter++; }
return false; };}
function append(x, input) { if (arguments.length === 1) return _input => append(x, _input); if (typeof input === 'string') return input.split('').concat(x); const clone = cloneList(input); clone.push(x); return clone;}
function apply(fn, args) { if (arguments.length === 1) { return _args => apply(fn, _args); }
return fn.apply(this, args);}
const _isArray = Array.isArray;
function __findHighestArity(spec, max = 0) { for (const key in spec) { if (spec.hasOwnProperty(key) === false || key === 'constructor') continue;
if (typeof spec[key] === 'object') { max = Math.max(max, __findHighestArity(spec[key])); }
if (typeof spec[key] === 'function') { max = Math.max(max, spec[key].length); } }
return max;}
function __filterUndefined() { const defined = []; let i = 0; const l = arguments.length;
while (i < l) { if (typeof arguments[i] === 'undefined') break; defined[i] = arguments[i]; i++; }
return defined;}
function __applySpecWithArity(spec, arity, cache) { const remaining = arity - cache.length; if (remaining === 1) return x => __applySpecWithArity(spec, arity, __filterUndefined(...cache, x)); if (remaining === 2) return (x, y) => __applySpecWithArity(spec, arity, __filterUndefined(...cache, x, y)); if (remaining === 3) return (x, y, z) => __applySpecWithArity(spec, arity, __filterUndefined(...cache, x, y, z)); if (remaining === 4) return (x, y, z, a) => __applySpecWithArity(spec, arity, __filterUndefined(...cache, x, y, z, a)); if (remaining > 4) return (...args) => __applySpecWithArity(spec, arity, __filterUndefined(...cache, ...args));
if (_isArray(spec)) { const ret = []; let i = 0; const l = spec.length;
for (; i < l; i++) { if (typeof spec[i] === 'object' || _isArray(spec[i])) { ret[i] = __applySpecWithArity(spec[i], arity, cache); }
if (typeof spec[i] === 'function') { ret[i] = spec[i](...cache); } }
return ret; }
const ret = {};
for (const key in spec) { if (spec.hasOwnProperty(key) === false || key === 'constructor') continue;
if (typeof spec[key] === 'object') { ret[key] = __applySpecWithArity(spec[key], arity, cache); continue; }
if (typeof spec[key] === 'function') { ret[key] = spec[key](...cache); } }
return ret;}
function applySpec(spec, ...args) { const arity = __findHighestArity(spec);
if (arity === 0) { return () => ({}); }
const toReturn = __applySpecWithArity(spec, arity, args);
return toReturn;}
function assocFn(prop, newValue, obj) { return Object.assign({}, obj, { [prop]: newValue });}
const assoc = curry(assocFn);
function _isInteger(n) { return n << 0 === n;}var _isInteger$1 = Number.isInteger || _isInteger;
function assocPathFn(path, newValue, input) { const pathArrValue = typeof path === 'string' ? path.split('.').map(x => _isInteger(Number(x)) ? Number(x) : x) : path;
if (pathArrValue.length === 0) { return newValue; }
const index = pathArrValue[0];
if (pathArrValue.length > 1) { const condition = typeof input !== 'object' || input === null || !input.hasOwnProperty(index); const nextinput = condition ? _isInteger(pathArrValue[1]) ? [] : {} : input[index]; newValue = assocPathFn(Array.prototype.slice.call(pathArrValue, 1), newValue, nextinput); }
if (_isInteger(index) && _isArray(input)) { const arr = cloneList(input); arr[index] = newValue; return arr; }
return assoc(index, newValue, input);}
const assocPath = curry(assocPathFn);
function _curryN(n, cache, fn) { return function () { let ci = 0; let ai = 0; const cl = cache.length; const al = arguments.length; const args = new Array(cl + al);
while (ci < cl) { args[ci] = cache[ci]; ci++; }
while (ai < al) { args[cl + ai] = arguments[ai]; ai++; }
const remaining = n - args.length; return args.length >= n ? fn.apply(this, args) : _arity(remaining, _curryN(n, args, fn)); };}
function _arity(n, fn) { switch (n) { case 0: return function () { return fn.apply(this, arguments); };
case 1: return function (_1) { return fn.apply(this, arguments); };
case 2: return function (_1, _2) { return fn.apply(this, arguments); };
case 3: return function (_1, _2, _3) { return fn.apply(this, arguments); };
case 4: return function (_1, _2, _3, _4) { return fn.apply(this, arguments); };
case 5: return function (_1, _2, _3, _4, _5) { return fn.apply(this, arguments); };
case 6: return function (_1, _2, _3, _4, _5, _6) { return fn.apply(this, arguments); };
case 7: return function (_1, _2, _3, _4, _5, _6, _7) { return fn.apply(this, arguments); };
case 8: return function (_1, _2, _3, _4, _5, _6, _7, _8) { return fn.apply(this, arguments); };
case 9: return function (_1, _2, _3, _4, _5, _6, _7, _8, _9) { return fn.apply(this, arguments); };
default: return function (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) { return fn.apply(this, arguments); }; }}
function curryN(n, fn) { if (arguments.length === 1) return _fn => curryN(n, _fn);
if (n > 10) { throw new Error('First argument to _arity must be a non-negative integer no greater than ten'); }
return _arity(n, _curryN(n, [], fn));}
function bind(fn, thisObj) { if (arguments.length === 1) { return _thisObj => bind(fn, _thisObj); }
return curryN(fn.length, (...args) => fn.apply(thisObj, args));}
function both(f, g) { if (arguments.length === 1) return _g => both(f, _g); return (...input) => f(...input) && g(...input);}
function chain(fn, list) { if (arguments.length === 1) { return _list => chain(fn, _list); }
return [].concat(...list.map(fn));}
function clampFn(min, max, input) { if (min > max) { throw new Error('min must not be greater than max in clamp(min, max, value)'); }
if (input >= min && input <= max) return input; if (input > max) return max; if (input < min) return min;}
const clamp = curry(clampFn);
function clone(input) { const out = _isArray(input) ? Array(input.length) : {}; if (input && input.getTime) return new Date(input.getTime());
for (const key in input) { const v = input[key]; out[key] = typeof v === 'object' && v !== null ? v.getTime ? new Date(v.getTime()) : clone(v) : v; }
return out;}
function complement(fn) { return (...input) => !fn(...input);}
function compose(...fns) { if (fns.length === 0) { throw new Error('compose requires at least one argument'); }
return function (...args) { const list = fns.slice();
if (list.length > 0) { const fn = list.pop(); let result = fn.apply(this, args);
while (list.length > 0) { result = list.pop()(result); }
return result; } };}
function concat(x, y) { if (arguments.length === 1) return _y => concat(x, _y); return typeof x === 'string' ? `${x}${y}` : [...x, ...y];}
function cond(conditions) { return input => { let done = false; let toReturn; conditions.forEach(([predicate, resultClosure]) => { if (!done && predicate(input)) { done = true; toReturn = resultClosure(input); } }); return toReturn; };}
const _keys = Object.keys;
function mapArray(fn, list, isIndexed = false) { let index = 0; const willReturn = Array(list.length);
while (index < list.length) { willReturn[index] = isIndexed ? fn(list[index], index) : fn(list[index]); index++; }
return willReturn;}function mapObject(fn, obj) { let index = 0;
const keys = _keys(obj);
const len = keys.length; const willReturn = {};
while (index < len) { const key = keys[index]; willReturn[key] = fn(obj[key], key, obj); index++; }
return willReturn;}const mapObjIndexed = mapObject;function map(fn, iterable) { if (arguments.length === 1) return _iterable => map(fn, _iterable);
if (!iterable) { throw new Error('Incorrect iterable input'); }
if (_isArray(iterable)) return mapArray(fn, iterable); return mapObject(fn, iterable);}
function max(x, y) { if (arguments.length === 1) return _y => max(x, _y); return y > x ? y : x;}
function reduceFn(reducer, acc, list) { if (!_isArray(list)) { throw new TypeError('reduce: list must be array or iterable'); }
let index = 0; const len = list.length;
while (index < len) { acc = reducer(acc, list[index], index, list); index++; }
return acc;}
const reduce = curry(reduceFn);
function converge(fn, transformers) { if (arguments.length === 1) return _transformers => converge(fn, _transformers); const highestArity = reduce((a, b) => max(a, b.length), 0, transformers); return curryN(highestArity, function () { return fn.apply(this, map(g => g.apply(this, arguments), transformers)); });}
const dec = x => x - 1;
function isFalsy(input) { return input === undefined || input === null || Number.isNaN(input) === true;}
function defaultTo(defaultArgument, input) { if (arguments.length === 1) { return _input => defaultTo(defaultArgument, _input); }
return isFalsy(input) ? defaultArgument : input;}
function type(input) { if (input === null) { return 'Null'; } else if (input === undefined) { return 'Undefined'; } else if (Number.isNaN(input)) { return 'NaN'; }
const typeResult = Object.prototype.toString.call(input).slice(8, -1); return typeResult === 'AsyncFunction' ? 'Async' : typeResult;}
function _lastIndexOf(valueToFind, list) { if (!_isArray(list)) { throw new Error(`Cannot read property 'indexOf' of ${list}`); }
const typeOfValue = type(valueToFind); if (!['Object', 'Array', 'NaN', 'RegExp'].includes(typeOfValue)) return list.lastIndexOf(valueToFind); const { length } = list; let index = length; let foundIndex = -1;
while (--index > -1 && foundIndex === -1) { if (equals(list[index], valueToFind)) { foundIndex = index; } }
return foundIndex;}function _indexOf(valueToFind, list) { if (!_isArray(list)) { throw new Error(`Cannot read property 'indexOf' of ${list}`); }
const typeOfValue = type(valueToFind); if (!['Object', 'Array', 'NaN', 'RegExp'].includes(typeOfValue)) return list.indexOf(valueToFind); let index = -1; let foundIndex = -1; const { length } = list;
while (++index < length && foundIndex === -1) { if (equals(list[index], valueToFind)) { foundIndex = index; } }
return foundIndex;}
function _arrayFromIterator(iter) { const list = []; let next;
while (!(next = iter.next()).done) { list.push(next.value); }
return list;}
function _equalsSets(a, b) { if (a.size !== b.size) { return false; }
const aList = _arrayFromIterator(a.values());
const bList = _arrayFromIterator(b.values());
const filtered = aList.filter(aInstance => _indexOf(aInstance, bList) === -1); return filtered.length === 0;}
function parseError(maybeError) { const typeofError = maybeError.__proto__.toString();
if (!['Error', 'TypeError'].includes(typeofError)) return []; return [typeofError, maybeError.message];}
function parseDate(maybeDate) { if (!maybeDate.toDateString) return [false]; return [true, maybeDate.getTime()];}
function parseRegex(maybeRegex) { if (maybeRegex.constructor !== RegExp) return [false]; return [true, maybeRegex.toString()];}
function equals(a, b) { if (arguments.length === 1) return _b => equals(a, _b); const aType = type(a); if (aType !== type(b)) return false;
if (aType === 'Function') { return a.name === undefined ? false : a.name === b.name; }
if (['NaN', 'Undefined', 'Null'].includes(aType)) return true;
if (aType === 'Number') { if (Object.is(-0, a) !== Object.is(-0, b)) return false; return a.toString() === b.toString(); }
if (['String', 'Boolean'].includes(aType)) { return a.toString() === b.toString(); }
if (aType === 'Array') { const aClone = Array.from(a); const bClone = Array.from(b);
if (aClone.toString() !== bClone.toString()) { return false; }
let loopArrayFlag = true; aClone.forEach((aCloneInstance, aCloneIndex) => { if (loopArrayFlag) { if (aCloneInstance !== bClone[aCloneIndex] && !equals(aCloneInstance, bClone[aCloneIndex])) { loopArrayFlag = false; } } }); return loopArrayFlag; }
const aRegex = parseRegex(a); const bRegex = parseRegex(b);
if (aRegex[0]) { return bRegex[0] ? aRegex[1] === bRegex[1] : false; } else if (bRegex[0]) return false;
const aDate = parseDate(a); const bDate = parseDate(b);
if (aDate[0]) { return bDate[0] ? aDate[1] === bDate[1] : false; } else if (bDate[0]) return false;
const aError = parseError(a); const bError = parseError(b);
if (aError[0]) { return bError[0] ? aError[0] === bError[0] && aError[1] === bError[1] : false; }
if (aType === 'Set') { return _equalsSets(a, b); }
if (aType === 'Object') { const aKeys = Object.keys(a);
if (aKeys.length !== Object.keys(b).length) { return false; }
let loopObjectFlag = true; aKeys.forEach(aKeyInstance => { if (loopObjectFlag) { const aValue = a[aKeyInstance]; const bValue = b[aKeyInstance];
if (aValue !== bValue && !equals(aValue, bValue)) { loopObjectFlag = false; } } }); return loopObjectFlag; }
return false;}
function includes(valueToFind, iterable) { if (arguments.length === 1) return _iterable => includes(valueToFind, _iterable);
if (typeof iterable === 'string') { return iterable.includes(valueToFind); }
if (!iterable) { throw new TypeError(`Cannot read property \'indexOf\' of ${iterable}`); }
if (!_isArray(iterable)) return false; return _indexOf(valueToFind, iterable) > -1;}
class _Set { constructor() { this.set = new Set(); this.items = {}; }
checkUniqueness(item) { const type$1 = type(item);
if (['Null', 'Undefined', 'NaN'].includes(type$1)) { if (type$1 in this.items) { return false; }
this.items[type$1] = true; return true; }
if (!['Object', 'Array'].includes(type$1)) { const prevSize = this.set.size; this.set.add(item); return this.set.size !== prevSize; }
if (!(type$1 in this.items)) { this.items[type$1] = [item]; return true; }
if (_indexOf(item, this.items[type$1]) === -1) { this.items[type$1].push(item); return true; }
return false; }
}
function uniq(list) { const set = new _Set(); const willReturn = []; list.forEach(item => { if (set.checkUniqueness(item)) { willReturn.push(item); } }); return willReturn;}
function difference(a, b) { if (arguments.length === 1) return _b => difference(a, _b); return uniq(a).filter(aInstance => !includes(aInstance, b));}
function dissoc(prop, obj) { if (arguments.length === 1) return _obj => dissoc(prop, _obj); if (obj === null || obj === undefined) return {}; const willReturn = {};
for (const p in obj) { willReturn[p] = obj[p]; }
delete willReturn[prop]; return willReturn;}
function divide(a, b) { if (arguments.length === 1) return _b => divide(a, _b); return a / b;}
function drop(howManyToDrop, listOrString) { if (arguments.length === 1) return _list => drop(howManyToDrop, _list); return listOrString.slice(howManyToDrop > 0 ? howManyToDrop : 0);}
function dropLast(howManyToDrop, listOrString) { if (arguments.length === 1) { return _listOrString => dropLast(howManyToDrop, _listOrString); }
return howManyToDrop > 0 ? listOrString.slice(0, -howManyToDrop) : listOrString.slice();}
function dropLastWhile(predicate, iterable) { if (arguments.length === 1) { return _iterable => dropLastWhile(predicate, _iterable); }
if (iterable.length === 0) return iterable;
const isArray = _isArray(iterable);
if (typeof predicate !== 'function') { throw new Error(`'predicate' is from wrong type ${typeof predicate}`); }
if (!isArray && typeof iterable !== 'string') { throw new Error(`'iterable' is from wrong type ${typeof iterable}`); }
let found = false; const toReturn = []; let counter = iterable.length;
while (counter > 0) { counter--;
if (!found && predicate(iterable[counter]) === false) { found = true; toReturn.push(iterable[counter]); } else if (found) { toReturn.push(iterable[counter]); } }
return isArray ? toReturn.reverse() : toReturn.reverse().join('');}
function dropRepeats(list) { if (!_isArray(list)) { throw new Error(`${list} is not a list`); }
const toReturn = []; list.reduce((prev, current) => { if (!equals(prev, current)) { toReturn.push(current); }
return current; }, undefined); return toReturn;}
function dropRepeatsWith(predicate, list) { if (arguments.length === 1) { return _iterable => dropRepeatsWith(predicate, _iterable); }
if (!_isArray(list)) { throw new Error(`${list} is not a list`); }
const toReturn = []; list.reduce((prev, current) => { if (prev === undefined) { toReturn.push(current); return current; }
if (!predicate(prev, current)) { toReturn.push(current); }
return current; }, undefined); return toReturn;}
function dropWhile(predicate, iterable) { if (arguments.length === 1) { return _iterable => dropWhile(predicate, _iterable); }
const isArray = _isArray(iterable);
if (!isArray && typeof iterable !== 'string') { throw new Error('`iterable` is neither list nor a string'); }
let flag = false; const holder = []; let counter = -1;
while (counter++ < iterable.length - 1) { if (flag) { holder.push(iterable[counter]); } else if (!predicate(iterable[counter])) { if (!flag) flag = true; holder.push(iterable[counter]); } }
return isArray ? holder : holder.join('');}
function either(firstPredicate, secondPredicate) { if (arguments.length === 1) { return _secondPredicate => either(firstPredicate, _secondPredicate); }
return (...input) => Boolean(firstPredicate(...input) || secondPredicate(...input));}
function endsWith(target, iterable) { if (arguments.length === 1) return _iterable => endsWith(target, _iterable);
if (typeof iterable === 'string') { return iterable.endsWith(target); }
if (!_isArray(target)) return false; const diff = iterable.length - target.length; let correct = true; const filtered = target.filter((x, index) => { if (!correct) return false; const result = equals(x, iterable[index + diff]); if (!result) correct = false; return result; }); return filtered.length === target.length;}
function prop(propToFind, obj) { if (arguments.length === 1) return _obj => prop(propToFind, _obj); if (!obj) return undefined; return obj[propToFind];}
function eqPropsFn(property, objA, objB) { return equals(prop(property, objA), prop(property, objB));}
const eqProps = curry(eqPropsFn);
function evolveArray(rules, list) { return mapArray((x, i) => { if (type(rules[i]) === 'Function') { return rules[i](x); }
return x; }, list, true);}function evolveObject(rules, iterable) { return mapObject((x, prop) => { if (type(x) === 'Object') { const typeRule = type(rules[prop]);
if (typeRule === 'Function') { return rules[prop](x); }
if (typeRule === 'Object') { return evolve(rules[prop], x); }
return x; }
if (type(rules[prop]) === 'Function') { return rules[prop](x); }
return x; }, iterable);}function evolve(rules, iterable) { if (arguments.length === 1) { return _iterable => evolve(rules, _iterable); }
const rulesType = type(rules); const iterableType = type(iterable);
if (iterableType !== rulesType) { throw new Error('iterableType !== rulesType'); }
if (!['Object', 'Array'].includes(rulesType)) { throw new Error(`'iterable' and 'rules' are from wrong type ${rulesType}`); }
if (iterableType === 'Object') { return evolveObject(rules, iterable); }
return evolveArray(rules, iterable);}
function filterObject(predicate, obj) { const willReturn = {};
for (const prop in obj) { if (predicate(obj[prop], prop, obj)) { willReturn[prop] = obj[prop]; } }
return willReturn;}function filterArray(predicate, list, indexed = false) { let index = 0; const len = list.length; const willReturn = [];
while (index < len) { const predicateResult = indexed ? predicate(list[index], index) : predicate(list[index]);
if (predicateResult) { willReturn.push(list[index]); }
index++; }
return willReturn;}function filter(predicate, iterable) { if (arguments.length === 1) return _iterable => filter(predicate, _iterable);
if (!iterable) { throw new Error('Incorrect iterable input'); }
if (_isArray(iterable)) return filterArray(predicate, iterable, false); return filterObject(predicate, iterable);}
function find(predicate, list) { if (arguments.length === 1) return _list => find(predicate, _list); let index = 0; const len = list.length;
while (index < len) { const x = list[index];
if (predicate(x)) { return x; }
index++; }}
function findIndex(predicate, list) { if (arguments.length === 1) return _list => findIndex(predicate, _list); const len = list.length; let index = -1;
while (++index < len) { if (predicate(list[index])) { return index; } }
return -1;}
function findLast(predicate, list) { if (arguments.length === 1) return _list => findLast(predicate, _list); let index = list.length;
while (--index >= 0) { if (predicate(list[index])) { return list[index]; } }
return undefined;}
function findLastIndex(fn, list) { if (arguments.length === 1) return _list => findLastIndex(fn, _list); let index = list.length;
while (--index >= 0) { if (fn(list[index])) { return index; } }
return -1;}
function flatten(list, input) { const willReturn = input === undefined ? [] : input;
for (let i = 0; i < list.length; i++) { if (_isArray(list[i])) { flatten(list[i], willReturn); } else { willReturn.push(list[i]); } }
return willReturn;}
function flipFn(fn) { return (...input) => { if (input.length === 1) { return holder => fn(holder, input[0]); } else if (input.length === 2) { return fn(input[1], input[0]); } else if (input.length === 3) { return fn(input[1], input[0], input[2]); } else if (input.length === 4) { return fn(input[1], input[0], input[2], input[3]); }
throw new Error("R.flip doesn't work with arity > 4"); };}
function flip(fn) { return flipFn(fn);}
function forEach(fn, list) { if (arguments.length === 1) return _list => forEach(fn, _list);
if (list === undefined) { return; }
if (_isArray(list)) { let index = 0; const len = list.length;
while (index < len) { fn(list[index]); index++; } } else { let index = 0;
const keys = _keys(list);
const len = keys.length;
while (index < len) { const key = keys[index]; fn(list[key], key, list); index++; } }
return list;}
function fromPairs(listOfPairs) { const toReturn = {}; listOfPairs.forEach(([prop, value]) => toReturn[prop] = value); return toReturn;}
function groupBy(groupFn, list) { if (arguments.length === 1) return _list => groupBy(groupFn, _list); const result = {};
for (let i = 0; i < list.length; i++) { const item = list[i]; const key = groupFn(item);
if (!result[key]) { result[key] = []; }
result[key].push(item); }
return result;}
function groupWith(compareFn, list) { if (!_isArray(list)) throw new TypeError('list.reduce is not a function'); const clone = cloneList(list); if (list.length === 1) return [clone]; const toReturn = []; let holder = []; clone.reduce((prev, current, i) => { if (i === 0) return current; const okCompare = compareFn(prev, current); const holderIsEmpty = holder.length === 0; const lastCall = i === list.length - 1;
if (okCompare) { if (holderIsEmpty) holder.push(prev); holder.push(current); if (lastCall) toReturn.push(holder); return current; }
if (holderIsEmpty) { toReturn.push([prev]); if (lastCall) toReturn.push([current]); return current; }
toReturn.push(holder); if (lastCall) toReturn.push([current]); holder = []; return current; }, undefined); return toReturn;}
function has(prop, obj) { if (arguments.length === 1) return _obj => has(prop, _obj); if (!obj) return false; return obj.hasOwnProperty(prop);}
function path(pathInput, obj) { if (arguments.length === 1) return _obj => path(pathInput, _obj);
if (obj === null || obj === undefined) { return undefined; }
let willReturn = obj; let counter = 0; const pathArrValue = typeof pathInput === 'string' ? pathInput.split('.') : pathInput;
while (counter < pathArrValue.length) { if (willReturn === null || willReturn === undefined) { return undefined; }
if (willReturn[pathArrValue[counter]] === null) return undefined; willReturn = willReturn[pathArrValue[counter]]; counter++; }
return willReturn;}
function hasPath(pathInput, obj) { if (arguments.length === 1) { return objHolder => hasPath(pathInput, objHolder); }
return path(pathInput, obj) !== undefined;}
function head(listOrString) { if (typeof listOrString === 'string') return listOrString[0] || ''; return listOrString[0];}
function _objectIs(a, b) { if (a === b) { return a !== 0 || 1 / a === 1 / b; }
return a !== a && b !== b;}var _objectIs$1 = Object.is || _objectIs;
function identical(a, b) { if (arguments.length === 1) return _b => identical(a, _b); return _objectIs$1(a, b);}
function identity(x) { return x;}
function ifElseFn(condition, onTrue, onFalse) { return (...input) => { const conditionResult = typeof condition === 'boolean' ? condition : condition(...input);
if (conditionResult === true) { return onTrue(...input); }
return onFalse(...input); };}
const ifElse = curry(ifElseFn);
const inc = x => x + 1;
function indexByPath(pathInput, list) { const toReturn = {};
for (let i = 0; i < list.length; i++) { const item = list[i]; toReturn[path(pathInput, item)] = item; }
return toReturn;}
function indexBy(condition, list) { if (arguments.length === 1) { return _list => indexBy(condition, _list); }
if (typeof condition === 'string') { return indexByPath(condition, list); }
const toReturn = {};
for (let i = 0; i < list.length; i++) { const item = list[i]; toReturn[condition(item)] = item; }
return toReturn;}
function indexOf(valueToFind, list) { if (arguments.length === 1) { return _list => _indexOf(valueToFind, _list); }
return _indexOf(valueToFind, list);}
function baseSlice(array, start, end) { let index = -1; let { length } = array; end = end > length ? length : end;
if (end < 0) { end += length; }
length = start > end ? 0 : end - start >>> 0; start >>>= 0; const result = Array(length);
while (++index < length) { result[index] = array[index + start]; }
return result;}
function init(listOrString) { if (typeof listOrString === 'string') return listOrString.slice(0, -1); return listOrString.length ? baseSlice(listOrString, 0, -1) : [];}
function intersection(listA, listB) { if (arguments.length === 1) return _list => intersection(listA, _list); return filter(x => includes(x, listA), listB);}
function intersperse(separator, list) { if (arguments.length === 1) return _list => intersperse(separator, _list); let index = -1; const len = list.length; const willReturn = [];
while (++index < len) { if (index === len - 1) { willReturn.push(list[index]); } else { willReturn.push(list[index], separator); } }
return willReturn;}
function is(targetPrototype, x) { if (arguments.length === 1) return _x => is(targetPrototype, _x); return x != null && x.constructor === targetPrototype || x instanceof targetPrototype;}
function isEmpty(input) { const inputType = type(input); if (['Undefined', 'NaN', 'Number', 'Null'].includes(inputType)) return false; if (!input) return true;
if (inputType === 'Object') { return Object.keys(input).length === 0; }
if (inputType === 'Array') { return input.length === 0; }
return false;}
function isNil(x) { return x === undefined || x === null;}
function join(glue, list) { if (arguments.length === 1) return _list => join(glue, _list); return list.join(glue);}
function keys(x) { return Object.keys(x);}
function last(listOrString) { if (typeof listOrString === 'string') { return listOrString[listOrString.length - 1] || ''; }
return listOrString[listOrString.length - 1];}
function lastIndexOf(valueToFind, list) { if (arguments.length === 1) { return _list => _lastIndexOf(valueToFind, _list); }
return _lastIndexOf(valueToFind, list);}
function length(x) { if (_isArray(x)) return x.length; if (typeof x === 'string') return x.length; return NaN;}
function lens(getter, setter) { return function (functor) { return function (target) { return functor(getter(target)).map(focus => setter(focus, target)); }; };}
function nth(index, list) { if (arguments.length === 1) return _list => nth(index, _list); const idx = index < 0 ? list.length + index : index; return Object.prototype.toString.call(list) === '[object String]' ? list.charAt(idx) : list[idx];}
function updateFn(index, newValue, list) { const clone = cloneList(list); if (index === -1) return clone.fill(newValue, index); return clone.fill(newValue, index, index + 1);}
const update = curry(updateFn);
function lensIndex(index) { return lens(nth(index), update(index));}
function lensPath(key) { return lens(path(key), assocPath(key));}
function lensProp(key) { return lens(prop(key), assoc(key));}
function match(pattern, input) { if (arguments.length === 1) return _input => match(pattern, _input); const willReturn = input.match(pattern); return willReturn === null ? [] : willReturn;}
function mathMod(x, y) { if (arguments.length === 1) return _y => mathMod(x, _y); if (!_isInteger$1(x) || !_isInteger$1(y) || y < 1) return NaN; return (x % y + y) % y;}
function maxByFn(compareFn, x, y) { return compareFn(y) > compareFn(x) ? y : x;}const maxBy = curry(maxByFn);
function sum(list) { return list.reduce((prev, current) => prev + current, 0);}
function mean(list) { return sum(list) / list.length;}
function median(list) { const len = list.length; if (len === 0) return NaN; const width = 2 - len % 2; const idx = (len - width) / 2; return mean(Array.prototype.slice.call(list, 0).sort((a, b) => { if (a === b) return 0; return a < b ? -1 : 1; }).slice(idx, idx + width));}
function merge(target, newProps) { if (arguments.length === 1) return _newProps => merge(target, _newProps); return Object.assign({}, target || {}, newProps || {});}
function mergeAll(arr) { let willReturn = {}; map(val => { willReturn = merge(willReturn, val); }, arr); return willReturn;}
function mergeDeepRight(target, source) { if (arguments.length === 1) { return sourceHolder => mergeDeepRight(target, sourceHolder); }
const willReturn = JSON.parse(JSON.stringify(target)); Object.keys(source).forEach(key => { if (type(source[key]) === 'Object') { if (type(target[key]) === 'Object') { willReturn[key] = mergeDeepRight(target[key], source[key]); } else { willReturn[key] = source[key]; } } else { willReturn[key] = source[key]; } }); return willReturn;}
function mergeLeft(x, y) { if (arguments.length === 1) return _y => mergeLeft(x, _y); return merge(y, x);}
function min(x, y) { if (arguments.length === 1) return _y => min(x, _y); return y < x ? y : x;}
function minByFn(compareFn, x, y) { return compareFn(y) < compareFn(x) ? y : x;}const minBy = curry(minByFn);
function modulo(x, y) { if (arguments.length === 1) return _y => modulo(x, _y); return x % y;}
function moveFn(fromIndex, toIndex, list) { if (fromIndex < 0 || toIndex < 0) { throw new Error('Rambda.move does not support negative indexes'); }
if (fromIndex > list.length - 1 || toIndex > list.length - 1) return list; const clone = cloneList(list); clone[fromIndex] = list[toIndex]; clone[toIndex] = list[fromIndex]; return clone;}
const move = curry(moveFn);
function multiply(x, y) { if (arguments.length === 1) return _y => multiply(x, _y); return x * y;}
function negate(x) { return -x;}
function none(predicate, list) { if (arguments.length === 1) return _list => none(predicate, _list);
for (let i = 0; i < list.length; i++) { if (!predicate(list[i])) return true; }
return false;}
function not(input) { return !input;}
function objOf(key, value) { if (arguments.length === 1) { return _value => objOf(key, _value); }
return { [key]: value };}
function of(value) { return [value];}
function omit(propsToOmit, obj) { if (arguments.length === 1) return _obj => omit(propsToOmit, _obj);
if (obj === null || obj === undefined) { return undefined; }
const propsToOmitValue = typeof propsToOmit === 'string' ? propsToOmit.split(',') : propsToOmit; const willReturn = {};
for (const key in obj) { if (!propsToOmitValue.includes(key)) { willReturn[key] = obj[key]; } }
return willReturn;}
function onceFn(fn, context) { let result; return function () { if (fn) { result = fn.apply(context || this, arguments); fn = null; }
return result; };}
function once(fn, context) { if (arguments.length === 1) { const wrap = onceFn(fn, context); return curry(wrap); }
return onceFn(fn, context);}
function or(a, b) { if (arguments.length === 1) return _b => or(a, _b); return a || b;}
const Identity = x => ({ x, map: fn => Identity(fn(x))});
function overFn(lens, fn, object) { return lens(x => Identity(fn(x)))(object).x;}
const over = curry(overFn);
function partial(fn, ...args) { const len = fn.length; return (...rest) => { if (args.length + rest.length >= len) { return fn(...args, ...rest); }
return partial(fn, ...[...args, ...rest]); };}
function partitionObject(predicate, iterable) { const yes = {}; const no = {}; Object.entries(iterable).forEach(([prop, value]) => { if (predicate(value, prop)) { yes[prop] = value; } else { no[prop] = value; } }); return [yes, no];}function partitionArray(predicate, list, indexed = false) { const yes = []; const no = []; let counter = -1;
while (counter++ < list.length - 1) { if (indexed ? predicate(list[counter], counter) : predicate(list[counter])) { yes.push(list[counter]); } else { no.push(list[counter]); } }
return [yes, no];}function partition(predicate, iterable) { if (arguments.length === 1) { return listHolder => partition(predicate, listHolder); }
if (!_isArray(iterable)) return partitionObject(predicate, iterable); return partitionArray(predicate, iterable);}
function pathEqFn(pathToSearch, target, input) { return equals(path(pathToSearch, input), target);}
const pathEq = curry(pathEqFn);
function pathOrFn(defaultValue, pathInput, obj) { return defaultTo(defaultValue, path(pathInput, obj));}
const pathOr = curry(pathOrFn);
function paths(pathsToSearch, obj) { if (arguments.length === 1) { return _obj => paths(pathsToSearch, _obj); }
return pathsToSearch.map(singlePath => path(singlePath, obj));}
function pick(propsToPick, input) { if (arguments.length === 1) return _input => pick(propsToPick, _input);
if (input === null || input === undefined) { return undefined; }
const keys = typeof propsToPick === 'string' ? propsToPick.split(',') : propsToPick; const willReturn = {}; let counter = 0;
while (counter < keys.length) { if (keys[counter] in input) { willReturn[keys[counter]] = input[keys[counter]]; }
counter++; }
return willReturn;}
function pickAll(propsToPick, obj) { if (arguments.length === 1) return _obj => pickAll(propsToPick, _obj);
if (obj === null || obj === undefined) { return undefined; }
const keysValue = typeof propsToPick === 'string' ? propsToPick.split(',') : propsToPick; const willReturn = {}; let counter = 0;
while (counter < keysValue.length) { if (keysValue[counter] in obj) { willReturn[keysValue[counter]] = obj[keysValue[counter]]; } else { willReturn[keysValue[counter]] = undefined; }
counter++; }
return willReturn;}
function pipe(...fns) { if (fns.length === 0) throw new Error('pipe requires at least one argument'); return (...args) => { const list = fns.slice();
if (list.length > 0) { const fn = list.shift(); let result = fn(...args);
while (list.length > 0) { result = list.shift()(result); }
return result; } };}
function pluck(property, list) { if (arguments.length === 1) return _list => pluck(property, _list); const willReturn = []; map(x => { if (x[property] !== undefined) { willReturn.push(x[property]); } }, list); return willReturn;}
function prepend(x, input) { if (arguments.length === 1) return _input => prepend(x, _input); if (typeof input === 'string') return [x].concat(input.split('')); return [x].concat(input);}
const product = reduce(multiply, 1);
function propEqFn(propToFind, valueToMatch, obj) { if (!obj) return false; return obj[propToFind] === valueToMatch;}
const propEq = curry(propEqFn);
function propIsFn(targetPrototype, property, obj) { return is(targetPrototype, obj[property]);}
const propIs = curry(propIsFn);
function propOrFn(defaultValue, property, obj) { if (!obj) return defaultValue; return defaultTo(defaultValue, obj[property]);}
const propOr = curry(propOrFn);
function props(propsToPick, obj) { if (arguments.length === 1) { return _obj => props(propsToPick, _obj); }
if (!_isArray(propsToPick)) { throw new Error('propsToPick is not a list'); }
return mapArray(prop => obj[prop], propsToPick);}
function range(start, end) { if (arguments.length === 1) return _end => range(start, _end);
if (Number.isNaN(Number(start)) || Number.isNaN(Number(end))) { throw new TypeError('Both arguments to range must be numbers'); }
if (end < start) return []; const len = end - start; const willReturn = Array(len);
for (let i = 0; i < len; i++) { willReturn[i] = start + i; }
return willReturn;}
function reject(predicate, list) { if (arguments.length === 1) return _list => reject(predicate, _list); return filter(x => !predicate(x), list);}
function repeat(x, timesToRepeat) { if (arguments.length === 1) { return _timesToRepeat => repeat(x, _timesToRepeat); }
return Array(timesToRepeat).fill(x);}
function replaceFn(pattern, replacer, str) { return str.replace(pattern, replacer);}
const replace = curry(replaceFn);
function reverse(listOrString) { if (typeof listOrString === 'string') { return listOrString.split('').reverse().join(''); }
const clone = listOrString.slice(); return clone.reverse();}
function setFn(lens, replacer, x) { return over(lens, always(replacer), x);}
const set = curry(setFn);
function sliceFn(from, to, list) { return list.slice(from, to);}
const slice = curry(sliceFn);
function sort(sortFn, list) { if (arguments.length === 1) return _list => sort(sortFn, _list); return cloneList(list).sort(sortFn);}
function sortBy(sortFn, list) { if (arguments.length === 1) return _list => sortBy(sortFn, _list); const clone = cloneList(list); return clone.sort((a, b) => { const aSortResult = sortFn(a); const bSortResult = sortFn(b); if (aSortResult === bSortResult) return 0; return aSortResult < bSortResult ? -1 : 1; });}
function split(separator, str) { if (arguments.length === 1) return _str => split(separator, _str); return str.split(separator);}
function maybe(ifRule, whenIf, whenElse) { const whenIfInput = ifRule && type(whenIf) === 'Function' ? whenIf() : whenIf; const whenElseInput = !ifRule && type(whenElse) === 'Function' ? whenElse() : whenElse; return ifRule ? whenIfInput : whenElseInput;}
function take(howMany, listOrString) { if (arguments.length === 1) return _listOrString => take(howMany, _listOrString); if (howMany < 0) return listOrString.slice(); if (typeof listOrString === 'string') return listOrString.slice(0, howMany); return baseSlice(listOrString, 0, howMany);}
function splitAt(index, input) { if (arguments.length === 1) { return _list => splitAt(index, _list); }
if (!input) throw new TypeError(`Cannot read property 'slice' of ${input}`); if (!_isArray(input) && typeof input !== 'string') return [[], []]; const correctIndex = maybe(index < 0, input.length + index < 0 ? 0 : input.length + index, index); return [take(correctIndex, input), drop(correctIndex, input)];}
function splitEvery(sliceLength, listOrString) { if (arguments.length === 1) { return _listOrString => splitEvery(sliceLength, _listOrString); }
if (sliceLength < 1) { throw new Error('First argument to splitEvery must be a positive integer'); }
const willReturn = []; let counter = 0;
while (counter < listOrString.length) { willReturn.push(listOrString.slice(counter, counter += sliceLength)); }
return willReturn;}
function splitWhen(predicate, input) { if (arguments.length === 1) { return _input => splitWhen(predicate, _input); }
if (!input) throw new TypeError(`Cannot read property 'length' of ${input}`); const preFound = []; const postFound = []; let found = false; let counter = -1;
while (counter++ < input.length - 1) { if (found) { postFound.push(input[counter]); } else if (predicate(input[counter])) { postFound.push(input[counter]); found = true; } else { preFound.push(input[counter]); } }
return [preFound, postFound];}
function startsWith(target, iterable) { if (arguments.length === 1) return _iterable => startsWith(target, _iterable);
if (typeof iterable === 'string') { return iterable.startsWith(target); }
if (!_isArray(target)) return false; let correct = true; const filtered = target.filter((x, index) => { if (!correct) return false; const result = equals(x, iterable[index]); if (!result) correct = false; return result; }); return filtered.length === target.length;}
function subtract(a, b) { if (arguments.length === 1) return _b => subtract(a, _b); return a - b;}
function symmetricDifference(x, y) { if (arguments.length === 1) { return _y => symmetricDifference(x, _y); }
return concat(filter(value => !includes(value, y), x), filter(value => !includes(value, x), y));}
function tail(listOrString) { return drop(1, listOrString);}
function takeLast(howMany, listOrString) { if (arguments.length === 1) return _listOrString => takeLast(howMany, _listOrString); const len = listOrString.length; if (howMany < 0) return listOrString.slice(); let numValue = howMany > len ? len : howMany; if (typeof listOrString === 'string') return listOrString.slice(len - numValue); numValue = len - numValue; return baseSlice(listOrString, numValue, len);}
function takeLastWhile(predicate, input) { if (arguments.length === 1) { return _input => takeLastWhile(predicate, _input); }
if (input.length === 0) return input; let found = false; const toReturn = []; let counter = input.length;
while (!found || counter === 0) { counter--;
if (predicate(input[counter]) === false) { found = true; } else if (!found) { toReturn.push(input[counter]); } }
return _isArray(input) ? toReturn.reverse() : toReturn.reverse().join('');}
function takeWhile(predicate, iterable) { if (arguments.length === 1) { return _iterable => takeWhile(predicate, _iterable); }
const isArray = _isArray(iterable);
if (!isArray && typeof iterable !== 'string') { throw new Error('`iterable` is neither list nor a string'); }
let flag = true; const holder = []; let counter = -1;
while (counter++ < iterable.length - 1) { if (!predicate(iterable[counter])) { if (flag) flag = false; } else if (flag) { holder.push(iterable[counter]); } } return isArray ? holder : holder.join('');}
function tap(fn, x) { if (arguments.length === 1) return _x => tap(fn, _x); fn(x); return x;}
function test(pattern, str) { if (arguments.length === 1) return _str => test(pattern, _str);
if (typeof pattern === 'string') { throw new TypeError(`‘test’ requires a value of type RegExp as its first argument; received "${pattern}"`); }
return str.search(pattern) !== -1;}
function times(fn, howMany) { if (arguments.length === 1) return _howMany => times(fn, _howMany);
if (!Number.isInteger(howMany) || howMany < 0) { throw new RangeError('n must be an integer'); }
return map(fn, range(0, howMany));}
function toLower(str) { return str.toLowerCase();}
function toPairs(obj) { return Object.entries(obj);}
function toString(x) { return x.toString();}
function toUpper(str) { return str.toUpperCase();}
function transpose(array) { return array.reduce((acc, el) => { el.forEach((nestedEl, i) => _isArray(acc[i]) ? acc[i].push(nestedEl) : acc.push([nestedEl])); return acc; }, []);}
function trim(str) { return str.trim();}
function isFunction(fn) { return ['Async', 'Function'].includes(type(fn));}
function tryCatch(fn, fallback) { if (!isFunction(fn)) { throw new Error(`R.tryCatch | fn '${fn}'`); }
const passFallback = isFunction(fallback); return (...inputs) => { try { return fn(...inputs); } catch (e) { return passFallback ? fallback(e, ...inputs) : fallback; } };}
function unapply(fn) { return function (...args) { return fn.call(this, args); };}
function union(x, y) { if (arguments.length === 1) return _y => union(x, _y); const toReturn = cloneList(x); y.forEach(yInstance => { if (!includes(yInstance, x)) toReturn.push(yInstance); }); return toReturn;}
function includesWith(predicate, target, list) { let willReturn = false; let index = -1;
while (++index < list.length && !willReturn) { const value = list[index];
if (predicate(target, value)) { willReturn = true; } }
return willReturn;}
function uniqWith(predicate, list) { if (arguments.length === 1) return _list => uniqWith(predicate, _list); let index = -1; const willReturn = [];
while (++index < list.length) { const value = list[index];
if (!includesWith(predicate, value, willReturn)) { willReturn.push(value); } }
return willReturn;}
function unless(predicate, whenFalse) { if (arguments.length === 1) { return _whenFalse => unless(predicate, _whenFalse); }
return input => predicate(input) ? input : whenFalse(input);}
function values(obj) { if (type(obj) !== 'Object') return []; return Object.values(obj);}
const Const = x => ({ x, map: fn => Const(x)});
function view(lens, target) { if (arguments.length === 1) return _target => view(lens, _target); return lens(Const)(target).x;}
function whenFn(predicate, whenTrueFn, input) { if (!predicate(input)) return input; return whenTrueFn(input);}
const when = curry(whenFn);
function where(conditions, input) { if (input === undefined) { return _input => where(conditions, _input); }
let flag = true;
for (const prop in conditions) { const result = conditions[prop](input[prop]);
if (flag && result === false) { flag = false; } }
return flag;}
function whereEq(condition, input) { if (arguments.length === 1) { return _input => whereEq(condition, _input); }
const result = filter((conditionValue, conditionProp) => equals(conditionValue, input[conditionProp]), condition); return Object.keys(result).length === Object.keys(condition).length;}
function without(matchAgainst, source) { if (source === undefined) { return _source => without(matchAgainst, _source); }
return reduce((prev, current) => _indexOf(current, matchAgainst) > -1 ? prev : prev.concat(current), [], source);}
function xor(a, b) { if (arguments.length === 1) return _b => xor(a, _b); return Boolean(a) && !b || Boolean(b) && !a;}
function zip(left, right) { if (arguments.length === 1) return _right => zip(left, _right); const result = []; const length = Math.min(left.length, right.length);
for (let i = 0; i < length; i++) { result[i] = [left[i], right[i]]; }
return result;}
function zipObj(keys, values) { if (arguments.length === 1) return yHolder => zipObj(keys, yHolder); return take(values.length, keys).reduce((prev, xInstance, i) => { prev[xInstance] = values[i]; return prev; }, {});}
function zipWithFn(fn, x, y) { return take(x.length > y.length ? y.length : x.length, x).map((xInstance, i) => fn(xInstance, y[i]));}
const zipWith = curry(zipWithFn);
export { F, T, _indexOf, _lastIndexOf, add, adjust, all, allPass, always, and, any, anyPass, append, apply, applySpec, assoc, assocPath, bind, both, chain, clamp, clone, complement, compose, concat, cond, converge, curry, curryN, dec, defaultTo, difference, dissoc, divide, drop, dropLast, dropLastWhile, dropRepeats, dropRepeatsWith, dropWhile, either, endsWith, eqProps, equals, evolve, evolveArray, evolveObject, filter, filterArray, filterObject, find, findIndex, findLast, findLastIndex, flatten, flip, forEach, fromPairs, groupBy, groupWith, has, hasPath, head, identical, identity, ifElse, inc, includes, indexBy, indexOf, init, intersection, intersperse, is, isEmpty, isNil, join, keys, last, lastIndexOf, length, lens, lensIndex, lensPath, lensProp, map, mapArray, mapObjIndexed, mapObject, match, mathMod, max, maxBy, maxByFn, mean, median, merge, mergeAll, mergeDeepRight, mergeLeft, min, minBy, minByFn, modulo, move, multiply, negate, none, not, nth, objOf, of, omit, once, or, over, partial, partition, partitionArray, partitionObject, path, pathEq, pathOr, paths, pick, pickAll, pipe, pluck, prepend, product, prop, propEq, propIs, propOr, props, range, reduce, reject, repeat, replace, reverse, set, slice, sort, sortBy, split, splitAt, splitEvery, splitWhen, startsWith, subtract, sum, symmetricDifference, tail, take, takeLast, takeLastWhile, takeWhile, tap, test, times, toLower, toPairs, toString, toUpper, transpose, trim, tryCatch, type, unapply, union, uniq, uniqWith, unless, update, values, view, when, where, whereEq, without, xor, zip, zipObj, zipWith };