UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

18 lines (17 loc) 894 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.reduce = void 0; const arrayReduce_1 = __importDefault(require("./.internal/arrayReduce")); const baseEach_1 = __importDefault(require("./.internal/baseEach")); const baseReduce_1 = __importDefault(require("./.internal/baseReduce")); const getIteratee_1 = __importDefault(require("./.internal/getIteratee")); function reduce(collection, iteratee, accumulator) { const func = Array.isArray(collection) ? arrayReduce_1.default : baseReduce_1.default; const initialValue = arguments.length < 3; return func(collection, (0, getIteratee_1.default)(iteratee, 4), accumulator, initialValue, baseEach_1.default); } exports.reduce = reduce; exports.default = reduce;