source: node_modules/ramda/es/internal/_createReduce.js

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: 888 bytes
Line 
1import _isArrayLike from "./_isArrayLike.js";
2var symIterator = typeof Symbol !== 'undefined' ? Symbol.iterator : '@@iterator';
3export default function _createReduce(arrayReduce, methodReduce, iterableReduce) {
4 return function _reduce(xf, acc, list) {
5 if (_isArrayLike(list)) {
6 return arrayReduce(xf, acc, list);
7 }
8
9 if (list == null) {
10 return acc;
11 }
12
13 if (typeof list['fantasy-land/reduce'] === 'function') {
14 return methodReduce(xf, acc, list, 'fantasy-land/reduce');
15 }
16
17 if (list[symIterator] != null) {
18 return iterableReduce(xf, acc, list[symIterator]());
19 }
20
21 if (typeof list.next === 'function') {
22 return iterableReduce(xf, acc, list);
23 }
24
25 if (typeof list.reduce === 'function') {
26 return methodReduce(xf, acc, list, 'reduce');
27 }
28
29 throw new TypeError('reduce: list must be array or iterable');
30 };
31}
Note: See TracBrowser for help on using the repository browser.