main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
925 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | var _isArrayLike =
|
---|
| 2 | /*#__PURE__*/
|
---|
| 3 | require("./_isArrayLike.js");
|
---|
| 4 |
|
---|
| 5 | var symIterator = typeof Symbol !== 'undefined' ? Symbol.iterator : '@@iterator';
|
---|
| 6 |
|
---|
| 7 | function _createReduce(arrayReduce, methodReduce, iterableReduce) {
|
---|
| 8 | return function _reduce(xf, acc, list) {
|
---|
| 9 | if (_isArrayLike(list)) {
|
---|
| 10 | return arrayReduce(xf, acc, list);
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 | if (list == null) {
|
---|
| 14 | return acc;
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | if (typeof list['fantasy-land/reduce'] === 'function') {
|
---|
| 18 | return methodReduce(xf, acc, list, 'fantasy-land/reduce');
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | if (list[symIterator] != null) {
|
---|
| 22 | return iterableReduce(xf, acc, list[symIterator]());
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | if (typeof list.next === 'function') {
|
---|
| 26 | return iterableReduce(xf, acc, list);
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | if (typeof list.reduce === 'function') {
|
---|
| 30 | return methodReduce(xf, acc, list, 'reduce');
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | throw new TypeError('reduce: list must be array or iterable');
|
---|
| 34 | };
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | module.exports = _createReduce; |
---|
Note:
See
TracBrowser
for help on using the repository browser.