feelin 4.3.0

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 (114) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +6 -0
  3. data/.rspec +2 -0
  4. data/CHANGELOG.md +10 -0
  5. data/Gemfile +3 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +43 -0
  8. data/feelin.gemspec +22 -0
  9. data/lib/feelin/js/node_modules/.package-lock.json +67 -0
  10. data/lib/feelin/js/node_modules/@lezer/common/LICENSE +21 -0
  11. data/lib/feelin/js/node_modules/@lezer/common/README.md +14 -0
  12. data/lib/feelin/js/node_modules/@lezer/common/dist/index.cjs +2181 -0
  13. data/lib/feelin/js/node_modules/@lezer/common/dist/index.d.cts +1137 -0
  14. data/lib/feelin/js/node_modules/@lezer/common/dist/index.d.ts +1137 -0
  15. data/lib/feelin/js/node_modules/@lezer/common/dist/index.js +2168 -0
  16. data/lib/feelin/js/node_modules/@lezer/common/package.json +32 -0
  17. data/lib/feelin/js/node_modules/@lezer/highlight/LICENSE +21 -0
  18. data/lib/feelin/js/node_modules/@lezer/highlight/README.md +14 -0
  19. data/lib/feelin/js/node_modules/@lezer/highlight/dist/index.cjs +915 -0
  20. data/lib/feelin/js/node_modules/@lezer/highlight/dist/index.d.cts +621 -0
  21. data/lib/feelin/js/node_modules/@lezer/highlight/dist/index.d.ts +623 -0
  22. data/lib/feelin/js/node_modules/@lezer/highlight/dist/index.js +904 -0
  23. data/lib/feelin/js/node_modules/@lezer/highlight/package.json +31 -0
  24. data/lib/feelin/js/node_modules/@lezer/lr/LICENSE +21 -0
  25. data/lib/feelin/js/node_modules/@lezer/lr/README.md +25 -0
  26. data/lib/feelin/js/node_modules/@lezer/lr/dist/constants.d.ts +45 -0
  27. data/lib/feelin/js/node_modules/@lezer/lr/dist/constants.js +5 -0
  28. data/lib/feelin/js/node_modules/@lezer/lr/dist/index.cjs +1890 -0
  29. data/lib/feelin/js/node_modules/@lezer/lr/dist/index.d.cts +303 -0
  30. data/lib/feelin/js/node_modules/@lezer/lr/dist/index.d.ts +303 -0
  31. data/lib/feelin/js/node_modules/@lezer/lr/dist/index.js +1883 -0
  32. data/lib/feelin/js/node_modules/@lezer/lr/package.json +32 -0
  33. data/lib/feelin/js/node_modules/feelin/LICENSE +21 -0
  34. data/lib/feelin/js/node_modules/feelin/README.md +65 -0
  35. data/lib/feelin/js/node_modules/feelin/dist/builtins.d.ts +355 -0
  36. data/lib/feelin/js/node_modules/feelin/dist/index.cjs +2072 -0
  37. data/lib/feelin/js/node_modules/feelin/dist/index.cjs.map +1 -0
  38. data/lib/feelin/js/node_modules/feelin/dist/index.d.ts +3 -0
  39. data/lib/feelin/js/node_modules/feelin/dist/index.esm.js +2063 -0
  40. data/lib/feelin/js/node_modules/feelin/dist/index.esm.js.map +1 -0
  41. data/lib/feelin/js/node_modules/feelin/dist/interpreter.d.ts +26 -0
  42. data/lib/feelin/js/node_modules/feelin/dist/parser.d.ts +4 -0
  43. data/lib/feelin/js/node_modules/feelin/dist/temporal.d.ts +6 -0
  44. data/lib/feelin/js/node_modules/feelin/dist/types.d.ts +35 -0
  45. data/lib/feelin/js/node_modules/feelin/dist/utils.d.ts +12 -0
  46. data/lib/feelin/js/node_modules/feelin/package.json +63 -0
  47. data/lib/feelin/js/node_modules/lezer-feel/LICENSE +21 -0
  48. data/lib/feelin/js/node_modules/lezer-feel/README.md +94 -0
  49. data/lib/feelin/js/node_modules/lezer-feel/dist/index.cjs +1328 -0
  50. data/lib/feelin/js/node_modules/lezer-feel/dist/index.cjs.map +1 -0
  51. data/lib/feelin/js/node_modules/lezer-feel/dist/index.d.ts +32 -0
  52. data/lib/feelin/js/node_modules/lezer-feel/dist/index.js +1323 -0
  53. data/lib/feelin/js/node_modules/lezer-feel/dist/index.js.map +1 -0
  54. data/lib/feelin/js/node_modules/lezer-feel/package.json +61 -0
  55. data/lib/feelin/js/node_modules/luxon/LICENSE.md +7 -0
  56. data/lib/feelin/js/node_modules/luxon/README.md +55 -0
  57. data/lib/feelin/js/node_modules/luxon/build/amd/luxon.js +8623 -0
  58. data/lib/feelin/js/node_modules/luxon/build/amd/luxon.js.map +1 -0
  59. data/lib/feelin/js/node_modules/luxon/build/cjs-browser/luxon.js +8621 -0
  60. data/lib/feelin/js/node_modules/luxon/build/cjs-browser/luxon.js.map +1 -0
  61. data/lib/feelin/js/node_modules/luxon/build/es6/luxon.js +8011 -0
  62. data/lib/feelin/js/node_modules/luxon/build/es6/luxon.js.map +1 -0
  63. data/lib/feelin/js/node_modules/luxon/build/global/luxon.js +8626 -0
  64. data/lib/feelin/js/node_modules/luxon/build/global/luxon.js.map +1 -0
  65. data/lib/feelin/js/node_modules/luxon/build/global/luxon.min.js +1 -0
  66. data/lib/feelin/js/node_modules/luxon/build/global/luxon.min.js.map +1 -0
  67. data/lib/feelin/js/node_modules/luxon/build/node/luxon.js +7679 -0
  68. data/lib/feelin/js/node_modules/luxon/build/node/luxon.js.map +1 -0
  69. data/lib/feelin/js/node_modules/luxon/package.json +87 -0
  70. data/lib/feelin/js/node_modules/luxon/src/datetime.js +2566 -0
  71. data/lib/feelin/js/node_modules/luxon/src/duration.js +990 -0
  72. data/lib/feelin/js/node_modules/luxon/src/errors.js +61 -0
  73. data/lib/feelin/js/node_modules/luxon/src/impl/conversions.js +206 -0
  74. data/lib/feelin/js/node_modules/luxon/src/impl/diff.js +95 -0
  75. data/lib/feelin/js/node_modules/luxon/src/impl/digits.js +90 -0
  76. data/lib/feelin/js/node_modules/luxon/src/impl/english.js +233 -0
  77. data/lib/feelin/js/node_modules/luxon/src/impl/formats.js +176 -0
  78. data/lib/feelin/js/node_modules/luxon/src/impl/formatter.js +409 -0
  79. data/lib/feelin/js/node_modules/luxon/src/impl/invalid.js +14 -0
  80. data/lib/feelin/js/node_modules/luxon/src/impl/locale.js +554 -0
  81. data/lib/feelin/js/node_modules/luxon/src/impl/regexParser.js +335 -0
  82. data/lib/feelin/js/node_modules/luxon/src/impl/tokenParser.js +505 -0
  83. data/lib/feelin/js/node_modules/luxon/src/impl/util.js +316 -0
  84. data/lib/feelin/js/node_modules/luxon/src/impl/zoneUtil.js +34 -0
  85. data/lib/feelin/js/node_modules/luxon/src/info.js +205 -0
  86. data/lib/feelin/js/node_modules/luxon/src/interval.js +665 -0
  87. data/lib/feelin/js/node_modules/luxon/src/luxon.js +26 -0
  88. data/lib/feelin/js/node_modules/luxon/src/package.json +4 -0
  89. data/lib/feelin/js/node_modules/luxon/src/settings.js +180 -0
  90. data/lib/feelin/js/node_modules/luxon/src/zone.js +97 -0
  91. data/lib/feelin/js/node_modules/luxon/src/zones/IANAZone.js +231 -0
  92. data/lib/feelin/js/node_modules/luxon/src/zones/fixedOffsetZone.js +150 -0
  93. data/lib/feelin/js/node_modules/luxon/src/zones/invalidZone.js +53 -0
  94. data/lib/feelin/js/node_modules/luxon/src/zones/systemZone.js +61 -0
  95. data/lib/feelin/js/node_modules/min-dash/LICENSE +21 -0
  96. data/lib/feelin/js/node_modules/min-dash/README.md +38 -0
  97. data/lib/feelin/js/node_modules/min-dash/dist/array.d.ts +12 -0
  98. data/lib/feelin/js/node_modules/min-dash/dist/collection.d.ts +174 -0
  99. data/lib/feelin/js/node_modules/min-dash/dist/fn.d.ts +37 -0
  100. data/lib/feelin/js/node_modules/min-dash/dist/index.cjs +910 -0
  101. data/lib/feelin/js/node_modules/min-dash/dist/index.d.ts +5 -0
  102. data/lib/feelin/js/node_modules/min-dash/dist/index.esm.js +872 -0
  103. data/lib/feelin/js/node_modules/min-dash/dist/lang.d.ts +29 -0
  104. data/lib/feelin/js/node_modules/min-dash/dist/min-dash.js +916 -0
  105. data/lib/feelin/js/node_modules/min-dash/dist/min-dash.min.js +1 -0
  106. data/lib/feelin/js/node_modules/min-dash/dist/object.d.ts +112 -0
  107. data/lib/feelin/js/node_modules/min-dash/package.json +72 -0
  108. data/lib/feelin/js/package-lock.json +72 -0
  109. data/lib/feelin/js/package.json +5 -0
  110. data/lib/feelin/version.rb +3 -0
  111. data/lib/feelin.rb +63 -0
  112. data/spec/feelin/feelin_spec.rb +38 -0
  113. data/spec/spec_helper.rb +2 -0
  114. metadata +198 -0
