ts-errorflow
Advanced tools
Comparing version 1.0.1 to 2.0.0
@@ -1,5 +0,5 @@ | ||
export declare const EitherErrorSymbol: unique symbol; | ||
export interface IError { | ||
either_error_symbol: Symbol; | ||
} | ||
export declare const AnErrorSymbol: unique symbol; | ||
export declare type IError = { | ||
[AnErrorSymbol]?: Symbol; | ||
}; | ||
/** | ||
@@ -13,3 +13,3 @@ * Checks an object to verify whether it represents a failure. Will return true if the checked object | ||
*/ | ||
export declare function isError<T, U extends {}>(either: T | U): either is U; | ||
export declare function isError<T, U>(either: T | U): either is U; | ||
/** | ||
@@ -16,0 +16,0 @@ * Augments a given object with the either error symbol. This guarantees that it when checked |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.EitherErrorSymbol = Symbol('EitherError'); | ||
exports.AnErrorSymbol = Symbol('AnErrorSymbol'); | ||
/** | ||
@@ -13,5 +13,4 @@ * Checks an object to verify whether it represents a failure. Will return true if the checked object | ||
function isError(either) { | ||
const candidateFailure = either; | ||
if (candidateFailure.either_error_symbol) { | ||
return candidateFailure.either_error_symbol === exports.EitherErrorSymbol; | ||
if (either[exports.AnErrorSymbol]) { | ||
return either[exports.AnErrorSymbol] === exports.AnErrorSymbol; | ||
} | ||
@@ -34,5 +33,5 @@ return false; | ||
} | ||
error.either_error_symbol = exports.EitherErrorSymbol; | ||
error[exports.AnErrorSymbol] = exports.AnErrorSymbol; | ||
return error; | ||
} | ||
exports.makeError = makeError; |
{ | ||
"name": "ts-errorflow", | ||
"version": "1.0.1", | ||
"version": "2.0.0", | ||
"description": "A simple zero dependency TypeScript empowered implementation of an Either construct for improved control flow and error handling", | ||
@@ -5,0 +5,0 @@ "main": "dist/index", |
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
255468
115