axax
Version:
A library of async iterator extensions for JavaScript including ```map```, ```reduce```, ```filter```, ```flatMap```, ```pipe``` and [more](https://github.com/jamiemccrindle/axax/blob/master/docs/API.md#functions).
22 lines (21 loc) • 941 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const last_1 = require("../last");
const of_1 = require("../of");
const toArray_1 = require("../toArray");
test("last", async () => {
const result = await toArray_1.toArray(last_1.last()(of_1.of(1, 2, 3, 4, 5, 6, 7)));
expect(result).toEqual([7]);
});
test("last with predicate", async () => {
const result = await toArray_1.toArray(last_1.last((value) => value % 2 === 0)(of_1.of(1, 2, 3, 4, 5, 6, 7)));
expect(result).toEqual([6]);
});
test("last with no value fulfilling predicate", async () => {
const result = await toArray_1.toArray(last_1.last((value) => value % 8 === 0)(of_1.of(1, 2, 3, 4, 5, 6)));
expect(result).toEqual([]);
});
test("last with default value", async () => {
const result = await toArray_1.toArray(last_1.last((value) => value % 8 === 0, 42)(of_1.of(1, 2, 3, 4, 5, 6)));
expect(result).toEqual([42]);
});