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 6.0.1 to 7.0.0

28

index.d.ts

@@ -1,2 +0,2 @@

export declare type Decoder<T, U = unknown> = (value: U, errors?: Array<DecoderError>) => T;
export declare type Decoder<T, U = unknown> = (value: U) => T;
declare type WithUndefinedAsOptional<T> = T extends Record<string, unknown> ? Expand<{

@@ -19,21 +19,9 @@ [P in OptionalKeys<T>]?: T[P];

export declare function string(value: unknown): string;
export declare function stringUnion<T extends Record<string, null>>(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" : T[P];
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 array<T, U = never>(decoder: Decoder<T>, { mode }?: {
mode?: "skip" | "throw" | {
default: U;
};
}): Decoder<Array<T | U>>;
export declare function record<T, U = never>(decoder: Decoder<T>, { mode }?: {
mode?: "skip" | "throw" | {
default: U;
};
}): Decoder<Record<string, T | U>>;
export declare function fields<T>(callback: (field: <U, V = never>(key: string, decoder: Decoder<U>, options?: {
mode?: "throw" | {
default: V;
};
}) => U | V, object: Record<string, unknown>, errors?: Array<DecoderError>) => T, { exact, allow, }?: {
exact?: "allow extra" | "push" | "throw";
export declare function array<T>(decoder: Decoder<T>): Decoder<Array<T>>;
export declare function record<T>(decoder: Decoder<T>): Decoder<Record<string, T>>;
export declare function fields<T>(callback: (field: <U>(key: string, decoder: Decoder<U>) => U, object: Record<string, unknown>) => T, { exact, allow, }?: {
exact?: "allow extra" | "throw";
allow?: "array" | "object";

@@ -44,3 +32,3 @@ }): Decoder<WithUndefinedAsOptional<T>>;

}, { exact }?: {
exact?: "allow extra" | "push" | "throw";
exact?: "allow extra" | "throw";
}): Decoder<WithUndefinedAsOptional<T>>;

@@ -47,0 +35,0 @@ declare type Values<T> = T[keyof T];

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