UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

39 lines (38 loc) 1.37 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.pullAllBy = void 0; const basePullAll_1 = __importDefault(require("./.internal/basePullAll")); /** * This method is like `pullAll` except that it accepts `iteratee` which is * invoked for each element of `array` and `values` to generate the criterion * by which they're compared. The iteratee is invoked with one argument: (value). * * **Note:** Unlike `differenceBy`, this method mutates `array`. * * @since 5.11.0 * @category Array * @param array The array to modify. * @param values The values to remove. * @param iteratee The iteratee invoked per element. * @returns Returns `array`. * @see [[pull]], [[pullAll]], [[pullAllWith]], [[pullAt]], [[remove]], [[reject]] * @example * * ```js * const array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }] * * pullAllBy(array, [{ 'x': 1 }, { 'x': 3 }], 'x') * console.log(array) * // => [{ 'x': 2 }] * ``` */ function pullAllBy(array, values, iteratee) { return (array != null && array.length && values != null && values.length) ? (0, basePullAll_1.default)(array, values, iteratee) : array; } exports.pullAllBy = pullAllBy; exports.default = pullAllBy;