Function without

Returns an array with value(s) omitted. If value is not found, result will be a copy of input. Value checking is completed via the provided comparer function. By default checking whether a === b. To compare based on value, use the isEqualValueDefault comparer.

import { Arrays } from 'https://unpkg.com/ixfx/dist/data.js';

const data = [100, 20, 40];
const filtered = Arrays.without(data, 20); // [100, 40]
import { Arrays } from 'https://unpkg.com/ixfx/dist/data.js';

const data = [{name: `Alice`}, {name:`Sam`}];

// This wouldn't work as expected, because the default comparer uses instance,
// not value:
Arrays.without(data, {name: `Alice`});

// So instead we can use a value comparer:
Arrays.without(data, {name:`Alice`}, isEqualValueDefault);
import { Arrays } from 'https://unpkg.com/ixfx/dist/data.js';

const data = [{name: `Alice`}, {name:`Sam`}];
Arrays.without(data, {name:`ALICE`}, (a, b) => {
return (a.name.toLowerCase() === b.name.toLowerCase());
});

Consider remove to remove an item by index.

  • Type Parameters

    • V

      Type of array items

    Parameters

    • sourceArray: readonly V[] | V[]

      Source array

    • toRemove: V | V[]

      Value(s) to remove

    • comparer: IsEqual<V> = isEqualDefault

      Comparison function. If not provided Util.isEqualDefault is used, which compares using ===

    Returns V[]

    Copy of array without value.