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 7.0.1 to 8.0.0

24

index.d.ts

@@ -1,3 +0,3 @@

export declare type Decoder<T, U = unknown> = (value: U) => T;
declare type WithUndefinedAsOptional<T> = T extends Record<string, unknown> ? Expand<{
export type Decoder<T, U = unknown> = (value: U) => T;
type WithUndefinedAsOptional<T> = T extends Record<string, unknown> ? Expand<{
[P in OptionalKeys<T>]?: T[P];

@@ -7,9 +7,9 @@ } & {

}> : T;
declare type RequiredKeys<T> = {
type RequiredKeys<T> = {
[P in keyof T]: undefined extends T[P] ? never : P;
}[keyof T];
declare type OptionalKeys<T> = {
type OptionalKeys<T> = {
[P in keyof T]: undefined extends T[P] ? P : never;
}[keyof T];
declare type Expand<T> = T extends infer O ? {
type Expand<T> = T extends infer O ? {
[K in keyof O]: O[K];

@@ -20,5 +20,3 @@ } : never;

export declare function string(value: unknown): string;
export declare function stringUnion<T extends Record<string, unknown>>(mapping: keyof T extends string ? keyof T extends never ? "stringUnion must have at least one key" : T : {
[P in keyof T]: P extends number ? ["stringUnion keys must be strings, not numbers", never] : T[P];
}): Decoder<keyof T>;
export declare function stringUnion<T extends [string, ...Array<string>]>(variants: readonly [...T]): Decoder<T[number]>;
export declare function array<T>(decoder: Decoder<T>): Decoder<Array<T>>;

@@ -35,3 +33,3 @@ export declare function record<T>(decoder: Decoder<T>): Decoder<Record<string, T>>;

}): Decoder<WithUndefinedAsOptional<T>>;
declare type Values<T> = T[keyof T];
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 : {

@@ -42,3 +40,3 @@ [P in keyof T]: P extends number ? "fieldsUnion keys must be strings, not numbers" : T[P];

}>>>;
export declare function tuple<T extends ReadonlyArray<unknown>>(mapping: readonly [...{
export declare function tuple<T extends Array<unknown>>(mapping: readonly [...{
[P in keyof T]: Decoder<T[P]>;

@@ -60,3 +58,3 @@ }]): Decoder<[...T]>;

export declare function chain<T, U>(decoder: Decoder<T>, next: Decoder<U, T>): Decoder<U>;
export declare type DecoderErrorVariant = {
export type DecoderErrorVariant = {
tag: "custom";

@@ -101,3 +99,3 @@ message: string;

};
declare type Key = number | string;
type Key = number | string;
export declare class DecoderError extends TypeError {

@@ -119,3 +117,3 @@ path: Array<Key>;

}
export declare type ReprOptions = {
export type ReprOptions = {
recurse?: boolean;

@@ -122,0 +120,0 @@ maxArrayChildren?: number;

{
"name": "tiny-decoders",
"version": "7.0.1",
"version": "8.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