@webalternatif/js-core 1.2.0 → 1.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.
package/dist/cjs/dom.js CHANGED
@@ -4,26 +4,51 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
4
4
  function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
5
5
  function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
6
6
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
7
- import { isArray, isArrayLike, isObject, isString } from "./is.js";
7
+ import { isArray, isArrayLike, isFunction, isObject, isPlainObject, isString } from "./is.js";
8
8
  import { camelCase } from "./string.js";
9
9
  import { each, foreach, map } from "./traversal.js";
10
10
  import { inArray } from "./array.js";
11
11
  var cssNumber = ['animationIterationCount', 'aspectRatio', 'borderImageSlice', 'columnCount', 'flexGrow', 'flexShrink', 'fontWeight', 'gridArea', 'gridColumn', 'gridColumnEnd', 'gridColumnStart', 'gridRow', 'gridRowEnd', 'gridRowStart', 'lineHeight', 'opacity', 'order', 'orphans', 'scale', 'widows', 'zIndex', 'zoom', 'fillOpacity', 'floodOpacity', 'stopOpacity', 'strokeMiterlimit', 'strokeOpacity'];
12
+ var LISTENERS = new WeakMap();
13
+
14
+ /**
15
+ * @param {any} o
16
+ * @returns {boolean}
17
+ */
12
18
  export var isWindow = function isWindow(o) {
13
19
  return !!o && o === o.window;
14
20
  };
21
+
22
+ /**
23
+ * @param {any} o
24
+ * @returns {boolean}
25
+ */
26
+ export var isDocument = function isDocument(o) {
27
+ return !!o && o.nodeType === 9;
28
+ };
29
+
30
+ /**
31
+ * @param {any} o
32
+ * @returns {boolean}
33
+ */
15
34
  export var isDomElement = function isDomElement(o) {
16
35
  return isObject(o) && o instanceof HTMLElement;
17
36
  };
18
- export var getStyle = function getStyle(elem, cssRule) {
19
- if (!isDomElement(elem)) {
37
+
38
+ /**
39
+ * @param {Element} el
40
+ * @param {string} cssRule
41
+ * @returns {string}
42
+ */
43
+ export var getStyle = function getStyle(el, cssRule) {
44
+ if (!isDomElement(el)) {
20
45
  return '';
21
46
  }
22
47
  if (window.getComputedStyle) {
23
- var computedStyle = window.getComputedStyle(elem, null);
48
+ var computedStyle = window.getComputedStyle(el, null);
24
49
  return computedStyle.getPropertyValue(cssRule) || computedStyle[camelCase(cssRule)] || '';
25
50
  }
26
- return elem.style[camelCase(cssRule)] || '';
51
+ return el.style[camelCase(cssRule)] || '';
27
52
  };
28
53
  export default {
29
54
  /**
@@ -74,6 +99,26 @@ export default {
74
99
  }
75
100
  return Array.from(refEl.querySelectorAll(selector));
76
101
  },
102
+ /**
103
+ * @param {Element} el
104
+ * @param {string} data
105
+ * @param {string} value
106
+ * @returns {Element|null}
107
+ */
108
+ findOneByData: function findOneByData(el, data, value) {
109
+ var _this$findByData$;
110
+ return (_this$findByData$ = this.findByData(el, data, value)[0]) !== null && _this$findByData$ !== void 0 ? _this$findByData$ : null;
111
+ },
112
+ /**
113
+ * @param {Element} el
114
+ * @param {string} data
115
+ * @param {string} value
116
+ * @returns {Element[]}
117
+ */
118
+ findByData: function findByData(el, data, value) {
119
+ var escapeValue = CSS.escape(value);
120
+ return this.find(el, "[data-".concat(data, "=\"").concat(escapeValue, "\"]"));
121
+ },
77
122
  /**
78
123
  * @param {Element|NodeList|Array<Element>} el
79
124
  * @param {string} className
@@ -147,26 +192,38 @@ export default {
147
192
  },
148
193
  /**
149
194
  * @param {Node} node
150
- * @param {...Node} children
195
+ * @param {...(Node|string)} children
151
196
  * @returns {Node}
152
197
  */
153
198
  append: function append(node) {
199
+ var _this = this;
154
200
  for (var _len = arguments.length, children = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
155
201
  children[_key - 1] = arguments[_key];
156
202
  }
157
- node.append.apply(node, children);
203
+ foreach(children, function (child) {
204
+ if (isString(child)) {
205
+ child = _this.create(child);
206
+ }
207
+ child && node.append(child);
208
+ });
158
209
  return node;
159
210
  },
160
211
  /**
161
212
  * @param {Node} node
162
- * @param {...Node} children
213
+ * @param {...(Node|string)} children
163
214
  * @returns {Node}
164
215
  */
165
216
  prepend: function prepend(node) {
217
+ var _this2 = this;
166
218
  for (var _len2 = arguments.length, children = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
167
219
  children[_key2 - 1] = arguments[_key2];
168
220
  }
169
- node.prepend.apply(node, children);
221
+ foreach(children, function (child) {
222
+ if (isString(child)) {
223
+ child = _this2.create(child);
224
+ }
225
+ child && node.prepend(child);
226
+ });
170
227
  return node;
171
228
  },
172
229
  /**
@@ -174,7 +231,7 @@ export default {
174
231
  * @returns {void}
175
232
  */
176
233
  remove: function remove() {
177
- var _this = this;
234
+ var _this3 = this;
178
235
  for (var _len3 = arguments.length, els = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
179
236
  els[_key3] = arguments[_key3];
180
237
  }
@@ -186,7 +243,7 @@ export default {
186
243
  return e.remove();
187
244
  });
188
245
  } else {
189
- _this.remove(_this.find(el));
246
+ _this3.remove(_this3.find(el));
190
247
  }
191
248
  });
