Skip to content

Commit

Permalink
Export everything inside dist
Browse files Browse the repository at this point in the history
  • Loading branch information
asd committed Nov 8, 2024
1 parent cf158d9 commit 8c3d742
Show file tree
Hide file tree
Showing 298 changed files with 6,208 additions and 4,348 deletions.
2 changes: 2 additions & 0 deletions dist/anyhow/anyhow.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=anyhow.test.d.ts.map
1 change: 1 addition & 0 deletions dist/anyhow/anyhow.test.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions dist/anyhow/anyhow.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import test from "ava";
import { AnyHow } from "./index.js";
test("Sink error", (t) => {
const anyhowErr = AnyHow.msg("Hi");
const wrappedErr = anyhowErr.wrapWith(() => "Context");
t.is(wrappedErr.toString(), ["Hi", "Context"].join("\n"));
});
test("Separated context", (t) => {
const anyhowErr = AnyHow.msg("Hi");
const wrappedErr = anyhowErr.wrapWith(() => "Context");
const a = wrappedErr.wrapWith(() => "a");
const b = wrappedErr.wrapWith(() => "b");
t.is(wrappedErr.toString(), ["Hi", "Context"].join("\n"));
t.is(a.toString(), ["Hi", "Context", "a"].join("\n"));
t.is(b.toString(), ["Hi", "Context", "b"].join("\n"));
});
2 changes: 1 addition & 1 deletion dist/anyhow/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/convert/result-option.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ export declare const ResultTo: {
};
export declare const ResultFrom: {
ok<T, E>(ok: NewOption<T>, err: () => E): ResultNew<T, E>;
err<T_1, E_1>(err: NewOption<E_1>, ok: () => T_1): ResultNew<E_1, T_1>;
err<T, E>(err: NewOption<E>, ok: () => T): ResultNew<E, T>;
};
export declare const OptionTo: {
ok<T, E>(err: () => E): import("../option/middleware/aggregate.js").MiddlewareAggregator<T, ResultNew<T, E>>;
err<T_1, E_1>(ok: () => T_1): import("../option/middleware/aggregate.js").MiddlewareAggregator<E_1, ResultNew<T_1, E_1>>;
err<T, E>(ok: () => T): import("../option/middleware/aggregate.js").MiddlewareAggregator<E, ResultNew<T, E>>;
};
export declare const OptionFrom: {
result<T, E>(result: ResultNew<T, E>): NewOption<T>;
Expand Down
2 changes: 1 addition & 1 deletion dist/convert/result-option.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions dist/dependency.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=dependency.test.d.ts.map
1 change: 1 addition & 0 deletions dist/dependency.test.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions dist/dependency.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import test from "ava";
import { Err, Ok } from "./result/index.js";
import { NewOption, None, Some } from "./option/index.js";
import { OptionFrom, OptionTo, ResultFrom, ResultTo, } from "./convert/result-option.js";
test(`Circular dependencies resolving`, (t) => {
// Apis
t.true(NewOption.Some(3)
.do(OptionTo.ok(() => 4))
.eq(Ok(3)));
t.true(Err(3).do(ResultTo.option()).eq(None()));
// Froms
t.true(OptionFrom.result(Err(3)).eq(None()));
t.true(ResultFrom.ok(Some(3), () => 4).eq(Ok(3)));
});
2 changes: 2 additions & 0 deletions dist/iter/api/all.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=all.test.d.ts.map
1 change: 1 addition & 0 deletions dist/iter/api/all.test.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions dist/iter/api/all.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import test from "ava";
import { Iter } from "../index.js";
import { all } from "./all.js";
test(`all() truthy if everything valid`, (t) => {
const numbers = Iter.from([1, 2, 3, 4]);
t.true(numbers.do(all((v) => typeof v === "number")));
});
test(`all() falsy if at least one is invalid`, (t) => {
const firstInvalid = Iter.from(["1", 2, 3, 4]);
const middleInvalid = Iter.from([1, "2", 3, 4]);
const lastInvalid = Iter.from([1, 2, 3, "4"]);
const isNumber = all((v) => typeof v === "number");
t.false(firstInvalid.do(isNumber));
t.false(middleInvalid.do(isNumber));
t.false(lastInvalid.do(isNumber));
});
test(`all() truthy on empty sets`, (t) => {
const notAllNumbers = Iter.from([]);
t.true(notAllNumbers.do(all((_) => false)));
});
2 changes: 2 additions & 0 deletions dist/iter/api/any.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=any.test.d.ts.map
1 change: 1 addition & 0 deletions dist/iter/api/any.test.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions dist/iter/api/any.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import test from "ava";
import { Iter } from "../index.js";
import { any } from "./any.js";
test(`any() falsy if everything invalid`, (t) => {
const numbers = Iter.from(["1", "2", "3", "4"]);
t.false(numbers.do(any((v) => typeof v === "number")));
});
test(`any() truthy if at least one is valid`, (t) => {
const firstValid = Iter.from([1, "2", "3", "4"]);
const middleValid = Iter.from(["1", 2, "3", "4"]);
const lastValid = Iter.from(["1", "2", "3", 4]);
const isNumber = any((v) => typeof v === "number");
t.true(firstValid.do(isNumber));
t.true(middleValid.do(isNumber));
t.true(lastValid.do(isNumber));
});
test(`any() falsy on empty sets`, (t) => {
const notAllNumbers = Iter.from([]);
t.false(notAllNumbers.do(any((_) => true)));
});
2 changes: 2 additions & 0 deletions dist/iter/api/chain.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=chain.test.d.ts.map
1 change: 1 addition & 0 deletions dist/iter/api/chain.test.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions dist/iter/api/chain.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import test from "ava";
import { Iter } from "../index.js";
import { chain } from "./chain.js";
import { toArray } from "./to_array.js";
test(`chain() concats two iterables`, (t) => {
const values = Iter.from([1, 2, 3]);
const extraValues = [4, 5, 6];
t.deepEqual(values.do(chain(extraValues)).do(toArray()), [1, 2, 3, 4, 5, 6]);
});
test(`chain() works with empty iterables`, (t) => {
t.deepEqual(Iter.from([1, 2, 3]).do(chain([])).do(toArray()), [1, 2, 3]);
t.deepEqual(Iter.from([])
.do(chain([1, 2, 3]))
.do(toArray()), [1, 2, 3]);
});
2 changes: 2 additions & 0 deletions dist/iter/api/cycle.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=cycle.test.d.ts.map
1 change: 1 addition & 0 deletions dist/iter/api/cycle.test.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions dist/iter/api/cycle.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import test from "ava";
import { Iter } from "../index.js";
import { cycle } from "./cycle.js";
import { NewOption } from "../../option/index.js";
test(`cycle() creates repeated iterator from non-empty iterators`, (t) => {
const iter = Iter.from([1, 2]).do(cycle());
for (const _ of [1, 2, 3, 4, 5]) {
t.true(NewOption.Some(1).eq(iter.next()));
t.true(NewOption.Some(2).eq(iter.next()));
}
});
test(`cycle() creates empty iterator from empty iterator`, (t) => {
const emptyIter = Iter.from([]).do(cycle());
for (const _ of [1, 2, 3, 4, 5]) {
t.true(NewOption.None().eq(emptyIter.next()));
}
});
2 changes: 2 additions & 0 deletions dist/iter/api/enumerate.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=enumerate.test.d.ts.map
1 change: 1 addition & 0 deletions dist/iter/api/enumerate.test.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions dist/iter/api/enumerate.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import test from "ava";
import { Iter } from "../index.js";
import { enumerate } from "./enumerate.js";
test(`enumerate() does not mutate original iter`, (t) => {
const numbers = [3, 4, 5, 6];
const iter = Iter.from(numbers);
// Clone test: initial iter should be untouched
const enumeratedIter = iter.do(enumerate());
const enumeratedValues = numbers.map((item, index) => ({ item, index }));
t.deepEqual(Array.from(iter), [3, 4, 5, 6]);
t.deepEqual(Array.from(enumeratedIter), enumeratedValues);
});
2 changes: 2 additions & 0 deletions dist/iter/api/eq.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=eq.test.d.ts.map
1 change: 1 addition & 0 deletions dist/iter/api/eq.test.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions dist/iter/api/eq.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import test from "ava";
import { Iter } from "../index.js";
import { eq } from "./eq.js";
test(`eq() truthy on equal iterators`, (t) => {
t.true(Iter.from([1, 2]).do(eq(Iter.from([1, 2]))));
t.false(Iter.from([1, 2]).do(eq(Iter.from([1, 2, 3]))));
t.false(Iter.from([1, 2, 3]).do(eq(Iter.from([1, 2]))));
t.false(Iter.from([1]).do(eq(Iter.from([2]))));
t.true(Iter.from([]).do(eq(Iter.from([]))));
});
test(`eq(by) remaps values if "by" provided`, (t) => {
const iterOne = Iter.from([{ a: 1 }, { a: 2 }]);
const iterTwo = Iter.from([{ a: 1 }, { a: 2 }]);
const iterThree = Iter.from([{ a: 1 }, { a: 2 }, { a: 3 }]);
t.true(iterOne.do(eq(iterTwo, (v) => v.a)));
t.false(iterOne.do(eq(iterThree, (v) => v.a)));
});
2 changes: 2 additions & 0 deletions dist/iter/api/filter.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=filter.test.d.ts.map
1 change: 1 addition & 0 deletions dist/iter/api/filter.test.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions dist/iter/api/filter.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import test from "ava";
import { Iter } from "../index.js";
import { nativeRange } from "../iter-test-tools.js";
import { filter } from "./filter.js";
test(`filter() should return only elements that satisfy the condition`, (t) => {
const evenValues = nativeRange(0, 10).filter((v) => v % 2 === 0);
const oddValues = nativeRange(0, 10).filter((v) => v % 2 !== 0);
const iter = Iter.fromRange(0, 10);
// Clone test: initial iter should be untouched
const evenIter = iter.do(filter((v) => v % 2 === 0));
const oddIter = iter.do(filter((v) => v % 2 !== 0));
t.deepEqual([...evenIter], evenValues);
t.deepEqual([...oddIter], oddValues);
});
2 changes: 2 additions & 0 deletions dist/iter/api/filter_map.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=filter_map.test.d.ts.map
1 change: 1 addition & 0 deletions dist/iter/api/filter_map.test.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions dist/iter/api/filter_map.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import test from "ava";
import { Iter } from "../index.js";
import { nativeRange } from "../iter-test-tools.js";
import { filterMap } from "./filter_map.js";
import { NewOption } from "../../option/index.js";
test(`.filterMap()`, (t) => {
const evenValues = nativeRange(0, 10).filter((v) => v % 2 === 0);
const oddValues = nativeRange(0, 10).filter((v) => v % 2 !== 0);
const iter = Iter.fromRange(0, 10);
function even(v) {
return v % 2 === 0 ? NewOption.Some(v) : NewOption.None();
}
function odd(v) {
return v % 2 !== 0 ? NewOption.Some(v) : NewOption.None();
}
// Clone test: initial iter should be untouched
const evenIter = iter.do(filterMap(even));
const oddIter = iter.do(filterMap(odd));
t.deepEqual([...evenIter], evenValues);
t.deepEqual([...oddIter], oddValues);
});
2 changes: 2 additions & 0 deletions dist/iter/api/find.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=find.test.d.ts.map
1 change: 1 addition & 0 deletions dist/iter/api/find.test.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions dist/iter/api/find.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import test from "ava";
import { useSpy } from "../../testutils/spy.js";
import { Iter } from "../index.js";
import { enumerate } from "./enumerate.js";
import { find } from "./find.js";
test("find() should return first element found by condition", (t) => {
const condition = useSpy((v) => v.item === 2);
const iter = Iter.from([1, 2, 3, 4, 2]).do(enumerate());
t.deepEqual(iter.do(find(condition.spy)).unwrap(), { item: 2, index: 1 });
t.is(condition.calledTimes(), 2);
});
test("find() should return none if element not found", (t) => {
const iter = Iter.from([1, 2, 3, 4, 2]);
t.truthy(iter.do(find((v) => v === 7)).isNone());
});
test("find() should return none on empty iter", (t) => {
const iter = Iter.from([]);
t.truthy(iter.do(find((_) => true)).isNone());
});
2 changes: 2 additions & 0 deletions dist/iter/api/find_map.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=find_map.test.d.ts.map
1 change: 1 addition & 0 deletions dist/iter/api/find_map.test.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions dist/iter/api/find_map.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import test from "ava";
import { Iter } from "../index.js";
import { findMap } from "./find_map.js";
import { NewOption } from "../../option/index.js";
test(`.findMap()`, (t) => {
const iter = Iter.fromRange(0, 10);
const valueIfEq = (to) => {
return (v) => {
return v === to ? NewOption.Some("value") : NewOption.None();
};
};
t.true(iter.do(findMap(valueIfEq(5))).eq(NewOption.Some("value")));
t.true(iter.do(findMap(valueIfEq(100))).eq(NewOption.None()));
});
2 changes: 2 additions & 0 deletions dist/iter/api/first.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=first.test.d.ts.map
1 change: 1 addition & 0 deletions dist/iter/api/first.test.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions dist/iter/api/first.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import test from "ava";
import { Iter } from "../index.js";
import { first } from "./first.js";
import { cycle } from "./cycle.js";
import { NewOption } from "../../option/index.js";
test(`first() should return first element`, (t) => {
t.true(Iter.from([1, 2, 3]).do(first()).eq(NewOption.Some(1)));
});
test(`first() should return none on empty iter`, (t) => {
t.true(Iter.from([]).do(first()).isNone());
});
test(`first() should return first-element on infinite iter`, (t) => {
t.true(Iter.from([1, 2, 3]).do(cycle()).do(first()).eq(NewOption.Some(1)));
});
2 changes: 2 additions & 0 deletions dist/iter/api/flat_map.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=flat_map.test.d.ts.map
1 change: 1 addition & 0 deletions dist/iter/api/flat_map.test.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions dist/iter/api/flat_map.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import test from "ava";
import { Iter } from "../index.js";
import { flatMap } from "./flat_map.js";
import { toArray } from "./to_array.js";
test(`flatMap() flattens inner iterable by 1 level`, (t) => {
const iter = Iter.from([1, 2, [3]]);
t.deepEqual(iter.do(flatMap((v) => [v])).do(toArray()), [1, 2, [3]]);
});
test(`flatMap() flattens inner Iter`, (t) => {
const iter = Iter.from([[1], [2], [3]]);
t.deepEqual(iter.do(flatMap(Iter.from)).do(toArray()), [1, 2, 3]);
});
2 changes: 2 additions & 0 deletions dist/iter/api/flatten.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=flatten.test.d.ts.map
1 change: 1 addition & 0 deletions dist/iter/api/flatten.test.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions dist/iter/api/flatten.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import test from "ava";
import { Iter } from "../index.js";
import { toArray } from "./to_array.js";
import { flatten } from "./flatten.js";
test(`flatten() flattens inner iterable`, (t) => {
const iter = Iter.from([[1], [2], [3]]);
t.deepEqual(iter.do(flatten()).do(toArray()), [1, 2, 3]);
});
test(`flatten() flattens inner Iter`, (t) => {
const iter = Iter.from([[1], [2], [3]]).do(Iter.from);
t.deepEqual(iter.do(flatten()).do(toArray()), [1, 2, 3]);
});
test(`flatten() works on empty iters`, (t) => {
const iter = Iter.from([[1], [], [3]]);
t.deepEqual(iter.do(flatten()).do(toArray()), [1, 3]);
});
test(`flatten() typecheck: should work only on Iter<Iterable<T>>`, (t) => {
const iter = Iter.from([[1], 2, [3]]);
// @ts-expect-error
iter.do(flatten());
t.pass();
});
2 changes: 2 additions & 0 deletions dist/iter/api/fold.test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=fold.test.d.ts.map
1 change: 1 addition & 0 deletions dist/iter/api/fold.test.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8c3d742

Please sign in to comment.