rambda 9.4.2 → 10.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (271) hide show
  1. package/CHANGELOG.md +177 -1
  2. package/README.md +6799 -11799
  3. package/dist/rambda.cjs +1795 -0
  4. package/dist/rambda.js +1162 -2234
  5. package/dist/rambda.umd.js +1801 -1
  6. package/immutable.d.ts +1154 -1403
  7. package/index.d.ts +1154 -1403
  8. package/package.json +102 -94
  9. package/rambda.js +24 -137
  10. package/src/_internals/baseSlice.js +5 -7
  11. package/src/_internals/createPath.js +4 -6
  12. package/src/_internals/includes.js +8 -4
  13. package/src/_internals/set.js +11 -11
  14. package/src/addProp.js +3 -0
  15. package/src/all.js +8 -6
  16. package/src/allPass.js +4 -4
  17. package/src/any.js +10 -10
  18. package/src/anyPass.js +4 -4
  19. package/src/append.js +6 -8
  20. package/src/ascend.js +8 -15
  21. package/src/checkObjectWithSpec.js +16 -0
  22. package/src/compact.js +12 -0
  23. package/src/complement.js +1 -1
  24. package/src/concat.js +2 -4
  25. package/src/count.js +7 -6
  26. package/src/countBy.js +13 -14
  27. package/src/createObjectFromKeys.js +10 -0
  28. package/src/defaultTo.js +4 -6
  29. package/src/descend.js +6 -13
  30. package/src/drop.js +4 -2
  31. package/src/dropLast.js +2 -8
  32. package/src/dropLastWhile.js +17 -26
  33. package/src/dropWhile.js +14 -22
  34. package/src/eqBy.js +3 -8
  35. package/src/eqProps.js +3 -9
  36. package/src/equals.js +99 -58
  37. package/src/evolve.js +3 -57
  38. package/src/excludes.js +5 -0
  39. package/src/filter.js +13 -43
  40. package/src/filterObject.js +13 -0
  41. package/src/find.js +10 -10
  42. package/src/findIndex.js +10 -10
  43. package/src/findLast.js +9 -9
  44. package/src/findLastIndex.js +9 -9
  45. package/src/findNth.js +16 -0
  46. package/src/flatMap.js +3 -0
  47. package/src/flatten.js +5 -5
  48. package/src/groupBy.js +14 -11
  49. package/src/head.js +5 -3
  50. package/src/includes.js +13 -11
  51. package/src/indexOf.js +2 -6
  52. package/src/init.js +6 -8
  53. package/src/innerJoin.js +11 -19
  54. package/src/interpolate.js +29 -0
  55. package/src/intersection.js +2 -4
  56. package/src/intersperse.js +13 -13
  57. package/src/join.js +2 -4
  58. package/src/last.js +4 -4
  59. package/src/lastIndexOf.js +2 -6
  60. package/src/map.js +9 -49
  61. package/src/mapAsync.js +11 -0
  62. package/src/mapKeys.js +11 -0
  63. package/src/mapObject.js +18 -0
  64. package/src/mapObjectAsync.js +10 -0
  65. package/src/mapParallelAsync.js +3 -0
  66. package/src/match.js +5 -5
  67. package/src/maxBy.js +2 -8
  68. package/src/merge.js +4 -1
  69. package/src/mergeTypes.js +3 -0
  70. package/src/minBy.js +2 -8
  71. package/src/modifyProp.js +20 -0
  72. package/src/none.js +8 -6
  73. package/src/objOf.js +2 -6
  74. package/src/objectIncludes.js +12 -0
  75. package/src/omit.js +26 -11
  76. package/src/partition.js +15 -42
  77. package/src/partitionObject.js +15 -0
  78. package/src/path.js +14 -15
  79. package/src/permutations.js +40 -0
  80. package/src/pick.js +15 -15
  81. package/src/pipe.js +70 -13
  82. package/src/pipeAsync.js +11 -0
  83. package/src/pluck.js +12 -14
  84. package/src/prepend.js +2 -6
  85. package/src/prop.js +2 -10
  86. package/src/propEq.js +8 -10
  87. package/src/propOr.js +7 -8
  88. package/src/propSatisfies.js +2 -9
  89. package/src/range.js +34 -11
  90. package/src/reduce.js +15 -30
  91. package/src/reject.js +2 -4
  92. package/src/rejectObject.js +13 -0
  93. package/src/replace.js +2 -8
  94. package/src/replaceItemAtIndex.js +15 -0
  95. package/src/shuffle.js +13 -0
  96. package/src/sort.js +2 -4
  97. package/src/sortBy.js +12 -10
  98. package/src/sortObject.js +15 -0
  99. package/src/sortWith.js +12 -16
  100. package/src/split.js +2 -4
  101. package/src/splitEvery.js +11 -13
  102. package/src/symmetricDifference.js +5 -8
  103. package/src/tail.js +2 -2
  104. package/src/take.js +11 -9
  105. package/src/takeLast.js +14 -14
  106. package/src/takeLastWhile.js +15 -16
  107. package/src/takeWhile.js +12 -21
  108. package/src/tap.js +5 -5
  109. package/src/test.js +2 -8
  110. package/src/tryCatch.js +5 -14
  111. package/src/type.js +6 -5
  112. package/src/union.js +10 -8
  113. package/src/uniq.js +2 -2
  114. package/src/uniqBy.js +5 -6
  115. package/src/uniqWith.js +15 -19
  116. package/src/unless.js +7 -9
  117. package/src/unwind.js +6 -14
  118. package/src/update.js +8 -11
  119. package/src/when.js +7 -9
  120. package/src/zip.js +8 -8
  121. package/src/zipWith.js +5 -7
  122. package/src/F.js +0 -3
  123. package/src/T.js +0 -3
  124. package/src/_internals/_arity.js +0 -64
  125. package/src/_internals/compare.js +0 -3
  126. package/src/_internals/constants.js +0 -1
  127. package/src/_internals/createPathInput.js +0 -7
  128. package/src/_internals/isFalsy.js +0 -13
  129. package/src/_internals/isInteger.js +0 -10
  130. package/src/_internals/isIterable.js +0 -5
  131. package/src/_internals/isObject.js +0 -5
  132. package/src/_internals/isTruthy.js +0 -13
  133. package/src/_internals/objectIs.js +0 -9
  134. package/src/_internals/utils.js +0 -21
  135. package/src/add.js +0 -5
  136. package/src/addIndex.js +0 -23
  137. package/src/addIndexRight.js +0 -9
  138. package/src/adjust.js +0 -16
  139. package/src/always.js +0 -3
  140. package/src/and.js +0 -5
  141. package/src/ap.js +0 -7
  142. package/src/aperture.js +0 -15
  143. package/src/apply.js +0 -7
  144. package/src/applySpec.js +0 -132
  145. package/src/applyTo.js +0 -7
  146. package/src/assoc.js +0 -11
  147. package/src/assocPath.js +0 -46
  148. package/src/binary.js +0 -5
  149. package/src/bind.js +0 -9
  150. package/src/both.js +0 -5
  151. package/src/call.js +0 -1
  152. package/src/chain.js +0 -7
  153. package/src/clamp.js +0 -15
  154. package/src/clone.js +0 -18
  155. package/src/collectBy.js +0 -27
  156. package/src/comparator.js +0 -5
  157. package/src/compose.js +0 -9
  158. package/src/composeWith.js +0 -33
  159. package/src/cond.js +0 -14
  160. package/src/converge.js +0 -18
  161. package/src/curry.js +0 -7
  162. package/src/curryN.js +0 -40
  163. package/src/dec.js +0 -1
  164. package/src/difference.js +0 -8
  165. package/src/differenceWith.js +0 -20
  166. package/src/dissoc.js +0 -13
  167. package/src/dissocPath.js +0 -47
  168. package/src/divide.js +0 -5
  169. package/src/dropRepeats.js +0 -20
  170. package/src/dropRepeatsBy.js +0 -21
  171. package/src/dropRepeatsWith.js +0 -28
  172. package/src/either.js +0 -8
  173. package/src/empty.js +0 -15
  174. package/src/endsWith.js +0 -23
  175. package/src/flip.js +0 -23
  176. package/src/forEach.js +0 -19
  177. package/src/forEachObjIndexed.js +0 -24
  178. package/src/fromPairs.js +0 -6
  179. package/src/groupWith.js +0 -46
  180. package/src/gt.js +0 -6
  181. package/src/gte.js +0 -6
  182. package/src/has.js +0 -7
  183. package/src/hasIn.js +0 -9
  184. package/src/hasPath.js +0 -9
  185. package/src/identical.js +0 -7
  186. package/src/identity.js +0 -3
  187. package/src/ifElse.js +0 -17
  188. package/src/inc.js +0 -1
  189. package/src/indexBy.js +0 -29
  190. package/src/insert.js +0 -11
  191. package/src/insertAll.js +0 -7
  192. package/src/is.js +0 -8
  193. package/src/isEmpty.js +0 -18
  194. package/src/isNil.js +0 -3
  195. package/src/isNotEmpty.js +0 -5
  196. package/src/isNotNil.js +0 -3
  197. package/src/isPromise.js +0 -5
  198. package/src/juxt.js +0 -3
  199. package/src/keys.js +0 -3
  200. package/src/length.js +0 -8
  201. package/src/lens.js +0 -7
  202. package/src/lensIndex.js +0 -7
  203. package/src/lensPath.js +0 -7
  204. package/src/lensProp.js +0 -7
  205. package/src/lt.js +0 -6
  206. package/src/lte.js +0 -6
  207. package/src/mathMod.js +0 -8
  208. package/src/max.js +0 -5
  209. package/src/maybe.js +0 -13
  210. package/src/mean.js +0 -5
  211. package/src/median.js +0 -17
  212. package/src/mergeAll.js +0 -11
  213. package/src/mergeDeepLeft.js +0 -5
  214. package/src/mergeDeepRight.js +0 -24
  215. package/src/mergeLeft.js +0 -7
  216. package/src/mergeRight.js +0 -8
  217. package/src/mergeWith.js +0 -25
  218. package/src/min.js +0 -5
  219. package/src/modify.js +0 -23
  220. package/src/modifyPath.js +0 -33
  221. package/src/modulo.js +0 -5
  222. package/src/move.js +0 -19
  223. package/src/multiply.js +0 -5
  224. package/src/negate.js +0 -3
  225. package/src/not.js +0 -3
  226. package/src/nth.js +0 -9
  227. package/src/of.js +0 -3
  228. package/src/on.js +0 -16
  229. package/src/once.js +0 -24
  230. package/src/or.js +0 -5
  231. package/src/over.js +0 -14
  232. package/src/partial.js +0 -17
  233. package/src/partialObject.js +0 -5
  234. package/src/pathEq.js +0 -11
  235. package/src/pathOr.js +0 -11
  236. package/src/pathSatisfies.js +0 -9
  237. package/src/paths.js +0 -9
  238. package/src/pickAll.js +0 -23
  239. package/src/pickBy.js +0 -11
  240. package/src/product.js +0 -4
  241. package/src/propIs.js +0 -10
  242. package/src/props.js +0 -13
  243. package/src/reduceBy.js +0 -29
  244. package/src/removeIndex.js +0 -7
  245. package/src/repeat.js +0 -7
  246. package/src/reverse.js +0 -9
  247. package/src/set.js +0 -9
  248. package/src/slice.js +0 -9
  249. package/src/splitAt.js +0 -21
  250. package/src/splitWhen.js +0 -25
  251. package/src/startsWith.js +0 -23
  252. package/src/subtract.js +0 -5
  253. package/src/sum.js +0 -3
  254. package/src/swap.js +0 -42
  255. package/src/times.js +0 -12
  256. package/src/toLower.js +0 -3
  257. package/src/toPairs.js +0 -3
  258. package/src/toString.js +0 -3
  259. package/src/toUpper.js +0 -3
  260. package/src/transpose.js +0 -10
  261. package/src/trim.js +0 -3
  262. package/src/unapply.js +0 -5
  263. package/src/unnest.js +0 -9
  264. package/src/values.js +0 -6
  265. package/src/view.js +0 -10
  266. package/src/where.js +0 -15
  267. package/src/whereAny.js +0 -12
  268. package/src/whereEq.js +0 -14
  269. package/src/without.js +0 -15
  270. package/src/xor.js +0 -5
  271. package/src/zipObj.js +0 -13
