Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tiny-decoders

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tiny-decoders - npm Package Compare versions

Comparing version 11.0.0 to 12.0.0

62

index.d.ts

@@ -35,2 +35,6 @@ export type Decoder<T, U = unknown> = (value: U) => T;

optional?: boolean | undefined;
tag?: {
decoded: string;
encoded: string;
} | undefined;
};

@@ -51,9 +55,49 @@ type FieldsMapping = Record<string, Decoder<any> | Field<any, FieldMeta>>;

}): Decoder<InferFields<Mapping>>;
export declare function field<Decoded, const Meta extends FieldMeta>(decoder: Decoder<Decoded>, meta: Meta): Field<Decoded, Meta>;
type Values<T> = T[keyof T];
export declare function fieldsUnion<T extends Record<string, Decoder<unknown>>>(key: string, mapping: keyof T extends string ? keyof T extends never ? "fieldsUnion must have at least one member" : T : {
[P in keyof T]: P extends number ? "fieldsUnion keys must be strings, not numbers" : T[P];
}): Decoder<Expand<Values<{
[P in keyof T]: T[P] extends Decoder<infer U, infer _> ? U : never;
}>>>;
export declare function field<Decoded, const Meta extends Omit<FieldMeta, "tag">>(decoder: Decoder<Decoded>, meta: Meta): Field<Decoded, Meta>;
type InferFieldsUnion<MappingsUnion extends FieldsMapping> = MappingsUnion extends any ? InferFields<MappingsUnion> : never;
type Variant<DecodedCommonField extends number | string | symbol> = Record<DecodedCommonField, Field<any, {
tag: {
decoded: string;
encoded: string;
};
}>> & Record<string, Decoder<any> | Field<any, FieldMeta>>;
export declare function fieldsUnion<const DecodedCommonField extends keyof Variants[number], Variants extends readonly [
Variant<DecodedCommonField>,
...ReadonlyArray<Variant<DecodedCommonField>>
]>(decodedCommonField: DecodedCommonField, variants: Variants, { exact }?: {
exact?: "allow extra" | "throw";
}): Decoder<InferFieldsUnion<Variants[number]>>;
export declare function tag<const Decoded extends string>(decoded: Decoded): Field<Decoded, {
tag: {
decoded: string;
encoded: string;
};
}>;
export declare function tag<const Decoded extends string, const Encoded extends string>(decoded: Decoded, options: {
renameTagFrom: Encoded;
}): Field<Decoded, {
tag: {
decoded: string;
encoded: string;
};
}>;
export declare function tag<const Decoded extends string, const EncodedFieldName extends string>(decoded: Decoded, options: {
renameFieldFrom: EncodedFieldName;
}): Field<Decoded, {
renameFrom: EncodedFieldName;
tag: {
decoded: string;
encoded: string;
};
}>;
export declare function tag<const Decoded extends string, const Encoded extends string, const EncodedFieldName extends string>(decoded: Decoded, options: {
renameTagFrom: Encoded;
renameFieldFrom: EncodedFieldName;
}): Field<Decoded, {
renameFrom: EncodedFieldName;
tag: {
decoded: string;
encoded: string;
};
}>;
export declare function tuple<T extends Array<unknown>>(mapping: [...{

@@ -121,2 +165,6 @@ [P in keyof T]: Decoder<T[P]>;

} | {
tag: "wrong tag";
expected: string;
got: string;
} | {
tag: "array";

@@ -123,0 +171,0 @@ got: unknown;

2

package.json
{
"name": "tiny-decoders",
"version": "11.0.0",
"version": "12.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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc