UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

29 lines (28 loc) 857 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.countBy = void 0; const baseAssignValue_1 = __importDefault(require("./.internal/baseAssignValue")); const createAggregator_1 = __importDefault(require("./.internal/createAggregator")); /** * @ignore */ const hasOwnProperty = Object.prototype.hasOwnProperty; /** * @ignore */ const internalCountBy = (0, createAggregator_1.default)((result, value, key) => { if (hasOwnProperty.call(result, key)) { ++result[key]; } else { (0, baseAssignValue_1.default)(result, key, 1); } }); function countBy(...args) { return internalCountBy(...args); } exports.countBy = countBy; exports.default = countBy;