Releases: numfin/kirka
Releases · numfin/kirka
v2.9.0 Expose union _tag and _value for debugging
Schema.union({}).parse(...) // { ...unionmethods, _tag: ..., _value: ... }
v2.7.0 Create schema equal to value
Schema.str("value") // Schema<"value">
Schema.num(0) // Schema<0>
Schema.bool(true) // Schema<true>
v2.5.0 Much easier to debug and use type system for schemas
Now every Schema.dict()/.union()/.arr()...etc will have a lot more simpler typings:
Instead of:
FromSchema<Record<string, FromSchema...>> ...
We now have:
SchemaDict<{
s: string;
n: number;
b: boolean;
}, ...>
Enjoy :)
v2.4.0 Refactoring for Schema.arr() and Schema.dict()
Generics now much simpler, and easier to understand. Just a quality of life change
v2.3.0 Result.match()
Minor tweaks, Schema.union() tests and Result.match()
v2.2.0 Schema validations like in zod
Implemented and tested Schema module for validating external data
Example
const s = Schema.num();
const v: Result<number> = s.parse(...);
// Parse unknown value to union
const innerUnion = Schema.union({
v3v1: Schema.arr(Schema.num()),
v3v2: Schema.str()
});
const tUnion = Schema.union({
v1: Schema.num(),
v2: Schema.str(),
v3: innerUnion
});
const parsedValue: UnionInstance<...> = tUnion.parse(...);
// Or create union instance yourself
const v1 = tUnion.v1(10);
const v2 = tUnion.v2("hi");
const v3v1 = tUnion.v3(innerUnion.v3v1([42]));
const v3v2 = tUnion.v3(innerUnion.v3v2("qwerty"));
const v = v1.match({
v1: (v) => 1, // all returns must have same type
v2: (v) => 2,
v3: (v) => 3,
}); // 1
const v = v2.matchSome({
v2: (v) => 2
}); // Some(2)
const isV3 = v3.is("v3") // true
v1.0.3 moduleResolution: nodeNext
version bump 1.0.3
v1.0.0 - Initial release
Iter<T>
- lazy iterators
Option<T>
- optional values
Result<T, E>
- error workflows workarounds