tiny-decoders
Advanced tools
Comparing version 19.0.0 to 20.0.0
@@ -22,4 +22,6 @@ export type Codec<Decoded, Encoded = unknown> = { | ||
export declare const number: Codec<number, number>; | ||
export declare const bigint: Codec<bigint, bigint>; | ||
export declare const string: Codec<string, string>; | ||
export declare function stringUnion<const Variants extends readonly [string, ...Array<string>]>(variants: Variants): Codec<Variants[number], Variants[number]>; | ||
type primitive = bigint | boolean | number | string | symbol | null | undefined; | ||
export declare function primitiveUnion<const Variants extends readonly [primitive, ...Array<primitive>]>(variants: Variants): Codec<Variants[number], Variants[number]>; | ||
export declare function array<DecodedItem, EncodedItem>(codec: Codec<DecodedItem, EncodedItem>): Codec<Array<DecodedItem>, Array<EncodedItem>>; | ||
@@ -34,4 +36,4 @@ export declare function record<DecodedValue, EncodedValue>(codec: Codec<DecodedValue, EncodedValue>): Codec<Record<string, DecodedValue>, Record<string, EncodedValue>>; | ||
tag?: { | ||
decoded: string; | ||
encoded: string; | ||
decoded: primitive; | ||
encoded: primitive; | ||
} | undefined; | ||
@@ -72,4 +74,4 @@ }; | ||
tag: { | ||
decoded: string; | ||
encoded: string; | ||
decoded: primitive; | ||
encoded: primitive; | ||
}; | ||
@@ -86,17 +88,17 @@ }>> & Record<string, Codec<any> | Field<any, any, FieldMeta>>; | ||
}): Codec<InferFieldsUnion<Variants[number]>, InferEncodedFieldsUnion<Variants[number]>>; | ||
export declare function tag<const Decoded extends string>(decoded: Decoded): Field<Decoded, Decoded, { | ||
export declare function tag<const Decoded extends primitive>(decoded: Decoded): Field<Decoded, Decoded, { | ||
tag: { | ||
decoded: string; | ||
encoded: string; | ||
decoded: primitive; | ||
encoded: primitive; | ||
}; | ||
}>; | ||
export declare function tag<const Decoded extends string, const Encoded extends string>(decoded: Decoded, options: { | ||
export declare function tag<const Decoded extends primitive, const Encoded extends primitive>(decoded: Decoded, options: { | ||
renameTagFrom: Encoded; | ||
}): Field<Decoded, Encoded, { | ||
tag: { | ||
decoded: string; | ||
encoded: string; | ||
decoded: primitive; | ||
encoded: primitive; | ||
}; | ||
}>; | ||
export declare function tag<const Decoded extends string, const EncodedFieldName extends string>(decoded: Decoded, options: { | ||
export declare function tag<const Decoded extends primitive, const EncodedFieldName extends string>(decoded: Decoded, options: { | ||
renameFieldFrom: EncodedFieldName; | ||
@@ -106,7 +108,7 @@ }): Field<Decoded, Decoded, { | ||
tag: { | ||
decoded: string; | ||
encoded: string; | ||
decoded: primitive; | ||
encoded: primitive; | ||
}; | ||
}>; | ||
export declare function tag<const Decoded extends string, const Encoded extends string, const EncodedFieldName extends string>(decoded: Decoded, options: { | ||
export declare function tag<const Decoded extends primitive, const Encoded extends primitive, const EncodedFieldName extends string>(decoded: Decoded, options: { | ||
renameTagFrom: Encoded; | ||
@@ -117,4 +119,4 @@ renameFieldFrom: EncodedFieldName; | ||
tag: { | ||
decoded: string; | ||
encoded: string; | ||
decoded: primitive; | ||
encoded: primitive; | ||
}; | ||
@@ -145,5 +147,14 @@ }>; | ||
value: number; | ||
} : Types extends "bigint" ? { | ||
type: "bigint"; | ||
value: bigint; | ||
} : Types extends "string" ? { | ||
type: "string"; | ||
value: string; | ||
} : Types extends "symbol" ? { | ||
type: "symbol"; | ||
value: symbol; | ||
} : Types extends "function" ? { | ||
type: "function"; | ||
value: Function; | ||
} : Types extends "array" ? { | ||
@@ -156,3 +167,3 @@ type: "array"; | ||
} : never : never; | ||
type MultiTypeName = "array" | "boolean" | "null" | "number" | "object" | "string" | "undefined"; | ||
type MultiTypeName = "array" | "bigint" | "boolean" | "function" | "null" | "number" | "object" | "string" | "symbol" | "undefined"; | ||
export declare function multi<Types extends readonly [MultiTypeName, ...Array<MultiTypeName>]>(types: Types): Codec<Multi<Types[number]>, Multi<Types[number]>["value"]>; | ||
@@ -191,4 +202,4 @@ export declare function recursive<Decoded, Encoded>(callback: () => Codec<Decoded, Encoded>): Codec<Decoded, Encoded>; | ||
tag: "unknown fieldsUnion tag"; | ||
knownTags: Array<string>; | ||
got: string; | ||
knownTags: Array<primitive>; | ||
got: unknown; | ||
} | { | ||
@@ -199,9 +210,9 @@ tag: "unknown multi type"; | ||
} | { | ||
tag: "unknown stringUnion variant"; | ||
knownVariants: Array<string>; | ||
got: string; | ||
tag: "unknown primitiveUnion variant"; | ||
knownVariants: Array<primitive>; | ||
got: unknown; | ||
} | { | ||
tag: "wrong tag"; | ||
expected: string; | ||
got: string; | ||
expected: primitive; | ||
got: unknown; | ||
} | { | ||
@@ -211,2 +222,5 @@ tag: "array"; | ||
} | { | ||
tag: "bigint"; | ||
got: unknown; | ||
} | { | ||
tag: "boolean"; | ||
@@ -213,0 +227,0 @@ got: unknown; |
{ | ||
"name": "tiny-decoders", | ||
"version": "19.0.0", | ||
"version": "20.0.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "author": "Simon Lydell", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65957
1697