192
249
  },
@@ -411,13 +468,13 @@ export default {
411
468
  * @returns {Element|DOMStringMap}
412
469
  */
413
470
  data: function data(el, name, value) {
414
- var _this2 = this;
471
+ var _this4 = this;
415
472
  if (undefined === name && undefined === value) {
416
473
  return el.dataset;
417
474
  }
418
- if (webf.isPlainObject(name)) {
419
- webf.each(name, function (k, v) {
420
- return _this2.data(el, k, v);
475
+ if (isPlainObject(name)) {
476
+ each(name, function (k, v) {
477
+ return _this4.data(el, k, v);
421
478
  });
422
479
  return el;
423
480
  }
@@ -443,25 +500,94 @@ export default {
443
500
  },
444
501
  /**
445
502
  * @param {Element|Document|Window} el
446
- * @param {string} event
447
- * @param {function} handler
448
- * @param {AddEventListenerOptions|false} options
503
+ * @param {string} events
504
+ * @param {string|Element|function} selector
505
+ * @param {function|AddEventListenerOptions|boolean} [handler]
506
+ * @param {AddEventListenerOptions|boolean} [options]
449
507
  * @returns {Element}
450
508
  */
451
- on: function on(el, event, handler) {
452
- var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
453
- el.addEventListener(event, handler, options);
509
+ on: function on(el, events, selector, handler, options) {
510
+ var _this5 = this;
511
+ if (isFunction(selector)) {
512
+ options = handler;
513
+ handler = selector;
514
+ selector = null;
515
+ }
516
+ foreach(events.split(' '), function (event) {
517
+ var listener = function listener(ev) {
518
+ if (!selector) {
519
+ handler.call(el, ev);
520
+ return;
521
+ }
522
+ var currentTarget = ev.target;
523
+ while (currentTarget && currentTarget !== el) {
524
+ if (_this5.matches(currentTarget, selector)) {
525
+ var wrappedEv = Object.assign({}, ev, {
526
+ originalEvent: ev,
527
+ type: ev.type,
528
+ currentTarget: currentTarget,
529
+ target: ev.target,
530
+ relatedTarget: ev.relatedTarget,
531
+ button: ev.button,
532
+ pageX: ev.pageX,
533
+ pageY: ev.pageY,
534
+ preventDefault: function preventDefault() {
535
+ return ev.preventDefault.apply(ev, arguments);
536
+ },
537
+ stopPropagation: function stopPropagation() {
538
+ return ev.stopPropagation.apply(ev, arguments);
539
+ },
540
+ stopImmediatePropagation: function stopImmediatePropagation() {
541
+ return ev.stopImmediatePropagation.apply(ev, arguments);
542
+ }
543
+ });
544
+ handler.call(currentTarget, wrappedEv);
545
+ break;
546
+ }
547
+ currentTarget = currentTarget.parentElement;
548
+ }
549
+ };
550
+ var store = LISTENERS.get(el);
551
+ if (!store) {
552
+ store = [];
553
+ LISTENERS.set(el, store);
554
+ }
555
+ store.push({
556
+ event: event,
557
+ handler: handler,
558
+ selector: selector,
559
+ listener: listener,
560
+ options: options
561
+ });
562
+ el.addEventListener(event, listener, options);
563
+ });
454
564
  return el;
455
565
  },
456
566
  /**
457
567
  * @param {Element|Document|Window} el
458
- * @param {string} event
459
- * @param {function} handler
460
- * @param {Object} options
568
+ * @param {string} events
569
+ * @param {string|Element|function} selector
570
+ * @param {function|AddEventListenerOptions|boolean} [handler]
571
+ * @param {AddEventListenerOptions|boolean} [options]
461
572
  * @returns {Element}
462
573
  */
463
- off: function off(el, event, handler, options) {
464
- el.removeEventListener(event, handler, options);
574
+ off: function off(el, events, selector, handler, options) {
575
+ if (isFunction(selector)) {
576
+ options = handler;
577
+ handler = selector;
578
+ selector = null;
579
+ }
580
+ var store = LISTENERS.get(el);
581
+ if (!store) return el;
582
+ foreach(events.split(' '), function (event) {
583
+ each(_toConsumableArray(store).reverse(), function (i, l) {
584
+ if (l.event === event && l.handler === handler && l.selector === selector && (options === undefined || l.options === options)) {
585
+ el.removeEventListener(event, l.listener, l.options);
586
+ var index = store.indexOf(l);
587
+ index !== -1 && store.splice(index, 1);
588
+ }
589
+ });
590
+ });
465
591
  return el;
466
592
  },
467
593
  /**
@@ -471,7 +597,7 @@ export default {
471
597
  * @returns {Element}
472
598
  */
473
599
  css: function css(el, style, value) {
474
- var _this3 = this;
600
+ var _this6 = this;
475
601
  if (isString(style)) {
476
602
  var prop = style.startsWith('--') ? style : camelCase(style);
477
603
  if (undefined === value) {
@@ -485,7 +611,7 @@ export default {
485
611
  }
486
612
  } else {
487
613
  each(style, function (name, v) {
488
- _this3.css(el, name, v);
614
+ _this6.css(el, name, v);
489
615
  });
490
616
  }
491
617
  return el;
@@ -517,19 +643,22 @@ export default {
517
643
  return null;
518
644
  },
519
645
  /**
520
- * @param {NodeList} nodeList
646
+ * @param {NodeList|Element|Array<Element>} nodeList
521
647
  * @returns {Element|null}
522
648
  */
523
649
  first: function first(nodeList) {
524
- return nodeList !== null && nodeList !== void 0 && nodeList.length ? nodeList.item(0) : null;
650
+ var _Array$from$;
651
+ if (nodeList instanceof Element) return nodeList;
652
+ return (_Array$from$ = Array.from(nodeList)[0]) !== null && _Array$from$ !== void 0 ? _Array$from$ : null;
525
653
  },
526
654
  /**
527
655
  * @param {NodeList|Array<Element>} nodeList
528
656
  * @returns {Element|null}
529
657
  */
530
658
  last: function last(nodeList) {
531
- var arr = Array.from(nodeList)[0];
532
- return arr[arr.length - 1];
659
+ var _arr;
660
+ var arr = Array.from(nodeList);
661
+ return (_arr = arr[arr.length - 1]) !== null && _arr !== void 0 ? _arr : null;
533
662
  },
534
663
  /**
535
664
  * @param {string} html
@@ -542,32 +671,42 @@ export default {
542
671
  return (_tpl$content$firstEle = tpl.content.firstElementChild) !== null && _tpl$content$firstEle !== void 0 ? _tpl$content$firstEle : null;
543
672
  },
544
673
  /**
545
- * @param {NodeList} nodeList
674
+ * @param {NodeList|Array<Element>} nodeList
546
675
  * @param {number} [index=0]
547
676
  * @returns {Element|null}
548
677
  */
549
678
  eq: function eq(nodeList) {
679
+ var _nodeList$index;
550
680
  var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
681
+ nodeList = Array.from(nodeList);
551
682
  if (Math.abs(index) >= nodeList.length) return null;
552
683
  if (index < 0) {
553
684
  index = nodeList.length + index;
554
685
  }
555
- return nodeList.item(index);
686
+ return (_nodeList$index = nodeList[index]) !== null && _nodeList$index !== void 0 ? _nodeList$index : null;
556
687
  },
557
688
  /**
558
689
  * @param {Element} el
559
- * @param {Element} newEl
560
- * @returns {Element}
690
+ * @param {Element|string} newEl
691
+ * @returns {Element|null}
561
692
  */
562
693
  after: function after(el, newEl) {
694
+ if (!el.parentElement) return null;
695
+ if (isString(newEl)) {
696
+ newEl = this.create(newEl);
697
+ }
563
698
  return el.parentElement.insertBefore(newEl, el.nextElementSibling);
564
699
  },
565
700
  /**
566
701
  * @param {Element} el
567
- * @param {Element} newEl
568
- * @returns {Element}
702
+ * @param {Element|string} newEl
703
+ * @returns {Element|null}
569
704
  */
570
705
  before: function before(el, newEl) {
706
+ if (!el.parentElement) return null;
707
+ if (isString(newEl)) {
708
+ newEl = this.create(newEl);
709
+ }
571
710
  return el.parentElement.insertBefore(newEl, el);
572
711
  },
573
712
  /**
@@ -592,5 +731,65 @@ export default {
592
731
  if (!(e instanceof Element)) return false;
593
732
  return selectorIsString ? !e.matches(selector) : e !== selector;
594
733
  });
734
+ },
735
+ /**
736
+ * @param {Element} elem1
737
+ * @param {Element} elem2
738
+ * @returns {boolean}
739
+ */
740
+ collide: function collide(elem1, elem2) {
741
+ var rect1 = elem1.getBoundingClientRect();
742
+ var rect2 = elem2.getBoundingClientRect();
743
+ return rect1.x < rect2.x + rect2.width && rect1.x + rect1.width > rect2.x && rect1.y < rect2.y + rect2.height && rect1.y + rect1.height > rect2.y;
744
+ },
745
+ /**
746
+ * @param {Element} el
747
+ * @param {string|Element} selector
748
+ */
749
+ matches: function matches(el, selector) {
750
+ return selector instanceof Element ? selector === el : el.matches(selector);
751
+ },
752
+ /**
753
+ * @param {Element} el
754
+ * @param {Element} child
755
+ * @param {Element} oldChild
756
+ */
757
+ replaceChild: function replaceChild(el, child, oldChild) {
758
+ return el.replaceChild(child, oldChild);
759
+ },
760
+ /**
761
+ * @param {Element} el
762
+ * @param {Element[]} children
763
+ * @returns {Element}
764
+ */
765
+ replaceChildren: function replaceChildren(el) {
766
+ for (var _len4 = arguments.length, children = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
767
+ children[_key4 - 1] = arguments[_key4];
768
+ }
769
+ el.replaceChildren.apply(el, children);
770
+ return el;
771
+ },
772
+ /**
773
+ * @param {Element|Document|Window} el
774
+ * @returns {{top: number, left: number}}
775
+ */
776
+ offset: function offset(el) {
777
+ if (isWindow(el)) {
778
+ return {
779
+ top: el.scrollY,
780
+ left: el.scrollX
781
+ };
782
+ } else if (isDocument(el)) {
783
+ return {
784
+ top: el.documentElement.scrollTop,
785
+ left: el.documentElement.scrollLeft
786
+ };
787
+ }
788
+ var rect = el.getBoundingClientRect();
789
+ var wOffset = this.offset(window);
790
+ return {
791
+ top: rect.top + wOffset.top,
792
+ left: rect.left + wOffset.left
793
+ };
595
794
  }
596
795
  };
package/dist/cjs/index.js CHANGED
@@ -7,19 +7,22 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
7
7
  import * as stringFunctions from './string.js';
8
8
  import './stringPrototype.js';
9
9
  import * as arrayFunctions from './array.js';
10
+ import * as is from './is.js';
11
+ import * as random from './random.js';
10
12
  import * as traversal from './traversal.js';
11
- import dom, { getStyle, isDomElement, isWindow } from './dom.js';
13
+ import dom, { getStyle, isDomElement, isWindow, isDocument } from './dom.js';
12
14
  import * as math from './math.js';
13
15
  import * as utils from './utils.js';
14
16
  import * as i18n from './i18n.js';
15
17
  import eventDispatcher from './eventDispatcher.js';
16
- var webf = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, stringFunctions), arrayFunctions), traversal), {}, {
18
+ var webf = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, stringFunctions), arrayFunctions), traversal), is), random), {}, {
17
19
  dom: dom,
18
20
  isWindow: isWindow,
21
+ isDocument: isDocument,
19
22
  isDomElement: isDomElement,
20
23
  getStyle: getStyle
21
24
  }, math), utils), i18n), {}, {
22
25
  eventDispatcher: eventDispatcher
23
26
  });
