UNPKG

ts-prime

Version:

A utility library for JavaScript and Typescript.

27 lines (26 loc) 836 B
import { difference } from './difference'; import { pipe } from './pipe'; import { take } from './take'; import { map } from './map'; var source = [1, 2, 3, 4]; var other = [2, 5, 3]; var expected = [1, 4]; describe('data_first', function () { test('should return difference', function () { expect(difference(source, other)).toEqual(expected); }); }); describe('data_last', function () { test('should return difference', function () { expect(difference(other)(source)).toEqual(expected); }); test('lazy', function () { var count = jest.fn(); var result = pipe([1, 2, 3, 4, 5, 6], map(function (x) { count(); return x; }), difference([2, 3]), take(2)); expect(count).toHaveBeenCalledTimes(4); expect(result).toEqual([1, 4]); }); });