@aicacia/core
v0.2.13
Published
aicacia core utils
Downloads
389
Readme
ts-core
aicacia core utils
Options
import { Option, none } from "@aicacia/core";
const maybe = none<number>();
if (maybe.isNone()) {
maybe.replace(1);
}
console.log(maybe.unwrap()); // 1
Result
import { Result, ok, err } from "@aicacia/core";
fetch("/api")
.then((res) => ok(res))
.catch((e) => err<Response>(e))
.then((result) => {
if (result.isOk()) {
console.log(result.unwrap());
} else {
console.error(result.unwrapErr());
}
});
Iter
import { iter } from "@aicacia/core";
const evens = iter([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
.map((x) => x * x)
.filter((x) => x % 2 === 0);
for (const value of evens) {
console.log(value);
}