@@ -0,0 +1,916 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MinDash = {}));
5
+ })(this, (function (exports) { 'use strict';
6
+
7
+ /**
8
+ * Flatten array, one level deep.
9
+ *
10
+ * @template T
11
+ *
12
+ * @param {T[][] | T[] | null} [arr]
13
+ *
14
+ * @return {T[]}
15
+ */
16
+ function flatten(arr) {
17
+ return Array.prototype.concat.apply([], arr);
18
+ }
19
+
20
+ const nativeToString = Object.prototype.toString;
21
+ const nativeHasOwnProperty = Object.prototype.hasOwnProperty;
22
+
23
+ function isUndefined(obj) {
24
+ return obj === undefined;
25
+ }
26
+
27
+ function isDefined(obj) {
28
+ return obj !== undefined;
29
+ }
30
+
31
+ function isNil(obj) {
32
+ return obj == null;
33
+ }
34
+
35
+ function isArray(obj) {
36
+ return nativeToString.call(obj) === '[object Array]';
37
+ }
38
+
39
+ function isObject(obj) {
40
+ return nativeToString.call(obj) === '[object Object]';
41
+ }
42
+
43
+ function isNumber(obj) {
44
+ return nativeToString.call(obj) === '[object Number]';
45
+ }
46
+
47
+ /**
48
+ * @param {any} obj
49
+ *
50
+ * @return {boolean}
51
+ */
52
+ function isFunction(obj) {
53
+ const tag = nativeToString.call(obj);
54
+
55
+ return (
56
+ tag === '[object Function]' ||
57
+ tag === '[object AsyncFunction]' ||
58
+ tag === '[object GeneratorFunction]' ||
59
+ tag === '[object AsyncGeneratorFunction]' ||
60
+ tag === '[object Proxy]'
61
+ );
62
+ }
63
+
64
+ function isString(obj) {
65
+ return nativeToString.call(obj) === '[object String]';
66
+ }
67
+
68
+
69
+ /**
70
+ * Ensure collection is an array.
71
+ *
72
+ * @param {Object} obj
73
+ */
74
+ function ensureArray(obj) {
75
+
76
+ if (isArray(obj)) {
77
+ return;
78
+ }
79
+
80
+ throw new Error('must supply array');
81
+ }
82
+
83
+ /**
84
+ * Return true, if target owns a property with the given key.
85
+ *
86
+ * @param {Object} target
87
+ * @param {String} key
88
+ *
89
+ * @return {Boolean}
90
+ */
91
+ function has(target, key) {
92
+ return !isNil(target) && nativeHasOwnProperty.call(target, key);
93
+ }
94
+
95
+ /**
96
+ * @template T
97
+ * @typedef { (
98
+ * ((e: T) => boolean) |
99
+ * ((e: T, idx: number) => boolean) |
100
+ * ((e: T, key: string) => boolean) |
101
+ * string |
102
+ * number
103
+ * ) } Matcher
104
+ */
105
+
106
+ /**
107
+ * @template T
108
+ * @template U
109
+ *
110
+ * @typedef { (
111
+ * ((e: T) => U) | string | number
112
+ * ) } Extractor
113
+ */
114
+
115
+
116
+ /**
117
+ * @template T
118
+ * @typedef { (val: T, key: any) => boolean } MatchFn
119
+ */
120
+
121
+ /**
122
+ * @template T
123
+ * @typedef { T[] } ArrayCollection
124
+ */
125
+
126
+ /**
127
+ * @template T
128
+ * @typedef { { [key: string]: T } } StringKeyValueCollection
129
+ */
130
+
131
+ /**
132
+ * @template T
133
+ * @typedef { { [key: number]: T } } NumberKeyValueCollection
134
+ */
135
+
136
+ /**
137
+ * @template T
138
+ * @typedef { StringKeyValueCollection<T> | NumberKeyValueCollection<T> } KeyValueCollection
139
+ */
140
+
141
+ /**
142
+ * @template T
143
+ * @typedef { KeyValueCollection<T> | ArrayCollection<T> } Collection
144
+ */
145
+
146
+ /**
147
+ * Find element in collection.
148
+ *
149
+ * @template T
150
+ * @param {Collection<T>} collection
151
+ * @param {Matcher<T>} matcher
152
+ *
153
+ * @return {Object}
154
+ */
155
+ function find(collection, matcher) {
156
+
157
+ const matchFn = toMatcher(matcher);
158
+
159
+ let match;
160
+
161
+ forEach(collection, function(val, key) {
162
+ if (matchFn(val, key)) {
163
+ match = val;
164
+
165
+ return false;
166
+ }
167
+ });
168
+
169
+ return match;
170
+
171
+ }
172
+
173
+
174
+ /**
175
+ * Find element index in collection.
176
+ *
177
+ * @template T
178
+ * @param {Collection<T>} collection
179
+ * @param {Matcher<T>} matcher
180
+ *
181
+ * @return {number | string | undefined}
182
+ */
183
+ function findIndex(collection, matcher) {
184
+
185
+ const matchFn = toMatcher(matcher);
186
+
187
+ let idx = isArray(collection) ? -1 : undefined;
188
+
189
+ forEach(collection, function(val, key) {
190
+ if (matchFn(val, key)) {
191
+ idx = key;
192
+
193
+ return false;
194
+ }
195
+ });
196
+
197
+ return idx;
198
+ }
199
+
200
+
201
+ /**
202
+ * Filter elements in collection.
203
+ *
204
+ * @template T
205
+ * @param {Collection<T>} collection
206
+ * @param {Matcher<T>} matcher
207
+ *
208
+ * @return {T[]} result
209
+ */
210
+ function filter(collection, matcher) {
211
+
212
+ const matchFn = toMatcher(matcher);
213
+
214
+ let result = [];
215
+
216
+ forEach(collection, function(val, key) {
217
+ if (matchFn(val, key)) {
218
+ result.push(val);
219
+ }
220
+ });
221
+
222
+ return result;
223
+ }
224
+
225
+
226
+ /**
227
+ * Iterate over collection; returning something
228
+ * (non-undefined) will stop iteration.
229
+ *
230
+ * @template T
231
+ * @param {Collection<T>} collection
232
+ * @param { ((item: T, idx: number) => (boolean|void)) | ((item: T, key: string) => (boolean|void)) } iterator
233
+ *
234
+ * @return {T} return result that stopped the iteration
235
+ */
236
+ function forEach(collection, iterator) {
237
+
238
+ let val,
239
+ result;
240
+
241
+ if (isUndefined(collection)) {
242
+ return;
243
+ }
244
+
245
+ const convertKey = isArray(collection) ? toNum : identity;
246
+
247
+ for (let key in collection) {
248
+
249
+ if (has(collection, key)) {
250
+ val = collection[key];
251
+
252
+ result = iterator(val, convertKey(key));
253
+
254
+ if (result === false) {
255
+ return val;
256
+ }
257
+ }
258
+ }
259
+ }
260
+
261
+ /**
262
+ * Return collection without element.
263
+ *
264
+ * @template T
265
+ * @param {ArrayCollection<T>} arr
266
+ * @param {Matcher<T>} matcher
267
+ *
268
+ * @return {T[]}
269
+ */
270
+ function without(arr, matcher) {
271
+
272
+ if (isUndefined(arr)) {
273
+ return [];
274
+ }
275
+
276
+ ensureArray(arr);
277
+
278
+ const matchFn = toMatcher(matcher);
279
+
280
+ return arr.filter(function(el, idx) {
281
+ return !matchFn(el, idx);
282
+ });
283
+
284
+ }
285
+
286
+
287
+ /**
288
+ * Reduce collection, returning a single result.
289
+ *
290
+ * @template T
291
+ * @template V
292
+ *
293
+ * @param {Collection<T>} collection
294
+ * @param {(result: V, entry: T, index: any) => V} iterator
295
+ * @param {V} result
296
+ *
297
+ * @return {V} result returned from last iterator
298
+ */
299
+ function reduce(collection, iterator, result) {
300
+
301
+ forEach(collection, function(value, idx) {
302
+ result = iterator(result, value, idx);
303
+ });
304
+
305
+ return result;
306
+ }
307
+
308
+
309
+ /**
310
+ * Return true if every element in the collection
311
+ * matches the criteria.
312
+ *
313
+ * @param {Object|Array} collection
314
+ * @param {Function} matcher
315
+ *
316
+ * @return {Boolean}
317
+ */
318
+ function every(collection, matcher) {
319
+
320
+ return !!reduce(collection, function(matches, val, key) {
321
+ return matches && matcher(val, key);
322
+ }, true);
323
+ }
324
+
325
+
326
+ /**
327
+ * Return true if some elements in the collection
328
+ * match the criteria.
329
+ *
330
+ * @param {Object|Array} collection
331
+ * @param {Function} matcher
332
+ *
333
+ * @return {Boolean}
334
+ */
335
+ function some(collection, matcher) {
336
+
337
+ return !!find(collection, matcher);
338
+ }
339
+
340
+
341
+ /**
342
+ * Transform a collection into another collection
343
+ * by piping each member through the given fn.
344
+ *
345
+ * @param {Object|Array} collection
346
+ * @param {Function} fn
347
+ *
348
+ * @return {Array} transformed collection
349
+ */
350
+ function map(collection, fn) {
351
+
352
+ let result = [];
353
+
354
+ forEach(collection, function(val, key) {
355
+ result.push(fn(val, key));
356
+ });
357
+
358
+ return result;
359
+ }
360
+
361
+
362
+ /**
363
+ * Get the collections keys.
364
+ *
365
+ * @param {Object|Array} collection
366
+ *
367
+ * @return {Array}
368
+ */
369
+ function keys(collection) {
370
+ return collection && Object.keys(collection) || [];
371
+ }
372
+
373
+
374
+ /**
375
+ * Shorthand for `keys(o).length`.
376
+ *
377
+ * @param {Object|Array} collection
378
+ *
379
+ * @return {Number}
380
+ */
381
+ function size(collection) {
382
+ return keys(collection).length;
383
+ }
384
+
385
+
386
+ /**
387
+ * Get the values in the collection.
388
+ *
389
+ * @param {Object|Array} collection
390
+ *
391
+ * @return {Array}
392
+ */
393
+ function values(collection) {
394
+ return map(collection, (val) => val);
395
+ }
396
+
397
+
398
+ /**
399
+ * Group collection members by attribute.
400
+ *
401
+ * @param {Object|Array} collection
402
+ * @param {Extractor} extractor
403
+ *
404
+ * @return {Object} map with { attrValue => [ a, b, c ] }
405
+ */
406
+ function groupBy(collection, extractor, grouped = {}) {
407
+
408
+ extractor = toExtractor(extractor);
409
+
410
+ forEach(collection, function(val) {
411
+ let discriminator = extractor(val) || '_';
412
+
413
+ let group = grouped[discriminator];
414
+
415
+ if (!group) {
416
+ group = grouped[discriminator] = [];
417
+ }
418
+
419
+ group.push(val);
420
+ });
421
+
422
+ return grouped;
423
+ }
424
+
425
+
426
+ function uniqueBy(extractor, ...collections) {
427
+
428
+ extractor = toExtractor(extractor);
429
+
430
+ let grouped = {};
431
+
432
+ forEach(collections, (c) => groupBy(c, extractor, grouped));
433
+
434
+ let result = map(grouped, function(val, key) {
435
+ return val[0];
436
+ });
437
+
438
+ return result;
439
+ }
440
+
441
+
442
+ const unionBy = uniqueBy;
443
+
444
+
445
+
446
+ /**
447
+ * Sort collection by criteria.
448
+ *
449
+ * @template T
450
+ *
451
+ * @param {Collection<T>} collection
452
+ * @param {Extractor<T, number | string>} extractor
453
+ *
454
+ * @return {Array}
455
+ */
456
+ function sortBy(collection, extractor) {
457
+
458
+ extractor = toExtractor(extractor);
459
+
460
+ let sorted = [];
461
+
462
+ forEach(collection, function(value, key) {
463
+ let disc = extractor(value, key);
464
+
465
+ let entry = {
466
+ d: disc,
467
+ v: value
468
+ };
469
+
470
+ for (var idx = 0; idx < sorted.length; idx++) {
471
+ let { d } = sorted[idx];
472
+
473
+ if (disc < d) {
474
+ sorted.splice(idx, 0, entry);
475
+ return;
476
+ }
477
+ }
478
+
479
+ // not inserted, append (!)
480
+ sorted.push(entry);
481
+ });
482
+
483
+ return map(sorted, (e) => e.v);
484
+ }
485
+
486
+
487
+ /**
488
+ * Create an object pattern matcher.
489
+ *
490
+ * @example
491
+ *
492
+ * ```javascript
493
+ * const matcher = matchPattern({ id: 1 });
494
+ *
495
+ * let element = find(elements, matcher);
496
+ * ```
497
+ *
498
+ * @template T
499
+ *
500
+ * @param {T} pattern
501
+ *
502
+ * @return { (el: any) => boolean } matcherFn
503
+ */
504
+ function matchPattern(pattern) {
505
+
506
+ return function(el) {
507
+
508
+ return every(pattern, function(val, key) {
509
+ return el[key] === val;
510
+ });
511
+
512
+ };
513
+ }
514
+
515
+
516
+ /**
517
+ * @param {string | ((e: any) => any) } extractor
518
+ *
519
+ * @return { (e: any) => any }
520
+ */
521
+ function toExtractor(extractor) {
522
+
523
+ /**
524
+ * @satisfies { (e: any) => any }
525
+ */
526
+ return isFunction(extractor) ? extractor : (e) => {
527
+
528
+ // @ts-ignore: just works
529
+ return e[extractor];
530
+ };
531
+ }
532
+
533
+
534
+ /**
535
+ * @template T
536
+ * @param {Matcher<T>} matcher
537
+ *
538
+ * @return {MatchFn<T>}
539
+ */
540
+ function toMatcher(matcher) {
541
+ return isFunction(matcher) ? matcher : (e) => {
542
+ return e === matcher;
543
+ };
544
+ }
545
+
546
+
547
+ function identity(arg) {
548
+ return arg;
549
+ }
550
+
551
+ function toNum(arg) {
552
+ return Number(arg);
553
+ }
554
+
555
+ /* global setTimeout clearTimeout */
556
+
557
+ /**
558
+ * @typedef { {
559
+ * (...args: any[]): any;
560
+ * flush: () => void;
561
+ * cancel: () => void;
562
+ * } } DebouncedFunction
563
+ */
564
+
565
+ /**
566
+ * Debounce fn, calling it only once if the given time
567
+ * elapsed between calls.
568
+ *
569
+ * Lodash-style the function exposes methods to `#clear`
570
+ * and `#flush` to control internal behavior.
571
+ *
572
+ * @param {Function} fn
573
+ * @param {Number} timeout
574
+ *
575
+ * @return {DebouncedFunction} debounced function
576
+ */
577
+ function debounce(fn, timeout) {
578
+
579
+ let timer;
580
+
581
+ let lastArgs;
582
+ let lastThis;
583
+
584
+ let lastNow;
585
+
586
+ function fire(force) {
587
+
588
+ let now = Date.now();
589
+
590
+ let scheduledDiff = force ? 0 : (lastNow + timeout) - now;
591
+
592
+ if (scheduledDiff > 0) {
593
+ return schedule(scheduledDiff);
594
+ }
595
+
596
+ fn.apply(lastThis, lastArgs);
597
+
598
+ clear();
599
+ }
600
+
601
+ function schedule(timeout) {
602
+ timer = setTimeout(fire, timeout);
603
+ }
604
+
605
+ function clear() {
606
+ if (timer) {
607
+ clearTimeout(timer);
608
+ }
609
+
610
+ timer = lastNow = lastArgs = lastThis = undefined;
611
+ }
612
+
613
+ function flush() {
614
+ if (timer) {
615
+ fire(true);
616
+ }
617
+
618
+ clear();
619
+ }
620
+
621
+ /**
622
+ * @type { DebouncedFunction }
623
+ */
624
+ function callback(...args) {
625
+ lastNow = Date.now();
626
+
627
+ lastArgs = args;
628
+ lastThis = this;
629
+
630
+ // ensure an execution is scheduled
631
+ if (!timer) {
632
+ schedule(timeout);
633
+ }
634
+ }
635
+
636
+ callback.flush = flush;
637
+ callback.cancel = clear;
638
+
639
+ return callback;
640
+ }
641
+
642
+ /**
643
+ * Throttle fn, calling at most once
644
+ * in the given interval.
645
+ *
646
+ * @param {Function} fn
647
+ * @param {Number} interval
648
+ *
649
+ * @return {Function} throttled function
650
+ */
651
+ function throttle(fn, interval) {
652
+ let throttling = false;
653
+
654
+ return function(...args) {
655
+
656
+ if (throttling) {
657
+ return;
658
+ }
659
+
660
+ fn(...args);
661
+ throttling = true;
662
+
663
+ setTimeout(() => {
664
+ throttling = false;
665
+ }, interval);
666
+ };
667
+ }
668
+
669
+ /**
670
+ * Bind function against target <this>.
671
+ *
672
+ * @param {Function} fn
673
+ * @param {Object} target
674
+ *
675
+ * @return {Function} bound function
676
+ */
677
+ function bind(fn, target) {
678
+ return fn.bind(target);
679
+ }
680
+
681
+ /**
682
+ * Convenience wrapper for `Object.assign`.
683
+ *
684
+ * @param {Object} target
685
+ * @param {...Object} others
686
+ *
687
+ * @return {Object} the target
688
+ */
689
+ function assign(target, ...others) {
690
+ return Object.assign(target, ...others);
691
+ }
692
+
693
+ /**
694
+ * Sets a nested property of a given object to the specified value.
695
+ *
696
+ * This mutates the object and returns it.
697
+ *
698
+ * @template T
699
+ *
700
+ * @param {T} target The target of the set operation.
701
+ * @param {(string|number)[]} path The path to the nested value.
702
+ * @param {any} value The value to set.
703
+ *
704
+ * @return {T}
705
+ */
706
+ function set(target, path, value) {
707
+
708
+ let currentTarget = target;
709
+
710
+ forEach(path, function(key, idx) {
711
+
712
+ if (typeof key !== 'number' && typeof key !== 'string') {
713
+ throw new Error('illegal key type: ' + typeof key + '. Key should be of type number or string.');
714
+ }
715
+
716
+ if (key === 'constructor') {
717
+ throw new Error('illegal key: constructor');
718
+ }
719
+
720
+ if (key === '__proto__') {
721
+ throw new Error('illegal key: __proto__');
722
+ }
723
+
724
+ let nextKey = path[idx + 1];
725
+ let nextTarget = currentTarget[key];
726
+
727
+ if (isDefined(nextKey) && isNil(nextTarget)) {
728
+ nextTarget = currentTarget[key] = isNaN(+nextKey) ? {} : [];
729
+ }
730
+
731
+ if (isUndefined(nextKey)) {
732
+ if (isUndefined(value)) {
733
+ delete currentTarget[key];
734
+ } else {
735
+ currentTarget[key] = value;
736
+ }
737
+ } else {
738
+ currentTarget = nextTarget;
739
+ }
740
+ });
741
+
742
+ return target;
743
+ }
744
+
745
+
746
+ /**
747
+ * Gets a nested property of a given object.
748
+ *
749
+ * @param {Object} target The target of the get operation.
750
+ * @param {(string|number)[]} path The path to the nested value.
751
+ * @param {any} [defaultValue] The value to return if no value exists.
752
+ *
753
+ * @return {any}
754
+ */
755
+ function get(target, path, defaultValue) {
756
+
757
+ let currentTarget = target;
758
+
759
+ forEach(path, function(key) {
760
+
761
+ // accessing nil property yields <undefined>
762
+ if (isNil(currentTarget)) {
763
+ currentTarget = undefined;
764
+
765
+ return false;
766
+ }
767
+
768
+ currentTarget = currentTarget[key];
769
+ });
770
+
771
+ return isUndefined(currentTarget) ? defaultValue : currentTarget;
772
+ }
773
+
774
+ /**
775
+ * Pick properties from the given target.
776
+ *
777
+ * @template T
778
+ * @template {any[]} V
779
+ *
780
+ * @param {T} target
781
+ * @param {V} properties
782
+ *
783
+ * @return Pick<T, V>
784
+ */
785
+ function pick(target, properties) {
786
+
787
+ let result = {};
788
+
789
+ let obj = Object(target);
790
+
791
+ forEach(properties, function(prop) {
792
+
793
+ if (prop in obj) {
794
+ result[prop] = target[prop];
795
+ }
796
+ });
797
+
798
+ return result;
799
+ }
800
+
801
+ /**
802
+ * Pick all target properties, excluding the given ones.
803
+ *
804
+ * @template T
805
+ * @template {any[]} V
806
+ *
807
+ * @param {T} target
808
+ * @param {V} properties
809
+ *
810
+ * @return {Omit<T, V>} target
811
+ */
812
+ function omit(target, properties) {
813
+
814
+ let result = {};
815
+
816
+ let obj = Object(target);
817
+
818
+ forEach(obj, function(prop, key) {
819
+
820
+ if (properties.indexOf(key) === -1) {
821
+ result[key] = prop;
822
+ }
823
+ });
824
+
825
+ return result;
826
+ }
827
+
828
+ /**
829
+ * Recursively merge `...sources` into given target.
830
+ *
831
+ * Does support merging objects; does not support merging arrays.
832
+ *
833
+ * @param {Object} target
834
+ * @param {...Object} sources
835
+ *
836
+ * @return {Object} the target
837
+ */
838
+ function merge(target, ...sources) {
839
+
840
+ if (!sources.length) {
841
+ return target;
842
+ }
843
+
844
+ forEach(sources, function(source) {
845
+
846
+ // skip non-obj sources, i.e. null
847
+ if (!source || !isObject(source)) {
848
+ return;
849
+ }
850
+
851
+ forEach(source, function(sourceVal, key) {
852
+
853
+ if (key === '__proto__') {
854
+ return;
855
+ }
856
+
857
+ let targetVal = target[key];
858
+
859
+ if (isObject(sourceVal)) {
860
+
861
+ if (!isObject(targetVal)) {
862
+
863
+ // override target[key] with object
864
+ targetVal = {};
865
+ }
866
+
867
+ target[key] = merge(targetVal, sourceVal);
868
+ } else {
869
+ target[key] = sourceVal;
870
+ }
871
+
872
+ });
873
+ });
874
+
875
+ return target;
876
+ }
877
+
878
+ exports.assign = assign;
879
+ exports.bind = bind;
880
+ exports.debounce = debounce;
881
+ exports.ensureArray = ensureArray;
882
+ exports.every = every;
883
+ exports.filter = filter;
884
+ exports.find = find;
885
+ exports.findIndex = findIndex;
886
+ exports.flatten = flatten;
887
+ exports.forEach = forEach;
888
+ exports.get = get;
889
+ exports.groupBy = groupBy;
890
+ exports.has = has;
891
+ exports.isArray = isArray;
892
+ exports.isDefined = isDefined;
893
+ exports.isFunction = isFunction;
894
+ exports.isNil = isNil;
895
+ exports.isNumber = isNumber;
896
+ exports.isObject = isObject;
897
+ exports.isString = isString;
898
+ exports.isUndefined = isUndefined;
899
+ exports.keys = keys;
900
+ exports.map = map;
901
+ exports.matchPattern = matchPattern;
902
+ exports.merge = merge;
903
+ exports.omit = omit;
904
+ exports.pick = pick;
905
+ exports.reduce = reduce;
906
+ exports.set = set;
907
+ exports.size = size;
908
+ exports.some = some;
909
+ exports.sortBy = sortBy;
910
+ exports.throttle = throttle;
911
+ exports.unionBy = unionBy;
912
+ exports.uniqueBy = uniqueBy;
913
+ exports.values = values;
914
+ exports.without = without;
915
+
916
+ }));