New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@swan-io/boxed

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swan-io/boxed - npm Package Compare versions

Comparing version 0.6.2 to 0.6.3

16

dist/Future.d.ts

@@ -74,3 +74,3 @@ import { Result } from "./OptionResult";

*/
tapOk<Ok, Error>(this: Future<Result<Ok, Error>>, func: (value: Ok) => unknown): Future<Result<Ok, Error>>;
tapOk<A, E>(this: Future<Result<A, E>>, func: (value: A) => unknown): Future<Result<A, E>>;
/**

@@ -81,3 +81,3 @@ * For Future<Result<*>>:

*/
tapError<Ok, Error>(this: Future<Result<Ok, Error>>, func: (value: Error) => unknown): Future<Result<Ok, Error>>;
tapError<A, E>(this: Future<Result<A, E>>, func: (value: E) => unknown): Future<Result<A, E>>;
/**

@@ -88,3 +88,3 @@ * For Future<Result<*>>:

*/
mapResult<Ok, Error, ReturnValue, ReturnError = Error>(this: Future<Result<Ok, Error>>, func: (value: Ok) => Result<ReturnValue, ReturnError>, propagateCancel?: boolean): Future<Result<ReturnValue, ReturnError | Error>>;
mapResult<A, E, B, F = E>(this: Future<Result<A, E>>, func: (value: A) => Result<B, F>, propagateCancel?: boolean): Future<Result<B, F | E>>;
/**

@@ -95,3 +95,3 @@ * For Future<Result<*>>:

*/
mapOk<Ok, Error, ReturnValue>(this: Future<Result<Ok, Error>>, func: (value: Ok) => ReturnValue, propagateCancel?: boolean): Future<Result<ReturnValue, Error>>;
mapOk<A, E, B>(this: Future<Result<A, E>>, func: (value: A) => B, propagateCancel?: boolean): Future<Result<B, E>>;
/**

@@ -102,3 +102,3 @@ * For Future<Result<*>>:

*/
mapError<Ok, Error, ReturnValue>(this: Future<Result<Ok, Error>>, func: (value: Error) => ReturnValue, propagateCancel?: boolean): Future<Result<Ok, ReturnValue>>;
mapError<A, E, B>(this: Future<Result<A, E>>, func: (value: E) => B, propagateCancel?: boolean): Future<Result<A, B>>;
/**

@@ -109,3 +109,3 @@ * For Future<Result<*>>:

*/
flatMapOk<Ok, Error, ReturnValue, ReturnError = Error>(this: Future<Result<Ok, Error>>, func: (value: Ok) => Future<Result<ReturnValue, ReturnError>>, propagateCancel?: boolean): Future<Result<ReturnValue, ReturnError | Error>>;
flatMapOk<A, E, B, F = E>(this: Future<Result<A, E>>, func: (value: A) => Future<Result<B, F>>, propagateCancel?: boolean): Future<Result<B, F | E>>;
/**

@@ -116,3 +116,3 @@ * For Future<Result<*>>:

*/
flatMapError<Ok, Error, ReturnValue, ReturnError>(this: Future<Result<Ok, Error>>, func: (value: Error) => Future<Result<ReturnValue, ReturnError>>, propagateCancel?: boolean): Future<Result<Ok | ReturnValue, ReturnError>>;
flatMapError<A, E, B, F>(this: Future<Result<A, E>>, func: (value: E) => Future<Result<B, F>>, propagateCancel?: boolean): Future<Result<A | B, F>>;
/**

@@ -127,4 +127,4 @@ * Converts the future into a promise

*/
resultToPromise<Ok, Error>(this: Future<Result<Ok, Error>>): Promise<Ok>;
resultToPromise<A, E>(this: Future<Result<A, E>>): Promise<A>;
}
export {};