24
27
  export default webf;
25
- export { stringFunctions, arrayFunctions, traversal, getStyle, dom, math, utils, eventDispatcher };
28
+ export { stringFunctions, arrayFunctions, traversal, is, random, getStyle, dom, math, utils, eventDispatcher };
@@ -1,20 +1,17 @@
1
- export var uniqid = function uniqid() {
2
- return randAlpha(10);
3
- };
4
1
  export var randAlpha = function randAlpha(n) {
5
- return rand("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z".split(','), n);
2
+ return rand("abcdefghijklmnopqrstuvwxyz".split(''), n);
6
3
  };
7
4
  export var randAlphaCs = function randAlphaCs(n) {
8
- return rand("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z".split(','), n);
5
+ return rand("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split(''), n);
9
6
  };
10
7
  export var randAlphaNum = function randAlphaNum(n) {
11
- return rand("0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z".split(','), n);
8
+ return rand("0123456789abcdefghijklmnopqrstuvwxyz".split(''), n);
12
9
  };
13
10
  export var randAlphaNumCs = function randAlphaNumCs(n) {
14
- return rand("0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z".split(','), n);
11
+ return rand("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".split(''), n);
15
12
  };
16
13
  export var randNum = function randNum(n) {
17
- return rand("0,1,2,3,4,5,6,7,8,9".split(','), n);
14
+ return rand("0123456789".split(''), n);
18
15
  };
19
16
  export var rand = function rand(range, n) {
20
17
  var rand = "";
@@ -22,4 +19,12 @@ export var rand = function rand(range, n) {
22
19
  rand += range[Math.floor(Math.random() * 1000) % range.length];
23
20
  }
24
21
  return rand;
25
- };
22
+ };
23
+ export var uniqid = function () {
24
+ var uid = 0;
25
+ return function () {
26
+ var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
27
+ uid++;
28
+ return "".concat(prefix).concat(Date.now().toString(36), "_").concat(uid.toString(36), "_").concat(randAlphaNum(5));
29
+ };
30
+ }();
@@ -318,13 +318,41 @@ export var escapeRegex = function escapeRegex(str) {
318
318
  return str.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&").replace(/[\n\t]/g, " ");
319
319
  };
