UNPKG

@qntm-code/utils

Version:

A collection of useful utility functions with associated TypeScript types. All functions have been unit tested.

23 lines (22 loc) 876 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.difference = void 0; const index_js_1 = require("../index.js"); /** * Creates an array of array values not included in the other given array using isEqual for equality comparisons. The order and references * of result values are determined by the first array. */ function difference(array, values) { if (!array.length || !values.length) { return []; } return array.reduce((result, item) => { if (!values.some(value => (0, index_js_1.isEqual)(item, value))) { // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call result.push(item); } // eslint-disable-next-line @typescript-eslint/no-unsafe-return return result; }, []); } exports.difference = difference;