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

neverthrow

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

neverthrow - npm Package Compare versions

Comparing version 5.1.0 to 6.0.0

22

dist/index.d.ts

@@ -30,4 +30,4 @@ interface ErrorConfig {

declare const fromSafePromise: typeof ResultAsync.fromSafePromise;
declare type CombineResultAsyncs<T> = TraverseAsync<UnwrapAsync<T>>;
declare type CombineResultsWithAllErrorsArrayAsync<T> = TraverseWithAllErrorsAsync<UnwrapAsync<T>>;
declare type CombineResultAsyncs<T extends readonly ResultAsync<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseAsync<UnwrapAsync<T>> : ResultAsync<ExtractOkAsyncTypes<T>, ExtractErrAsyncTypes<T>[number]>;
declare type CombineResultsWithAllErrorsArrayAsync<T extends readonly ResultAsync<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseWithAllErrorsAsync<UnwrapAsync<T>> : ResultAsync<ExtractOkAsyncTypes<T>, ExtractErrAsyncTypes<T>[number][]>;
declare type UnwrapAsync<T> = IsLiteralArray<T> extends 1 ? Writable<T> extends [infer H, ...infer Rest] ? H extends PromiseLike<infer HI> ? HI extends Result<unknown, unknown> ? [Dedup<HI>, ...UnwrapAsync<Rest>] : never : never : [] : T extends Array<infer A> ? A extends PromiseLike<infer HI> ? HI extends Result<infer L, infer R> ? Ok<L, R>[] : never : never : never;

@@ -38,2 +38,14 @@ declare type TraverseAsync<T, Depth extends number = 5> = IsLiteralArray<T> extends 1 ? Combine<T, Depth> extends [infer Oks, infer Errs] ? ResultAsync<EmptyArrayToNever<Oks>, MembersToUnion<Errs>> : never : T extends Array<infer I> ? Combine<MemberListOf<I>, Depth> extends [infer Oks, infer Errs] ? Oks extends unknown[] ? Errs extends unknown[] ? ResultAsync<EmptyArrayToNever<Oks[number][]>, MembersToUnion<Errs[number][]>> : ResultAsync<EmptyArrayToNever<Oks[number][]>, Errs> : Errs extends unknown[] ? ResultAsync<Oks, MembersToUnion<Errs[number][]>> : ResultAsync<Oks, Errs> : never : never;

declare type ExtractOkTypes<T extends readonly Result<unknown, unknown>[]> = {
[idx in keyof T]: T[idx] extends Result<infer U, unknown> ? U : never;
};
declare type ExtractOkAsyncTypes<T extends readonly ResultAsync<unknown, unknown>[]> = {
[idx in keyof T]: T[idx] extends ResultAsync<infer U, unknown> ? U : never;
};
declare type ExtractErrTypes<T extends readonly Result<unknown, unknown>[]> = {
[idx in keyof T]: T[idx] extends Result<unknown, infer E> ? E : never;
};
declare type ExtractErrAsyncTypes<T extends readonly ResultAsync<unknown, unknown>[]> = {
[idx in keyof T]: T[idx] extends ResultAsync<unknown, infer E> ? E : never;
};
declare type InferOkTypes<R> = R extends Result<infer T, unknown> ? T : never;

@@ -245,3 +257,3 @@ declare type InferErrTypes<R> = R extends Result<unknown, infer E> ? E : never;

infer R
] ? [UnknownMembersToNever<L>, UnknownMembersToNever<R>] : never;
] ? [UnknownMembersToNever<L>, UnknownMembersToNever<R>] : Transpose<CollectResults<T>, [], Depth> extends [] ? [[], []] : never;
declare type Dedup<T> = T extends Result<infer RL, infer RR> ? [unknown] extends [RL] ? Err<RL, RR> : Ok<RL, RR> : T;

@@ -260,5 +272,5 @@ declare type MemberListOf<T> = ((T extends unknown ? (t: T) => T : never) extends infer U ? (U extends unknown ? (u: U) => unknown : never) extends (v: infer V) => unknown ? V : never : never) extends (_: unknown) => infer W ? [...MemberListOf<Exclude<T, W>>, W] : [];

] ? Result<EmptyArrayToNever<Oks>, EmptyArrayToNever<Errs>> : never;
declare type CombineResults<T> = T extends ReadonlyArray<infer U> ? IsLiteralArray<T> extends 1 ? Traverse<T> : Traverse<MemberListOf<Dedup<U>>> extends Result<infer L, infer R> ? Result<L, EmptyArrayToNever<R>> : never : never;
declare type CombineResultsWithAllErrorsArray<T extends readonly Result<unknown, unknown>[]> = T extends ReadonlyArray<infer U> ? IsLiteralArray<T> extends 1 ? TraverseWithAllErrors<T> : TraverseWithAllErrors<MemberListOf<Dedup<U>>> extends Result<infer L, infer R> ? Result<EmptyArrayToNever<L>, EmptyArrayToNever<R>> : never : never;
declare type CombineResults<T extends readonly Result<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? Traverse<T> : Result<ExtractOkTypes<T>, ExtractErrTypes<T>[number]>;
declare type CombineResultsWithAllErrorsArray<T extends readonly Result<unknown, unknown>[]> = IsLiteralArray<T> extends 1 ? TraverseWithAllErrors<T> : Result<ExtractOkTypes<T>, ExtractErrTypes<T>[number][]>;
export { Err, Ok, Result, ResultAsync, err, errAsync, fromPromise, fromSafePromise, fromThrowable, ok, okAsync };
{
"name": "neverthrow",
"version": "5.1.0",
"version": "6.0.0",
"description": "Stop throwing errors, and instead return Results!",

@@ -5,0 +5,0 @@ "main": "dist/index.cjs.js",

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