320
320
  export var camelCase = function camelCase(str) {
321
- foreach('-_', function (_char5) {
322
- str = trim(str, _char5).replace(new RegExp("".concat(_char5, "+"), 'g'), _char5);
323
- });
324
- str = trim(str).replace(/\s+/g, '-');
325
- return str.toLowerCase().replace(/[_-](\w)/g, function (match, p1) {
326
- return p1.toUpperCase();
327
- });
321
+ if (!str) return '';
322
+ var prev = '';
323
+ var prevReplaced = false;
324
+ var prevIsSeparator = false;
325
+ var prevIsUpperCase = false;
326
+ str = trim(str);
327
+ str = trim(str, '_');
328
+ str = trim(str, '-');
329
+ var isUpperCase = function isUpperCase(c) {
330
+ return c === c.toUpperCase() && c !== c.toLowerCase();
331
+ };
332
+ var isSeparator = function isSeparator(c) {
333
+ return c === '-' || c === '_' || c === ' ';
334
+ };
335
+ return map(str, function (i, c) {
336
+ prevIsSeparator = isSeparator(prev);
337
+ prevIsUpperCase = isUpperCase(prev);
338
+ prev = c;
339
+ if (isSeparator(c)) {
340
+ return null;
341
+ } else if (prevIsSeparator) {
342
+ c = c.toUpperCase();
343
+ prevReplaced = true;
344
+ } else if (isUpperCase(c)) {
345
+ if (i === 0) {
346
+ c = c.toLowerCase();
347
+ } else if (prevIsUpperCase && !prevReplaced) {
348
+ c = c.toLowerCase();
349
+ }
350
+ prevReplaced = false;
351
+ } else {
352
+ prevReplaced = false;
353
+ }
354
+ return c;
355
+ }).join('');
328
356
  };
329
357
  export var format = function format(str) {
330
358
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
@@ -36,7 +36,7 @@ export var each = function each(o, callback, context) {
36
36
  var arr = o.split('');
37
37
  for (var _i = 0; _i < arr.length; _i++) if (false === callback.call(context !== null && context !== void 0 ? context : arr[_i], _i, arr[_i], o, _i)) return;
38
38
  return o;
39
- } else if (o instanceof Map) {
39
+ } else if (o instanceof Map || o instanceof WeakMap) {
40
40
  var _index = 0;
41
41
  var _iterator = _createForOfIteratorHelper(o.entries()),
42
42
  _step;
@@ -105,7 +105,7 @@ export var foreach = function foreach(o, callback, context) {
105
105
  * @param {Collection<T>} o
106
106
  * @param {(key: number|string, value: T, o: Collection<T>, index: number) => (R|null|false)} callback
107
107
  * @param {any} [context] Optional "this" binding for the callback
108
- * @returns {Array} Returns the resulted array
108
+ * @returns {Array<R>} Returns the resulted array
109
109
  */
110
110
  export var map = function map(o, callback, context) {
111
111
  var results = [];