@hazae41/result
Advanced tools
Comparing version 1.2.3 to 1.3.0
@@ -25,3 +25,3 @@ import { None, Some } from '@hazae41/option'; | ||
*/ | ||
static new<T>(inner: T): Err<T>; | ||
static create<T>(inner: T): Err<T>; | ||
/** | ||
@@ -36,6 +36,2 @@ * Create an `Err` with an `Error` inside | ||
/** | ||
* Set this result as handled | ||
*/ | ||
ignore(): this; | ||
/** | ||
* Type guard for `Ok` | ||
@@ -133,14 +129,2 @@ * @returns `true` if `Ok`, `false` if `Err` | ||
/** | ||
* Get the inner value or throw the inner error wrapped inside another Error | ||
* @param message | ||
* @returns `this.inner` if `Ok`, `Error(message, { cause: this.inner })` if `Err` | ||
*/ | ||
expect(message: string): never; | ||
/** | ||
* Get the inner error or throw the inner value wrapped inside another Error | ||
* @param message | ||
* @returns `this.inner` if `Err`, `Error(message, { cause: this.inner })` if `Ok` | ||
*/ | ||
expectErr(message: string): T; | ||
/** | ||
* Get the inner value or panic | ||
@@ -150,3 +134,3 @@ * @returns `this.inner` if `Ok` | ||
*/ | ||
unwrap(): never; | ||
getOrThrow(): never; | ||
/** | ||
@@ -157,3 +141,3 @@ * Get the inner error or panic | ||
*/ | ||
unwrapErr(): T; | ||
getErrOrThrow(): T; | ||
/** | ||
@@ -164,3 +148,3 @@ * Get the inner value or a default one | ||
*/ | ||
unwrapOr<U>(value: U): U; | ||
getOr<U>(value: U): U; | ||
/** | ||
@@ -172,3 +156,3 @@ * Get the inner value or compute a default one from the inner error | ||
*/ | ||
unwrapOrElse<U>(errMapper: (inner: T) => Awaitable<U>): Promise<U>; | ||
getOrElse<U>(errMapper: (inner: T) => Awaitable<U>): Promise<U>; | ||
/** | ||
@@ -180,3 +164,3 @@ * Get the inner value or compute a default one from the inner error | ||
*/ | ||
unwrapOrElseSync<U>(errMapper: (inner: T) => U): U; | ||
getOrElseSync<U>(errMapper: (inner: T) => U): U; | ||
/** | ||
@@ -186,3 +170,3 @@ * Get this if Ok or throw the inner error | ||
*/ | ||
check(): never; | ||
checkOrThrow(): never; | ||
/** | ||
@@ -192,3 +176,3 @@ * Get this if Err or throw the inner value | ||
*/ | ||
checkErr(): this; | ||
checkErrOrThrow(): this; | ||
/** | ||
@@ -195,0 +179,0 @@ * Transform Result<Promise<T>, E> into Promise<Result<T, E>> |
@@ -28,6 +28,2 @@ import { Some, None } from '@hazae41/option'; | ||
/** | ||
* Set this result as handled | ||
*/ | ||
ignore(): this; | ||
/** | ||
* Type guard for `Ok` | ||
@@ -124,14 +120,2 @@ * @returns `true` if `Ok`, `false` if `Err` | ||
/** | ||
* Get the inner value or throw the inner error wrapped inside another Error | ||
* @param message | ||
* @returns `this.inner` if `Ok`, `Error(message, { cause: this.inner })` if `Err` | ||
*/ | ||
expect(message: string): T; | ||
/** | ||
* Get the inner error or throw the inner value wrapped inside another Error | ||
* @param message | ||
* @returns `this.inner` if `Err`, `Error(message, { cause: this.inner })` if `Ok` | ||
*/ | ||
expectErr(message: string): never; | ||
/** | ||
* Get the inner value or panic | ||
@@ -141,3 +125,3 @@ * @returns `this.inner` if `Ok` | ||
*/ | ||
unwrap(): T; | ||
getOrThrow(): T; | ||
/** | ||
@@ -148,3 +132,3 @@ * Get the inner error or panic | ||
*/ | ||
unwrapErr(): never; | ||
getErrOrThrow(): never; | ||
/** | ||
@@ -155,3 +139,3 @@ * Get the inner value or a default one | ||
*/ | ||
unwrapOr(value: unknown): T; | ||
getOr(value: unknown): T; | ||
/** | ||
@@ -163,3 +147,3 @@ * Get the inner value or compute a default one from the inner error | ||
*/ | ||
unwrapOrElse(errMapper: unknown): Promise<T>; | ||
getOrElse(errMapper: unknown): Promise<T>; | ||
/** | ||
@@ -171,3 +155,3 @@ * Get the inner value or compute a default one from the inner error | ||
*/ | ||
unwrapOrElseSync(errMapper: unknown): T; | ||
getOrElseSync(errMapper: unknown): T; | ||
/** | ||
@@ -177,7 +161,7 @@ * Get this if Ok or throw the inner error | ||
*/ | ||
check(): this; | ||
checkOrThrow(): this; | ||
/** | ||
* Get this if Err or throw the inner value | ||
*/ | ||
checkErr(): never; | ||
checkErrOrThrow(): never; | ||
/** | ||
@@ -184,0 +168,0 @@ * Transform Result<Promise<T>, E> into Promise<Result<T, E>> |
@@ -7,3 +7,3 @@ import { Nullable } from '@hazae41/option'; | ||
interface Unwrappable<T = unknown> { | ||
unwrap(): T; | ||
getOrThrow(): T; | ||
} | ||
@@ -21,3 +21,2 @@ /** | ||
type Infer<T> = Ok.Infer<T> | Err.Infer<T>; | ||
let debug: boolean; | ||
/** | ||
@@ -51,3 +50,3 @@ * Create a Result from a maybe Error value | ||
/** | ||
* Rewrap any object with unwrap() into a Result | ||
* Rewrap any object with getOrThrow() into a Result | ||
* @param wrapper | ||
@@ -54,0 +53,0 @@ */ |
{ | ||
"type": "module", | ||
"name": "@hazae41/result", | ||
"version": "1.2.3", | ||
"version": "1.3.0", | ||
"description": "Rust-like Result for TypeScript", | ||
@@ -25,3 +25,3 @@ "homepage": "https://github.com/hazae41/result", | ||
"dependencies": { | ||
"@hazae41/option": "^1.0.27" | ||
"@hazae41/option": "^1.1.1" | ||
}, | ||
@@ -31,8 +31,8 @@ "devDependencies": { | ||
"@hazae41/rimraf": "^1.0.1", | ||
"@rollup/plugin-typescript": "^11.1.5", | ||
"@types/node": "^20.10.0", | ||
"rollup": "^4.5.2", | ||
"rollup-plugin-dts": "^6.1.0", | ||
"rollup-plugin-node-externals": "^6.1.2", | ||
"typescript": "^5.3.2" | ||
"@rollup/plugin-typescript": "^11.1.6", | ||
"@types/node": "^22.5.0", | ||
"rollup": "^4.21.0", | ||
"rollup-plugin-dts": "^6.1.1", | ||
"rollup-plugin-node-externals": "^7.1.3", | ||
"typescript": "^5.5.4" | ||
}, | ||
@@ -39,0 +39,0 @@ "exports": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
195852
3132
- Removed@hazae41/result@1.3.2(transitive)
Updated@hazae41/option@^1.1.1