@@ -115,28 +115,28 @@ export declare class Option<A> {

}
export declare class Result<Ok, Error> {
export declare class Result<A, E> {
/**
* Create an Result.Ok value
*/
static Ok: <Ok_1, Error_1>(ok: Ok_1) => Result<Ok_1, Error_1>;
static Ok: <A_1, E_1>(ok: A_1) => Result<A_1, E_1>;
/**
* Create an Result.Error value
*/
static Error: <Ok_1, Error_1>(error: Error_1) => Result<Ok_1, Error_1>;
static Error: <A_1, E_1>(error: E_1) => Result<A_1, E_1>;
/**
* Runs the function and resolves a result of its return value, or to an error if thrown
*/
static fromExecution: <ReturnValue, Error_1 = unknown>(func: () => ReturnValue) => Result<ReturnValue, Error_1>;
static fromExecution: <A_1, E_1 = unknown>(func: () => A_1) => Result<A_1, E_1>;
/**
* Takes the promise and resolves a result of its value, or to an error if rejected
*/
static fromPromise<ReturnValue, Error = unknown>(promise: Promise<ReturnValue>): Promise<Result<ReturnValue, Error>>;
static fromPromise<A, E = unknown>(promise: Promise<A>): Promise<Result<A, E>>;
/**
* Takes the option and turns it into Ok(value) is Some, or Error(valueWhenNone)
*/
static fromOption<A, Error>(option: Option<A>, valueWhenNone: Error): Result<A, Error>;
static fromOption<A, E>(option: Option<A>, valueWhenNone: E): Result<A, E>;
/**
* Turns an array of results into an result of array
*/
static all: <Results extends [] | readonly Result<any, any>[]>(results: Results) => Result<{ -readonly [P in keyof Results]: Results[P] extends Result<infer V, any> ? V : never; }, { -readonly [P_1 in keyof Results]: Results[P_1] extends Result<any, infer E> ? E : never; }[number]>;
static equals: <Value, Error_1>(a: Result<Value, Error_1>, b: Result<Value, Error_1>, equals: (a: Value, b: Value) => boolean) => boolean;
static all: <Results extends [] | readonly Result<any, any>[]>(results: Results) => Result<{ -readonly [P in keyof Results]: Results[P] extends Result<infer V, any> ? V : never; }, { -readonly [P_1 in keyof Results]: Results[P_1] extends Result<any, infer E_1> ? E_1 : never; }[number]>;
static equals: <A_1, E_1>(a: Result<A_1, E_1>, b: Result<A_1, E_1>, equals: (a: A_1, b: A_1) => boolean) => boolean;
static pattern: {

@@ -158,6 +158,6 @@ Ok: <T>(x: T) => {

tag: "Ok";
value: Ok;
value: A;
} | {
tag: "Error";
value: Error;
value: E;
};

@@ -170,3 +170,3 @@ constructor();

*/
map<ReturnValue>(f: (value: Ok) => ReturnValue): Result<ReturnValue, Error>;
map<B>(f: (value: A) => B): Result<B, E>;
/**

@@ -177,3 +177,3 @@ * Returns the Result containing the error returned from the callback

*/
mapError<ReturnError>(f: (value: Error) => ReturnError): Result<Ok, ReturnError>;
mapError<F>(f: (value: E) => F): Result<A, F>;
/**

@@ -184,3 +184,3 @@ * Returns the Result containing the value from the callback

*/
flatMap<ReturnValue, ResultError = Error>(f: (value: Ok) => Result<ReturnValue, ResultError | Error>): Result<ReturnValue, ResultError | Error>;
flatMap<B, F = E>(f: (value: A) => Result<B, F | E>): Result<B, F | E>;
/**

@@ -191,3 +191,3 @@ * Returns the Result containing the value from the callback

*/
flatMapError<ReturnValue, ResultError>(f: (value: Error) => Result<ReturnValue, ResultError>): Result<Ok | ReturnValue, ResultError>;
flatMapError<B, F>(f: (value: E) => Result<B, F>): Result<A | B, F>;
/**

@@ -198,29 +198,29 @@ * Return the value if present, and the fallback otherwise

*/
getWithDefault(defaultValue: Ok): Ok;
getWithDefault(defaultValue: A): A;
/**
* Explodes the Result given its case
*/
match<ReturnValue>(config: {
Ok: (value: Ok) => ReturnValue;
Error: (error: Error) => ReturnValue;
}): ReturnValue;
match<B>(config: {
Ok: (value: A) => B;
Error: (error: E) => B;
}): B;
/**
* Runs the callback and returns `this`
*/
tap(func: (result: Result<Ok, Error>) => unknown): Result<Ok, Error>;
tap(func: (result: Result<A, E>) => unknown): Result<A, E>;
/**
* Runs the callback if ok and returns `this`
*/
tapOk(func: (value: Ok) => unknown): Result<Ok, Error>;
tapOk(func: (value: A) => unknown): Result<A, E>;
/**
* Runs the callback if error and returns `this`
*/
tapError(func: (error: Error) => unknown): Result<Ok, Error>;
tapError(func: (error: E) => unknown): Result<A, E>;
/**
* Typeguard
*/
isOk(): this is Result<Ok, Error> & {
isOk(): this is Result<A, E> & {
value: {
tag: "Ok";
value: Ok;
value: A;
};

@@ -231,6 +231,6 @@ };

*/
isError(): this is Result<Ok, Error> & {
isError(): this is Result<A, E> & {
value: {
tag: "Error";
value: Error;
value: E;
};

@@ -243,21 +243,21 @@ };

*/
toOption(): Option<Ok>;
toOption(): Option<A>;
/**
* Returns the ok value. Use within `if (result.isOk()) { ... }`
*/
get(this: Result<Ok, Error> & {
get(this: Result<A, E> & {
value: {
tag: "Ok";
value: Ok;
value: A;
};
}): Ok;
}): A;
/**
* Returns the error value. Use within `if (result.isError()) { ... }`
*/
getError(this: Result<Ok, Error> & {
getError(this: Result<A, E> & {
value: {
tag: "Error";
value: Error;
value: E;
};
}): Error;
}): E;
}

@@ -0,1 +1,7 @@

# 0.6.3
Changes:
- More concise generics on Result-related types (2f9465e)
# 0.6.2

@@ -2,0 +8,0 @@

{
"name": "@swan-io/boxed",
"version": "0.6.2",
"version": "0.6.3",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "Utility types for functional TypeScript",

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