@@ -0,0 +1,1795 @@
1
+ 'use strict';
2
+
3
+ function addProp(key, value) {
4
+ return obj => ({ ...obj, [key]: value })
5
+ }
6
+
7
+ function all(predicate) {
8
+ return list => {
9
+ for (let i = 0; i < list.length; i++) {
10
+ if (!predicate(list[i])) {
11
+ return false
12
+ }
13
+ }
14
+
15
+ return true
16
+ }
17
+ }
18
+
19
+ function allPass(predicates) {
20
+ return input => {
21
+ let counter = 0;
22
+ while (counter < predicates.length) {
23
+ if (!predicates[counter](input)) {
24
+ return false
25
+ }
26
+ counter++;
27
+ }
28
+
29
+ return true
30
+ }
31
+ }
32
+
33
+ function any(predicate) {
34
+ return list => {
35
+ let counter = 0;
36
+ while (counter < list.length) {
37
+ if (predicate(list[counter], counter)) {
38
+ return true
39
+ }
40
+ counter++;
41
+ }
42
+
43
+ return false
44
+ }
45
+ }
46
+
47
+ function anyPass(predicates) {
48
+ return input => {
49
+ let counter = 0;
50
+ while (counter < predicates.length) {
51
+ if (predicates[counter](input)) {
52
+ return true
53
+ }
54
+ counter++;
55
+ }
56
+
57
+ return false
58
+ }
59
+ }
60
+
61
+ const cloneList$1 = list => Array.prototype.slice.call(list);
62
+
63
+ function append(x) {
64
+ return list => {
65
+ const clone = cloneList$1(list);
66
+ clone.push(x);
67
+
68
+ return clone
69
+ }
70
+ }
71
+
72
+ function createCompareFunction(a, b, winner, loser) {
73
+ if (a === b) {
74
+ return 0
75
+ }
76
+
77
+ return a < b ? winner : loser
78
+ }
79
+
80
+ function ascend(getFunction) {
81
+ return (a, b) => {
82
+ const aValue = getFunction(a);
83
+ const bValue = getFunction(b);
84
+
85
+ return createCompareFunction(aValue, bValue, -1, 1)
86
+ }
87
+ }
88
+
89
+ function checkObjectWithSpec(conditions) {
90
+ return input => {
91
+ let shouldProceed = true;
92
+ for (const prop in conditions) {
93
+ if (!shouldProceed) {
94
+ continue
95
+ }
96
+ const result = conditions[prop](input[prop]);
97
+ if (shouldProceed && result === false) {
98
+ shouldProceed = false;
99
+ }
100
+ }
101
+
102
+ return shouldProceed
103
+ }
104
+ }
105
+
106
+ const { isArray } = Array;
107
+
108
+ function filter(predicate) {
109
+ return list => {
110
+ if (!list) {
111
+ throw new Error('Incorrect iterable input')
112
+ }
113
+ let index = 0;
114
+ const len = list.length;
115
+ const willReturn = [];
116
+
117
+ while (index < len) {
118
+ if (predicate(list[index], index)) {
119
+ willReturn.push(list[index]);
120
+ }
121
+
122
+ index++;
123
+ }
124
+
125
+ return willReturn
126
+ }
127
+ }
128
+
129
+ function reject(predicate) {
130
+ return list => filter(x => !predicate(x))(list)
131
+ }
132
+
133
+ function rejectObject(predicate) {
134
+ return obj => {
135
+ const willReturn = {};
136
+
137
+ for (const prop in obj) {
138
+ if (!predicate(obj[prop], prop, obj)) {
139
+ willReturn[prop] = obj[prop];
140
+ }
141
+ }
142
+
143
+ return willReturn
144
+ }
145
+ }
146
+
147
+ const isNullOrUndefined = x => x === null || x === undefined;
148
+
149
+ function compact(input){
150
+ if(isArray(input)){
151
+ return reject(isNullOrUndefined)(input)
152
+ }
153
+ return rejectObject(isNullOrUndefined)(input)
154
+ }
155
+
156
+ function complement(fn) {
157
+ return (...input) => !fn(...input)
158
+ }
159
+
160
+ function concat(x) {
161
+ return y => (typeof x === 'string' ? `${x}${y}` : [...x, ...y])
162
+ }
163
+
164
+ function count(predicate) {
165
+ return list => {
166
+ if (!isArray(list)) {
167
+ return 0
168
+ }
169
+
170
+ return list.filter(x => predicate(x)).length
171
+ }
172
+ }
173
+
174
+ function countBy(fn) {
175
+ return list => {
176
+ const willReturn = {};
177
+
178
+ list.forEach(item => {
179
+ const key = fn(item);
180
+ if (!willReturn[key]) {
181
+ willReturn[key] = 1;
182
+ } else {
183
+ willReturn[key]++;
184
+ }
185
+ });
186
+
187
+ return willReturn
188
+ }
189
+ }
190
+
191
+ function createObjectFromKeys(keys) {
192
+ return fn => {
193
+ const result = {};
194
+ keys.forEach((key, index) => {
195
+ result[key] = fn(key, index);
196
+ });
197
+
198
+ return result
199
+ }
200
+ }
201
+
202
+ function isFalsy(input) {
203
+ return input === undefined || input === null || Number.isNaN(input) === true
204
+ }
205
+
206
+ function defaultTo(defaultArgument, input) {
207
+ if (arguments.length === 1) {
208
+ return _input => defaultTo(defaultArgument, _input)
209
+ }
210
+
211
+ return isFalsy(input) ? defaultArgument : input
212
+ }
213
+
214
+ function descend(getFunction) {
215
+ return (a, b) => {
216
+ const aValue = getFunction(a);
217
+ const bValue = getFunction(b);
218
+
219
+ return createCompareFunction(aValue, bValue, 1, -1)
220
+ }
221
+ }
222
+
223
+ function drop(howManyToDrop, listOrString) {
224
+ if (arguments.length === 1) {
225
+ return _list => drop(howManyToDrop, _list)
226
+ }
227
+
228
+ return listOrString.slice(howManyToDrop > 0 ? howManyToDrop : 0)
229
+ }
230
+
231
+ function dropLast(numberItems) {
232
+ return list => (numberItems > 0 ? list.slice(0, -numberItems) : list.slice())
233
+ }
234
+
235
+ function dropLastWhile(predicate) {
236
+ return list => {
237
+ if (list.length === 0) {
238
+ return list
239
+ }
240
+
241
+ const toReturn = [];
242
+ let counter = list.length;
243
+
244
+ while (counter) {
245
+ const item = list[--counter];
246
+ if (!predicate(item, counter)) {
247
+ toReturn.push(item);
248
+ break
249
+ }
250
+ }
251
+
252
+ while (counter) {
253
+ toReturn.push(list[--counter]);
254
+ }
255
+
256
+ return toReturn.reverse()
257
+ }
258
+ }
259
+
260
+ function dropWhile(predicate) {
261
+ return iterable => {
262
+ const toReturn = [];
263
+ let counter = 0;
264
+
265
+ while (counter < iterable.length) {
266
+ const item = iterable[counter++];
267
+ if (!predicate(item, counter)) {
268
+ toReturn.push(item);
269
+ break
270
+ }
271
+ }
272
+
273
+ while (counter < iterable.length) {
274
+ toReturn.push(iterable[counter++]);
275
+ }
276
+
277
+ return toReturn
278
+ }
279
+ }
280
+
281
+ function type(input) {
282
+ if (input === null) {
283
+ return 'Null'
284
+ }
285
+ if (input === undefined) {
286
+ return 'Undefined'
287
+ }
288
+ if (Number.isNaN(input)) {
289
+ return 'NaN'
290
+ }
291
+ const typeResult = Object.prototype.toString.call(input).slice(8, -1);
292
+ return typeResult === 'AsyncFunction' ? 'Promise' : typeResult
293
+ }
294
+
295
+ function _lastIndexOf(valueToFind, list) {
296
+ if (!isArray(list)) {
297
+ throw new Error(`Cannot read property 'indexOf' of ${list}`)
298
+ }
299
+
300
+ const typeOfValue = type(valueToFind);
301
+ if (!['Array', 'NaN', 'Object', 'RegExp'].includes(typeOfValue)) {
302
+ return list.lastIndexOf(valueToFind)
303
+ }
304
+
305
+ const { length } = list;
306
+ let index = length;
307
+ let foundIndex = -1;
308
+
309
+ while (--index > -1 && foundIndex === -1) {
310
+ if (equalsFn(list[index], valueToFind)) {
311
+ foundIndex = index;
312
+ }
313
+ }
314
+
315
+ return foundIndex
316
+ }
317
+
318
+ function _indexOf(valueToFind, list) {
319
+ if (!isArray(list)) {
320
+ throw new Error(`Cannot read property 'indexOf' of ${list}`)
321
+ }
322
+
323
+ const typeOfValue = type(valueToFind);
324
+ if (!['Array', 'NaN', 'Object', 'RegExp'].includes(typeOfValue)) {
325
+ return list.indexOf(valueToFind)
326
+ }
327
+
328
+ let index = -1;
329
+ let foundIndex = -1;
330
+ const { length } = list;
331
+
332
+ while (++index < length && foundIndex === -1) {
333
+ if (equalsFn(list[index], valueToFind)) {
334
+ foundIndex = index;
335
+ }
336
+ }
337
+
338
+ return foundIndex
339
+ }
340
+
341
+ function _arrayFromIterator(iter) {
342
+ const list = [];
343
+ let next;
344
+ while (!(next = iter.next()).done) {
345
+ list.push(next.value);
346
+ }
347
+
348
+ return list
349
+ }
350
+
351
+ function _compareSets(a, b) {
352
+ if (a.size !== b.size) {
353
+ return false
354
+ }
355
+
356
+ const aList = _arrayFromIterator(a.values());
357
+ const bList = _arrayFromIterator(b.values());
358
+
359
+ const filtered = aList.filter(aInstance => _indexOf(aInstance, bList) === -1);
360
+
361
+ return filtered.length === 0
362
+ }
363
+
364
+ function compareErrors(a, b) {
365
+ if (a.message !== b.message) {
366
+ return false
367
+ }
368
+ if (a.toString !== b.toString) {
369
+ return false
370
+ }
371
+
372
+ return a.toString() === b.toString()
373
+ }
374
+
375
+ function parseDate(maybeDate) {
376
+ if (!maybeDate.toDateString) {
377
+ return [false]
378
+ }
379
+
380
+ return [true, maybeDate.getTime()]
381
+ }
382
+
383
+ function parseRegex(maybeRegex) {
384
+ if (maybeRegex.constructor !== RegExp) {
385
+ return [false]
386
+ }
387
+
388
+ return [true, maybeRegex.toString()]
389
+ }
390
+
391
+ function equalsFn(a, b) {
392
+ if (Object.is(a, b)) {
393
+ return true
394
+ }
395
+
396
+ const aType = type(a);
397
+
398
+ if (aType !== type(b)) {
399
+ return false
400
+ }
401
+ if (aType === 'Function') {
402
+ return a.name === undefined ? false : a.name === b.name
403
+ }
404
+
405
+ if (['NaN', 'Null', 'Undefined'].includes(aType)) {
406
+ return true
407
+ }
408
+
409
+ if (['BigInt', 'Number'].includes(aType)) {
410
+ if (Object.is(-0, a) !== Object.is(-0, b)) {
411
+ return false
412
+ }
413
+
414
+ return a.toString() === b.toString()
415
+ }
416
+
417
+ if (['Boolean', 'String'].includes(aType)) {
418
+ return a.toString() === b.toString()
419
+ }
420
+
421
+ if (aType === 'Array') {
422
+ const aClone = Array.from(a);
423
+ const bClone = Array.from(b);
424
+
425
+ if (aClone.toString() !== bClone.toString()) {
426
+ return false
427
+ }
428
+
429
+ let loopArrayFlag = true;
430
+ aClone.forEach((aCloneInstance, aCloneIndex) => {
431
+ if (loopArrayFlag) {
432
+ if (
433
+ aCloneInstance !== bClone[aCloneIndex] &&
434
+ !equalsFn(aCloneInstance, bClone[aCloneIndex])
435
+ ) {
436
+ loopArrayFlag = false;
437
+ }
438
+ }
439
+ });
440
+
441
+ return loopArrayFlag
442
+ }
443
+
444
+ const aRegex = parseRegex(a);
445
+ const bRegex = parseRegex(b);
446
+
447
+ if (aRegex[0]) {
448
+ return bRegex[0] ? aRegex[1] === bRegex[1] : false
449
+ }
450
+ if (bRegex[0]) {
451
+ return false
452
+ }
453
+
454
+ const aDate = parseDate(a);
455
+ const bDate = parseDate(b);
456
+
457
+ if (aDate[0]) {
458
+ return bDate[0] ? aDate[1] === bDate[1] : false
459
+ }
460
+ if (bDate[0]) {
461
+ return false
462
+ }
463
+
464
+ if (a instanceof Error) {
465
+ if (!(b instanceof Error)) {
466
+ return false
467
+ }
468
+
469
+ return compareErrors(a, b)
470
+ }
471
+
472
+ if (aType === 'Set') {
473
+ return _compareSets(a, b)
474
+ }
475
+
476
+ if (aType === 'Object') {
477
+ const aKeys = Object.keys(a);
478
+
479
+ if (aKeys.length !== Object.keys(b).length) {
480
+ return false
481
+ }
482
+
483
+ let loopObjectFlag = true;
484
+ aKeys.forEach(aKeyInstance => {
485
+ if (loopObjectFlag) {
486
+ const aValue = a[aKeyInstance];
487
+ const bValue = b[aKeyInstance];
488
+
489
+ if (aValue !== bValue && !equalsFn(aValue, bValue)) {
490
+ loopObjectFlag = false;
491
+ }
492
+ }
493
+ });
494
+
495
+ return loopObjectFlag
496
+ }
497
+
498
+ return false
499
+ }
500
+ function equals(a) {
501
+ return b => equalsFn(a, b)
502
+ }
503
+
504
+ function eqBy(fn, a) {
505
+ return b => equalsFn(fn(a), fn(b))
506
+ }
507
+
508
+ function eqProps(property, objA) {
509
+ return objB => equalsFn( objA[property], objB[property] )
510
+ }
511
+
512
+ const { keys } = Object;
513
+
514
+ function mapObject(fn) {
515
+ return obj => {
516
+ let index = 0;
517
+ const objKeys = keys(obj);
518
+ const len = objKeys.length;
519
+ const willReturn = {};
520
+
521
+ while (index < len) {
522
+ const key = objKeys[index];
523
+ willReturn[key] = fn(obj[key], key, obj);
524
+ index++;
525
+ }
526
+
527
+ return willReturn
528
+ }
529
+ }
530
+
531
+ function evolve(rules) {
532
+ return mapObject((x, prop) => type(rules[prop]) === 'Function' ? rules[prop](x): x)
533
+ }
534
+
535
+ function includes(valueToFind) {
536
+ return iterable => {
537
+ if (typeof iterable === 'string') {
538
+ return iterable.includes(valueToFind)
539
+ }
540
+ if (!iterable) {
541
+ throw new TypeError(`Cannot read property \'indexOf\' of ${iterable}`)
542
+ }
543
+ if (!isArray(iterable)) {
544
+ return false
545
+ }
546
+
547
+ return _indexOf(valueToFind, iterable) > -1
548
+ }
549
+ }
550
+
551
+ function excludes(valueToFind) {
552
+ return iterable => !includes(valueToFind)(iterable)
553
+ }
554
+
555
+ function filterObject(predicate) {
556
+ return obj => {
557
+ const willReturn = {};
558
+
559
+ for (const prop in obj) {
560
+ if (predicate(obj[prop], prop, obj)) {
561
+ willReturn[prop] = obj[prop];
562
+ }
563
+ }
564
+
565
+ return willReturn
566
+ }
567
+ }
568
+
569
+ function find(predicate) {
570
+ return list => {
571
+ let index = 0;
572
+ const len = list.length;
573
+
574
+ while (index < len) {
575
+ const x = list[index];
576
+ if (predicate(x)) {
577
+ return x
578
+ }
579
+
580
+ index++;
581
+ }
582
+ }
583
+ }
584
+
585
+ function findIndex(predicate) {
586
+ return list => {
587
+ const len = list.length;
588
+ let index = -1;
589
+
590
+ while (++index < len) {
591
+ if (predicate(list[index])) {
592
+ return index
593
+ }
594
+ }
595
+
596
+ return -1
597
+ }
598
+ }
599
+
600
+ function findLast(predicate) {
601
+ return list => {
602
+ let index = list.length;
603
+
604
+ while (--index >= 0) {
605
+ if (predicate(list[index])) {
606
+ return list[index]
607
+ }
608
+ }
609
+
610
+ return undefined
611
+ }
612
+ }
613
+
614
+ function findLastIndex(fn) {
615
+ return list => {
616
+ let index = list.length;
617
+
618
+ while (--index >= 0) {
619
+ if (fn(list[index])) {
620
+ return index
621
+ }
622
+ }
623
+
624
+ return -1
625
+ }
626
+ }
627
+
628
+ function findNth(predicate, nth) {
629
+ return list => {
630
+ let index = 0;
631
+ const len = list.length;
632
+
633
+ while (index < len) {
634
+ const x = list[index];
635
+ if (predicate(x)) {
636
+ if (nth === 0) return x
637
+ nth--;
638
+ }
639
+
640
+ index++;
641
+ }
642
+ }
643
+ }
644
+
645
+ function flatMap(fn) {
646
+ return list => [].concat(...list.map(fn))
647
+ }
648
+
649
+ function flatten(list, input) {
650
+ const willReturn = input === undefined ? [] : input;
651
+
652
+ for (let i = 0; i < list.length; i++) {
653
+ if (isArray(list[i])) {
654
+ flatten(list[i], willReturn);
655
+ } else {
656
+ willReturn.push(list[i]);
657
+ }
658
+ }
659
+
660
+ return willReturn
661
+ }
662
+
663
+ function groupByFallback(groupFn, list) {
664
+ const result = {};
665
+ for (let i = 0; i < list.length; i++) {
666
+ const item = list[i];
667
+ const key = groupFn(item);
668
+
669
+ if (!result[key]) {
670
+ result[key] = [];
671
+ }
672
+
673
+ result[key].push(item);
674
+ }
675
+
676
+ return result
677
+ }
678
+
679
+
680
+ function groupBy(groupFn) {
681
+ return iterable => Object.groupBy ? Object.groupBy(iterable,groupFn) : groupByFallback(groupFn, iterable)
682
+ }
683
+
684
+ function head(listOrString) {
685
+ if (typeof listOrString === 'string') {
686
+ return listOrString[0] || ''
687
+ }
688
+
689
+ return listOrString[0]
690
+ }
691
+
692
+ function indexOf(valueToFind) {
693
+ return list => _indexOf(valueToFind, list)
694
+ }
695
+
696
+ function baseSlice(array, start, end) {
697
+ let index = -1;
698
+ let { length } = array;
699
+
700
+ end = end > length ? length : end;
701
+ if (end < 0) {
702
+ end += length;
703
+ }
704
+ length = start > end ? 0 : (end - start) >>> 0;
705
+ start >>>= 0;
706
+
707
+ const result = Array(length);
708
+
709
+ while (++index < length) {
710
+ result[index] = array[index + start];
711
+ }
712
+
713
+ return result
714
+ }
715
+
716
+ function init(input) {
717
+ if (typeof input === 'string') {
718
+ return input.slice(0, -1)
719
+ }
720
+
721
+ return input.length ? baseSlice(input, 0, -1) : []
722
+ }
723
+
724
+ function _includesWith(pred, x, list) {
725
+ let idx = 0;
726
+ const len = list.length;
727
+
728
+ while (idx < len) {
729
+ if (pred(x, list[idx])) {
730
+ return true
731
+ }
732
+
733
+ idx += 1;
734
+ }
735
+
736
+ return false
737
+ }
738
+ function _filter(fn, list) {
739
+ let idx = 0;
740
+ const len = list.length;
741
+ const result = [];
742
+
743
+ while (idx < len) {
744
+ if (fn(list[idx])) {
745
+ result[result.length] = list[idx];
746
+ }
747
+
748
+ idx += 1;
749
+ }
750
+
751
+ return result
752
+ }
753
+
754
+ function innerJoin(pred, xs) {
755
+ return ys => _filter(x => _includesWith(pred, x, ys), xs)
756
+ }
757
+
758
+ const getOccurrences = input => input.match(/{{\s*.+?\s*}}/g);
759
+ const getOccurrenceProp = occurrence => occurrence.replace(/{{\s*|\s*}}/g, '');
760
+
761
+ const replace$1 = ({ inputHolder, prop, replacer }) => {
762
+ const regexBase = `{{${prop}}}`;
763
+ const regex = new RegExp(regexBase, 'g');
764
+ return inputHolder.replace(regex, replacer)
765
+ };
766
+
767
+ function interpolate(input) {
768
+ return templateInput => {
769
+ const occurrences = getOccurrences(input);
770
+ if (occurrences === null) {
771
+ return input
772
+ }
773
+ let inputHolder = input;
774
+
775
+ for (const occurrence of occurrences) {
776
+ const prop = getOccurrenceProp(occurrence);
777
+ inputHolder = replace$1({
778
+ inputHolder,
779
+ prop,
780
+ replacer: templateInput[prop],
781
+ });
782
+ }
783
+
784
+ return inputHolder
785
+ }
786
+ }
787
+
788
+ function intersection(listA) {
789
+ return listB => filter(x => includes(x)(listA))(listB)
790
+ }
791
+
792
+ function intersperse(separator) {
793
+ return list => {
794
+ let index = -1;
795
+ const len = list.length;
796
+ const willReturn = [];
797
+
798
+ while (++index < len) {
799
+ if (index === len - 1) {
800
+ willReturn.push(list[index]);
801
+ } else {
802
+ willReturn.push(list[index], separator);
803
+ }
804
+ }
805
+
806
+ return willReturn
807
+ }
808
+ }
809
+
810
+ function join(glue) {
811
+ return list => list.join(glue)
812
+ }
813
+
814
+ function last(listOrString) {
815
+ if (typeof listOrString === 'string') {
816
+ return listOrString[listOrString.length - 1] || ''
817
+ }
818
+
819
+ return listOrString[listOrString.length - 1]
820
+ }
821
+
822
+ function lastIndexOf(valueToFind) {
823
+ return list => _lastIndexOf(valueToFind, list)
824
+ }
825
+
826
+ function map(fn) {
827
+ return list => {
828
+ let index = 0;
829
+ const willReturn = Array(list.length);
830
+ while (index < list.length) {
831
+ willReturn[index] = fn(list[index], index);
832
+ index++;
833
+ }
834
+ return willReturn
835
+ }
836
+ }
837
+
838
+ function mapAsync(fn) {
839
+ return async list => {
840
+ const willReturn = [];
841
+ let i = 0;
842
+ for (const a of list) {
843
+ willReturn.push(await fn(a, i++));
844
+ }
845
+
846
+ return willReturn
847
+ }
848
+ }
849
+
850
+ function mapKeys(fn) {
851
+ return obj => {
852
+ const willReturn = {};
853
+
854
+ Object.keys(obj).forEach(key => {
855
+ willReturn[fn(key, obj[key])] = obj[key];
856
+ });
857
+
858
+ return willReturn
859
+ }
860
+ }
861
+
862
+ function mapObjectAsync(fn) {
863
+ return async obj => {
864
+ const willReturn = {};
865
+ for (const prop in obj) {
866
+ willReturn[prop] = await fn(obj[prop], prop);
867
+ }
868
+
869
+ return willReturn
870
+ }
871
+ }
872
+
873
+ function mapParallelAsync(fn) {
874
+ return async list => Promise.all(list.map((x, i) => fn(x, i)))
875
+ }
876
+
877
+ function match(pattern) {
878
+ return input => {
879
+ const willReturn = input.match(pattern);
880
+
881
+ return willReturn === null ? [] : willReturn
882
+ }
883
+ }
884
+
885
+ function maxBy(compareFn, x) {
886
+ return y => (compareFn(y) > compareFn(x) ? y : x)
887
+ }
888
+
889
+ function merge(target) {
890
+ return objectWithNewProps =>
891
+ Object.assign({}, target || {}, objectWithNewProps || {})
892
+ }
893
+
894
+ function mergeTypes(x) {
895
+ return x
896
+ }
897
+
898
+ function minBy(compareFn, x) {
899
+ return y => (compareFn(y) < compareFn(x) ? y : x)
900
+ }
901
+
902
+ function update(index, newValue) {
903
+ return list => {
904
+ const clone = cloneList$1(list);
905
+ if (index === -1) {
906
+ return clone.fill(newValue, index)
907
+ }
908
+
909
+ return clone.fill(newValue, index, index + 1)
910
+ }
911
+ }
912
+
913
+ function modifyFn(property, fn, list) {
914
+ if (list[property] === undefined) {
915
+ return list
916
+ }
917
+ if (isArray(list)) {
918
+ return update(property, fn(list[property]))(list)
919
+ }
920
+
921
+ return {
922
+ ...list,
923
+ [property]: fn(list[property]),
924
+ }
925
+ }
926
+
927
+ function modifyProp(property, fn) {
928
+ return obj => modifyFn(property, fn, obj)
929
+ }
930
+
931
+ function none(predicate) {
932
+ return list => {
933
+ for (let i = 0; i < list.length; i++) {
934
+ if (predicate(list[i])) {
935
+ return false
936
+ }
937
+ }
938
+
939
+ return true
940
+ }
941
+ }
942
+
943
+ function objOf(key) {
944
+ return value => ({ [key]: value })
945
+ }
946
+
947
+ function objectIncludes(condition) {
948
+ return obj => {
949
+ const result = filterObject((conditionValue, conditionProp) =>
950
+ equals(conditionValue)(obj[conditionProp]),
951
+ )(condition);
952
+
953
+ return Object.keys(result).length === Object.keys(condition).length
954
+ }
955
+ }
956
+
957
+ function createPath(path, delimiter = '.') {
958
+ return typeof path === 'string'
959
+ ? path.split(delimiter).map(x => (Number.isInteger(Number(x)) ? Number(x) : x))
960
+ : path
961
+ }
962
+
963
+ function _includes(x, list) {
964
+ let index = -1;
965
+ const { length } = list;
966
+
967
+ while (++index < length) {
968
+ if (String(list[index]) === String(x)) {
969
+ return true
970
+ }
971
+ }
972
+
973
+ return false
974
+ }
975
+
976
+ function omit(propsToOmit) {
977
+ return obj => {
978
+ if (!obj) {
979
+ return undefined
980
+ }
981
+
982
+ const propsToOmitValue = createPath(propsToOmit, ',');
983
+ const willReturn = {};
984
+
985
+ for (const key in obj) {
986
+ if (!_includes(key, propsToOmitValue)) {
987
+ willReturn[key] = obj[key];
988
+ }
989
+ }
990
+
991
+ return willReturn
992
+ }
993
+ }
994
+
995
+ function partition(predicate) {
996
+ return list => {
997
+ const yes = [];
998
+ const no = [];
999
+ let counter = -1;
1000
+
1001
+ while (counter++ < list.length - 1) {
1002
+ if (predicate(list[counter], counter)) {
1003
+ yes.push(list[counter]);
1004
+ } else {
1005
+ no.push(list[counter]);
1006
+ }
1007
+ }
1008
+
1009
+ return [yes, no]
1010
+ }
1011
+ }
1012
+
1013
+ function partitionObject(predicate) {
1014
+ return obj => {
1015
+ const yes = {};
1016
+ const no = {};
1017
+ Object.entries(obj).forEach(([prop, value]) => {
1018
+ if (predicate(value, prop)) {
1019
+ yes[prop] = value;
1020
+ } else {
1021
+ no[prop] = value;
1022
+ }
1023
+ });
1024
+
1025
+ return [yes, no]
1026
+ }
1027
+ }
1028
+
1029
+ function path(pathInput, obj) {
1030
+ if (arguments.length === 1) {
1031
+ return _obj => path(pathInput, _obj)
1032
+ }
1033
+
1034
+ if (!obj) {
1035
+ return undefined
1036
+ }
1037
+ let willReturn = obj;
1038
+ let counter = 0;
1039
+
1040
+ const pathArrValue = createPath(pathInput);
1041
+
1042
+ while (counter < pathArrValue.length) {
1043
+ if (willReturn === null || willReturn === undefined) {
1044
+ return undefined
1045
+ }
1046
+ if (willReturn[pathArrValue[counter]] === null) {
1047
+ return undefined
1048
+ }
1049
+
1050
+ willReturn = willReturn[pathArrValue[counter]];
1051
+ counter++;
1052
+ }
1053
+
1054
+ return willReturn
1055
+ }
1056
+
1057
+ /**
1058
+ * Source:
1059
+ * https://github.com/denoland/std/blob/main/collections/permutations.ts
1060
+ */
1061
+ function permutations(inputArray) {
1062
+ const result = [];
1063
+ const array = cloneList$1(inputArray);
1064
+ const k = array.length;
1065
+ if (k === 0) {
1066
+ return result;
1067
+ }
1068
+
1069
+ const c = new Array(k).fill(0);
1070
+
1071
+ result.push([...array]);
1072
+
1073
+ let i = 1;
1074
+
1075
+ while (i < k) {
1076
+ if (c[i] < i) {
1077
+ if (i % 2 === 0) {
1078
+ [array[0], array[i]] = [array[i], array[0]];
1079
+ } else {
1080
+ [array[c[i]], array[i]] = [array[i], array[c[i]]];
1081
+ }
1082
+
1083
+ result.push([...array]);
1084
+
1085
+ c[i] += 1;
1086
+ i = 1;
1087
+ } else {
1088
+ c[i] = 0;
1089
+ i += 1;
1090
+ }
1091
+ }
1092
+
1093
+ return result;
1094
+ }
1095
+
1096
+ function pick(propsToPick) {
1097
+ return input => {
1098
+ if (!input === null) {
1099
+ return undefined
1100
+ }
1101
+ const keys = createPath(propsToPick, ',');
1102
+ const willReturn = {};
1103
+ let counter = 0;
1104
+
1105
+ while (counter < keys.length) {
1106
+ if (keys[counter] in input) {
1107
+ willReturn[keys[counter]] = input[keys[counter]];
1108
+ }
1109
+ counter++;
1110
+ }
1111
+
1112
+ return willReturn
1113
+ }
1114
+ }
1115
+
1116
+ function reduce(reducer, acc) {
1117
+ return list => {
1118
+ if (list == null) {
1119
+ return acc
1120
+ }
1121
+ if (!isArray(list)) {
1122
+ throw new TypeError('reduce: list must be array or iterable')
1123
+ }
1124
+ let index = 0;
1125
+ const len = list.length;
1126
+
1127
+ while (index < len) {
1128
+ acc = reducer(acc, list[index], index, list);
1129
+ index++;
1130
+ }
1131
+
1132
+ return acc
1133
+ }
1134
+ }
1135
+
1136
+ function _arity(n, fn) {
1137
+ switch (n) {
1138
+ case 0:
1139
+ return function () {
1140
+ return fn.apply(this, arguments)
1141
+ }
1142
+ case 1:
1143
+ return function (a0) {
1144
+ return fn.apply(this, arguments)
1145
+ }
1146
+ case 2:
1147
+ return function (a0, a1) {
1148
+ return fn.apply(this, arguments)
1149
+ }
1150
+ case 3:
1151
+ return function (a0, a1, a2) {
1152
+ return fn.apply(this, arguments)
1153
+ }
1154
+ case 4:
1155
+ return function (a0, a1, a2, a3) {
1156
+ return fn.apply(this, arguments)
1157
+ }
1158
+ case 5:
1159
+ return function (a0, a1, a2, a3, a4) {
1160
+ return fn.apply(this, arguments)
1161
+ }
1162
+ case 6:
1163
+ return function (a0, a1, a2, a3, a4, a5) {
1164
+ return fn.apply(this, arguments)
1165
+ }
1166
+ case 7:
1167
+ return function (a0, a1, a2, a3, a4, a5, a6) {
1168
+ return fn.apply(this, arguments)
1169
+ }
1170
+ case 8:
1171
+ return function (a0, a1, a2, a3, a4, a5, a6, a7) {
1172
+ return fn.apply(this, arguments)
1173
+ }
1174
+ case 9:
1175
+ return function (a0, a1, a2, a3, a4, a5, a6, a7, a8) {
1176
+ return fn.apply(this, arguments)
1177
+ }
1178
+ case 10:
1179
+ return function (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {
1180
+ return fn.apply(this, arguments)
1181
+ }
1182
+ default:
1183
+ throw new Error(
1184
+ 'First argument to _arity must be a non-negative integer no greater than ten',
1185
+ )
1186
+ }
1187
+ }
1188
+
1189
+ function _pipe(f, g) {
1190
+ return function () {
1191
+ return g.call(this, f.apply(this, arguments))
1192
+ }
1193
+ }
1194
+
1195
+ function pipeFn() {
1196
+ if (arguments.length === 0) {
1197
+ throw new Error('pipe requires at least one argument')
1198
+ }
1199
+
1200
+ return _arity(
1201
+ arguments[0].length,
1202
+ reduce(
1203
+ _pipe,
1204
+ arguments[0],
1205
+ )(Array.prototype.slice.call(arguments, 1, Number.POSITIVE_INFINITY)),
1206
+ )
1207
+ }
1208
+
1209
+ function pipe(...inputs) {
1210
+ const [input, ...fnList] = inputs;
1211
+
1212
+ return pipeFn(...fnList)(input)
1213
+ }
1214
+
1215
+ async function pipeAsync(input, ...fnList) {
1216
+ let willReturn = input;
1217
+ for (const fn of fnList) {
1218
+ const initialResult = fn(willReturn);
1219
+ willReturn =
1220
+ type(initialResult) === 'Promise' ? await initialResult : initialResult;
1221
+ }
1222
+ return willReturn
1223
+ }
1224
+
1225
+ function pluck(property) {
1226
+ return list => {
1227
+ const willReturn = [];
1228
+
1229
+ list.forEach(x => {
1230
+ if (x[property] !== undefined) {
1231
+ willReturn.push(x[property]);
1232
+ }
1233
+ });
1234
+
1235
+ return willReturn
1236
+ }
1237
+ }
1238
+
1239
+ function prepend(x) {
1240
+ return list => [x].concat(list)
1241
+ }
1242
+
1243
+ function prop(searchProperty) {
1244
+ return obj => (obj ? obj[searchProperty] : undefined)
1245
+ }
1246
+
1247
+ function propEq(valueToMatch, propToFind) {
1248
+ return obj => {
1249
+ if (!obj) {
1250
+ return false
1251
+ }
1252
+
1253
+ return equalsFn(valueToMatch, obj[propToFind])
1254
+ }
1255
+ }
1256
+
1257
+ function propOr(defaultValue, property) {
1258
+ return obj => {
1259
+ if (!obj) {
1260
+ return defaultValue
1261
+ }
1262
+
1263
+ return defaultTo(defaultValue, obj[property])
1264
+ }
1265
+ }
1266
+
1267
+ function propSatisfies(predicate, property) {
1268
+ return obj => predicate(obj[property])
1269
+ }
1270
+
1271
+ function range(start) {
1272
+ return end => {
1273
+ if (Number.isNaN(Number(start)) || Number.isNaN(Number(end))) {
1274
+ throw new TypeError('Both arguments to range must be numbers')
1275
+ }
1276
+
1277
+ if (end <= start) {
1278
+ return []
1279
+ }
1280
+
1281
+ const len = end - start;
1282
+ const willReturn = Array(len);
1283
+
1284
+ for (let i = 0; i < len + 1; i++) {
1285
+ willReturn[i] = start + i;
1286
+ }
1287
+
1288
+ return willReturn
1289
+ }
1290
+ }
1291
+
1292
+ function rangeDescending(start) {
1293
+ return end => {
1294
+ if (Number.isNaN(Number(start)) || Number.isNaN(Number(end))) {
1295
+ throw new TypeError('Both arguments to range must be numbers')
1296
+ }
1297
+
1298
+ if (end >= start) {
1299
+ return []
1300
+ }
1301
+
1302
+ const len = start - end;
1303
+ const willReturn = Array(len);
1304
+
1305
+ for (let i = 0; i < len + 1; i++) {
1306
+ willReturn[i] = start - i;
1307
+ }
1308
+
1309
+ return willReturn
1310
+ }
1311
+ }
1312
+
1313
+ function replace(pattern, replacer) {
1314
+ return str => str.replace(pattern, replacer)
1315
+ }
1316
+
1317
+ function replaceItemAtIndex(index, replaceFn) {
1318
+ return list => {
1319
+ const actualIndex = index < 0 ? list.length + index : index;
1320
+ if (index >= list.length || actualIndex < 0) {
1321
+ return list
1322
+ }
1323
+
1324
+ const clone = cloneList$1(list);
1325
+ clone[actualIndex] = replaceFn(clone[actualIndex]);
1326
+
1327
+ return clone
1328
+ }
1329
+ }
1330
+
1331
+ function shuffle(listInput) {
1332
+ const list = cloneList(listInput);
1333
+ let counter = list.length;
1334
+ while (counter > 0) {
1335
+ const index = Math.floor(Math.random() * counter);
1336
+ counter--;
1337
+ const temp = list[counter];
1338
+ list[counter] = list[index];
1339
+ list[index] = temp;
1340
+ }
1341
+
1342
+ return list
1343
+ }
1344
+
1345
+ function sort(sortFn) {
1346
+ return list => cloneList$1(list).sort(sortFn)
1347
+ }
1348
+
1349
+ function sortBy(sortFn) {
1350
+ return list => {
1351
+ const clone = cloneList$1(list);
1352
+
1353
+ return clone.sort((a, b) => {
1354
+ const aSortResult = sortFn(a);
1355
+ const bSortResult = sortFn(b);
1356
+
1357
+ if (aSortResult === bSortResult) {
1358
+ return 0
1359
+ }
1360
+
1361
+ return aSortResult < bSortResult ? -1 : 1
1362
+ })
1363
+ }
1364
+ }
1365
+
1366
+ function sortObject(predicate) {
1367
+ return obj => {
1368
+ const keys = Object.keys(obj);
1369
+ const sortedKeys = sort((a, b) => predicate(a, b, obj[a], obj[b]))(keys);
1370
+
1371
+ const toReturn = {};
1372
+ sortedKeys.forEach(singleKey => {
1373
+ toReturn[singleKey] = obj[singleKey];
1374
+ });
1375
+
1376
+ return toReturn
1377
+ }
1378
+ }
1379
+
1380
+ function sortHelper(a, b, listOfSortingFns) {
1381
+ let result = 0;
1382
+ let i = 0;
1383
+ while (result === 0 && i < listOfSortingFns.length) {
1384
+ result = listOfSortingFns[i](a, b);
1385
+ i += 1;
1386
+ }
1387
+
1388
+ return result
1389
+ }
1390
+
1391
+ function sortWith(listOfSortingFns) {
1392
+ return list => {
1393
+ if (Array.isArray(list) === false) {
1394
+ return []
1395
+ }
1396
+
1397
+ const clone = list.slice();
1398
+ clone.sort((a, b) => sortHelper(a, b, listOfSortingFns));
1399
+
1400
+ return clone
1401
+ }
1402
+ }
1403
+
1404
+ function split(separator) {
1405
+ return str => str.split(separator)
1406
+ }
1407
+
1408
+ function splitEvery(sliceLength) {
1409
+ return list => {
1410
+ if (sliceLength < 1) {
1411
+ throw new Error('First argument to splitEvery must be a positive integer')
1412
+ }
1413
+
1414
+ const willReturn = [];
1415
+ let counter = 0;
1416
+
1417
+ while (counter < list.length) {
1418
+ willReturn.push(list.slice(counter, (counter += sliceLength)));
1419
+ }
1420
+
1421
+ return willReturn
1422
+ }
1423
+ }
1424
+
1425
+ function symmetricDifference(x) {
1426
+ return y => [
1427
+ ...filter(value => !includes(value)(y))(x),
1428
+ ...filter(value => !includes(value)(x))(y),
1429
+ ]
1430
+ }
1431
+
1432
+ function tail(listOrString) {
1433
+ return drop(1)(listOrString)
1434
+ }
1435
+
1436
+ function take(numberOfItems) {
1437
+ return input => {
1438
+ if (numberOfItems < 0) {
1439
+ return input.slice()
1440
+ }
1441
+ if (typeof input === 'string') {
1442
+ return input.slice(0, numberOfItems)
1443
+ }
1444
+
1445
+ return baseSlice(input, 0, numberOfItems)
1446
+ }
1447
+ }
1448
+
1449
+ function takeLast(numberOfItems) {
1450
+ return input => {
1451
+ const len = input.length;
1452
+ if (numberOfItems < 0) {
1453
+ return input.slice()
1454
+ }
1455
+ let numValue = numberOfItems > len ? len : numberOfItems;
1456
+
1457
+ if (typeof input === 'string') {
1458
+ return input.slice(len - numValue)
1459
+ }
1460
+
1461
+ numValue = len - numValue;
1462
+
1463
+ return baseSlice(input, numValue, len)
1464
+ }
1465
+ }
1466
+
1467
+ function takeLastWhile(predicate) {
1468
+ return input => {
1469
+ if (input.length === 0) {
1470
+ return input
1471
+ }
1472
+
1473
+ const toReturn = [];
1474
+ let counter = input.length;
1475
+
1476
+ while (counter) {
1477
+ const item = input[--counter];
1478
+ if (!predicate(item)) {
1479
+ break
1480
+ }
1481
+ toReturn.push(item);
1482
+ }
1483
+
1484
+ return toReturn.reverse()
1485
+ }
1486
+ }
1487
+
1488
+ function takeWhile(predicate) {
1489
+ return iterable => {
1490
+ const toReturn = [];
1491
+ let counter = 0;
1492
+
1493
+ while (counter < iterable.length) {
1494
+ const item = iterable[counter++];
1495
+ if (!predicate(item)) {
1496
+ break
1497
+ }
1498
+ toReturn.push(item);
1499
+ }
1500
+ return toReturn
1501
+ }
1502
+ }
1503
+
1504
+ function tap(fn) {
1505
+ return x => {
1506
+ fn(x);
1507
+
1508
+ return x
1509
+ }
1510
+ }
1511
+
1512
+ function test(pattern) {
1513
+ return str => str.search(pattern) !== -1
1514
+ }
1515
+
1516
+ function tryCatch(fn, fallback) {
1517
+ return input => {
1518
+ try {
1519
+ return fn(input)
1520
+ } catch (e) {
1521
+ return fallback
1522
+ }
1523
+ }
1524
+ }
1525
+
1526
+ function union(x) {
1527
+ return y => {
1528
+ const toReturn = cloneList$1(x);
1529
+
1530
+ y.forEach(yInstance => {
1531
+ if (!includes(yInstance)(x)) {
1532
+ toReturn.push(yInstance);
1533
+ }
1534
+ });
1535
+
1536
+ return toReturn
1537
+ }
1538
+ }
1539
+
1540
+ class _Set {
1541
+ constructor() {
1542
+ this.set = new Set();
1543
+ this.items = {};
1544
+ }
1545
+
1546
+ checkUniqueness(item) {
1547
+ const type$1 = type(item);
1548
+ if (['Null', 'Undefined', 'NaN'].includes(type$1)) {
1549
+ if (type$1 in this.items) {
1550
+ return false
1551
+ }
1552
+ this.items[type$1] = true;
1553
+
1554
+ return true
1555
+ }
1556
+ if (!['Object', 'Array'].includes(type$1)) {
1557
+ const prevSize = this.set.size;
1558
+ this.set.add(item);
1559
+
1560
+ return this.set.size !== prevSize
1561
+ }
1562
+
1563
+ if (!(type$1 in this.items)) {
1564
+ this.items[type$1] = [item];
1565
+
1566
+ return true
1567
+ }
1568
+
1569
+ if (_indexOf(item, this.items[type$1]) === -1) {
1570
+ this.items[type$1].push(item);
1571
+
1572
+ return true
1573
+ }
1574
+
1575
+ return false
1576
+ }
1577
+ }
1578
+
1579
+ function uniq(list) {
1580
+ const set = new _Set();
1581
+ const willReturn = [];
1582
+ list.forEach(item => {
1583
+ if (set.checkUniqueness(item)) {
1584
+ willReturn.push(item);
1585
+ }
1586
+ });
1587
+
1588
+ return willReturn
1589
+ }
1590
+
1591
+ function uniqBy(fn) {
1592
+ return list => {
1593
+ const set = new _Set();
1594
+
1595
+ return list.filter(item => set.checkUniqueness(fn(item)))
1596
+ }
1597
+ }
1598
+
1599
+ function includesWith(predicate, target, list) {
1600
+ let willReturn = false;
1601
+ let index = -1;
1602
+
1603
+ while (++index < list.length && !willReturn) {
1604
+ const value = list[index];
1605
+
1606
+ if (predicate(target, value)) {
1607
+ willReturn = true;
1608
+ }
1609
+ }
1610
+
1611
+ return willReturn
1612
+ }
1613
+
1614
+ function uniqWith(predicate) {
1615
+ return list => {
1616
+ let index = -1;
1617
+ const willReturn = [];
1618
+
1619
+ while (++index < list.length) {
1620
+ const value = list[index];
1621
+
1622
+ if (!includesWith(predicate, value, willReturn)) {
1623
+ willReturn.push(value);
1624
+ }
1625
+ }
1626
+
1627
+ return willReturn
1628
+ }
1629
+ }
1630
+
1631
+ function unless(predicate, whenFalseFn) {
1632
+ return input => {
1633
+ if (predicate(input)) {
1634
+ return input
1635
+ }
1636
+
1637
+ return whenFalseFn(input)
1638
+ }
1639
+ }
1640
+
1641
+ function unwind(property) {
1642
+ return obj => {
1643
+ return obj[property].map(x => ({
1644
+ ...obj,
1645
+ [property]: x,
1646
+ }))
1647
+ }
1648
+ }
1649
+
1650
+ function when(predicate, whenTrueFn) {
1651
+ return input => {
1652
+ if (!predicate(input)) {
1653
+ return input
1654
+ }
1655
+
1656
+ return whenTrueFn(input)
1657
+ }
1658
+ }
1659
+
1660
+ function zip(left) {
1661
+ return right => {
1662
+ const result = [];
1663
+ const length = Math.min(left.length, right.length);
1664
+
1665
+ for (let i = 0; i < length; i++) {
1666
+ result[i] = [left[i], right[i]];
1667
+ }
1668
+
1669
+ return result
1670
+ }
1671
+ }
1672
+
1673
+ function zipWith(fn, x) {
1674
+ return y =>
1675
+ take(x.length > y.length ? y.length : x.length)(x).map((xInstance, i) =>
1676
+ fn(xInstance, y[i]),
1677
+ )
1678
+ }
1679
+
1680
+ exports._arity = _arity;
1681
+ exports._includes = _includes;
1682
+ exports._indexOf = _indexOf;
1683
+ exports._lastIndexOf = _lastIndexOf;
1684
+ exports.addProp = addProp;
1685
+ exports.all = all;
1686
+ exports.allPass = allPass;
1687
+ exports.any = any;
1688
+ exports.anyPass = anyPass;
1689
+ exports.append = append;
1690
+ exports.ascend = ascend;
1691
+ exports.checkObjectWithSpec = checkObjectWithSpec;
1692
+ exports.compact = compact;
1693
+ exports.complement = complement;
1694
+ exports.concat = concat;
1695
+ exports.count = count;
1696
+ exports.countBy = countBy;
1697
+ exports.createCompareFunction = createCompareFunction;
1698
+ exports.createObjectFromKeys = createObjectFromKeys;
1699
+ exports.defaultTo = defaultTo;
1700
+ exports.descend = descend;
1701
+ exports.drop = drop;
1702
+ exports.dropLast = dropLast;
1703
+ exports.dropLastWhile = dropLastWhile;
1704
+ exports.dropWhile = dropWhile;
1705
+ exports.eqBy = eqBy;
1706
+ exports.eqProps = eqProps;
1707
+ exports.equals = equals;
1708
+ exports.equalsFn = equalsFn;
1709
+ exports.evolve = evolve;
1710
+ exports.excludes = excludes;
1711
+ exports.filter = filter;
1712
+ exports.filterObject = filterObject;
1713
+ exports.find = find;
1714
+ exports.findIndex = findIndex;
1715
+ exports.findLast = findLast;
1716
+ exports.findLastIndex = findLastIndex;
1717
+ exports.findNth = findNth;
1718
+ exports.flatMap = flatMap;
1719
+ exports.flatten = flatten;
1720
+ exports.groupBy = groupBy;
1721
+ exports.groupByFallback = groupByFallback;
1722
+ exports.head = head;
1723
+ exports.includes = includes;
1724
+ exports.indexOf = indexOf;
1725
+ exports.init = init;
1726
+ exports.innerJoin = innerJoin;
1727
+ exports.interpolate = interpolate;
1728
+ exports.intersection = intersection;
1729
+ exports.intersperse = intersperse;
1730
+ exports.join = join;
1731
+ exports.last = last;
1732
+ exports.lastIndexOf = lastIndexOf;
1733
+ exports.map = map;
1734
+ exports.mapAsync = mapAsync;
1735
+ exports.mapKeys = mapKeys;
1736
+ exports.mapObject = mapObject;
1737
+ exports.mapObjectAsync = mapObjectAsync;
1738
+ exports.mapParallelAsync = mapParallelAsync;
1739
+ exports.match = match;
1740
+ exports.maxBy = maxBy;
1741
+ exports.merge = merge;
1742
+ exports.mergeTypes = mergeTypes;
1743
+ exports.minBy = minBy;
1744
+ exports.modifyProp = modifyProp;
1745
+ exports.none = none;
1746
+ exports.objOf = objOf;
1747
+ exports.objectIncludes = objectIncludes;
1748
+ exports.omit = omit;
1749
+ exports.partition = partition;
1750
+ exports.partitionObject = partitionObject;
1751
+ exports.path = path;
1752
+ exports.permutations = permutations;
1753
+ exports.pick = pick;
1754
+ exports.pipe = pipe;
1755
+ exports.pipeAsync = pipeAsync;
1756
+ exports.pluck = pluck;
1757
+ exports.prepend = prepend;
1758
+ exports.prop = prop;
1759
+ exports.propEq = propEq;
1760
+ exports.propOr = propOr;
1761
+ exports.propSatisfies = propSatisfies;
1762
+ exports.range = range;
1763
+ exports.rangeDescending = rangeDescending;
1764
+ exports.reduce = reduce;
1765
+ exports.reject = reject;
1766
+ exports.rejectObject = rejectObject;
1767
+ exports.replace = replace;
1768
+ exports.replaceItemAtIndex = replaceItemAtIndex;
1769
+ exports.shuffle = shuffle;
1770
+ exports.sort = sort;
1771
+ exports.sortBy = sortBy;
1772
+ exports.sortObject = sortObject;
1773
+ exports.sortWith = sortWith;
1774
+ exports.split = split;
1775
+ exports.splitEvery = splitEvery;
1776
+ exports.symmetricDifference = symmetricDifference;
1777
+ exports.tail = tail;
1778
+ exports.take = take;
1779
+ exports.takeLast = takeLast;
1780
+ exports.takeLastWhile = takeLastWhile;
1781
+ exports.takeWhile = takeWhile;
1782
+ exports.tap = tap;
1783
+ exports.test = test;
1784
+ exports.tryCatch = tryCatch;
1785
+ exports.type = type;
1786
+ exports.union = union;
1787
+ exports.uniq = uniq;
1788
+ exports.uniqBy = uniqBy;
1789
+ exports.uniqWith = uniqWith;
1790
+ exports.unless = unless;
1791
+ exports.unwind = unwind;
1792
+ exports.update = update;
1793
+ exports.when = when;
1794
+ exports.zip = zip;
1795
+ exports.zipWith = zipWith;