Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replicate support array and array #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions __tests__/classic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import { take } from "../src";
describe.only("classic iterable list", () => {
it("fibonacci", () => {
const fibs = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55];
expect([...L.take(10, fibonacci]).toEqual(fibs);

expect([...L.take(10, fibonacci)]).toEqual(fibs);
});

it.only("primes", () => {
// const primesLst = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29];
console.time();
console.log(...take(10000, primes);
console.log(...take(10000, primes));
console.timeEnd();
});
});
17 changes: 16 additions & 1 deletion __tests__/generators.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,22 @@ describe("iterable list generators", () => {
});

it("replicate", () => {
expect(Array.from(L.replicate(10, 5))).toEqual([10, 10, 10, 10, 10]);
expect(Array.from(L.replicate([8, [10, 12]], 5))).toEqual([
[8, [10, 12]],
[8, [10, 12]],
[8, [10, 12]],
[8, [10, 12]],
[8, [10, 12]]
]);
expect(Array.from(L.replicate([1], 2))).toEqual([
[1],
[1]
]);
expect(Array.from(L.replicate(7, 2))).toEqual([7, 7]);
expect(Array.from(L.replicate({ name: '1', age: '2' }, 2))).toEqual([
{ name: '1', age: '2' },
{ name: '1', age: '2' }
]);
});

it("random", () => {
Expand Down
Loading