source: imaps-frontend/node_modules/lodash-es/differenceBy.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 1.5 KB
Line 
1import baseDifference from './_baseDifference.js';
2import baseFlatten from './_baseFlatten.js';
3import baseIteratee from './_baseIteratee.js';
4import baseRest from './_baseRest.js';
5import isArrayLikeObject from './isArrayLikeObject.js';
6import last from './last.js';
7
8/**
9 * This method is like `_.difference` except that it accepts `iteratee` which
10 * is invoked for each element of `array` and `values` to generate the criterion
11 * by which they're compared. The order and references of result values are
12 * determined by the first array. The iteratee is invoked with one argument:
13 * (value).
14 *
15 * **Note:** Unlike `_.pullAllBy`, this method returns a new array.
16 *
17 * @static
18 * @memberOf _
19 * @since 4.0.0
20 * @category Array
21 * @param {Array} array The array to inspect.
22 * @param {...Array} [values] The values to exclude.
23 * @param {Function} [iteratee=_.identity] The iteratee invoked per element.
24 * @returns {Array} Returns the new array of filtered values.
25 * @example
26 *
27 * _.differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor);
28 * // => [1.2]
29 *
30 * // The `_.property` iteratee shorthand.
31 * _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
32 * // => [{ 'x': 2 }]
33 */
34var differenceBy = baseRest(function(array, values) {
35 var iteratee = last(values);
36 if (isArrayLikeObject(iteratee)) {
37 iteratee = undefined;
38 }
39 return isArrayLikeObject(array)
40 ? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true), baseIteratee(iteratee, 2))
41 : [];
42});
43
44export default differenceBy;
Note: See TracBrowser for help on using the repository browser.