server-json/node_modules/ramda/es/internal/_createReduce.js
2024-11-01 08:00:42 +00:00

25 lines
No EOL
882 B
JavaScript

import _isArrayLike from "./_isArrayLike.js";
var symIterator = typeof Symbol !== 'undefined' ? Symbol.iterator : '@@iterator';
export default function _createReduce(arrayReduce, methodReduce, iterableReduce) {
return function _reduce(xf, acc, list) {
if (_isArrayLike(list)) {
return arrayReduce(xf, acc, list);
}
if (list == null) {
return acc;
}
if (typeof list['fantasy-land/reduce'] === 'function') {
return methodReduce(xf, acc, list, 'fantasy-land/reduce');
}
if (list[symIterator] != null) {
return iterableReduce(xf, acc, list[symIterator]());
}
if (typeof list.next === 'function') {
return iterableReduce(xf, acc, list);
}
if (typeof list.reduce === 'function') {
return methodReduce(xf, acc, list, 'reduce');
}
throw new TypeError('reduce: list must be array or iterable');
};
}