@newdash/newdash
Version:
javascript/typescript utility library
38 lines (37 loc) • 1.43 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.difference = void 0;
const baseDifference_1 = __importDefault(require("./.internal/baseDifference"));
const baseFlatten_1 = __importDefault(require("./.internal/baseFlatten"));
const isArrayLikeObject_1 = __importDefault(require("./isArrayLikeObject"));
/**
* Creates an array of `array` values not included in the other given arrays
* using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons. The order and references of result values are
* determined by the first array.
*
* **Note:** Unlike `pullAll`, this method returns a new array.
*
* @since 5.9.0
* @category Array
* @param array The array to inspect.
* @param values The values to exclude.
* @returns Returns the new array of filtered values.
* @see union, unionBy, unionWith, without, xor, xorBy, xorWith,
* @example
*
* ```js
* difference([2, 1], [2, 3])
* // => [1]
* ```
*/
function difference(array, ...values) {
return (0, isArrayLikeObject_1.default)(array)
? (0, baseDifference_1.default)(array, (0, baseFlatten_1.default)(values, 1, isArrayLikeObject_1.default, true))
: [];
}
exports.difference = difference;
exports.default = difference;