Socket
Socket
Sign inDemoInstall

defekt

Package Overview
Dependencies
Maintainers
5
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

defekt - npm Package Compare versions

Comparing version 7.2.3 to 7.3.0

16

build/lib/Result.d.ts
interface ResultBase<TValue, TError extends Error> {
hasError: () => this is ResultError<TValue, TError>;
hasValue: () => this is ResultValue<TValue, TError>;
hasError: () => this is ResultError<TError>;
hasValue: () => this is ResultValue<TValue>;
unwrapOrThrow: (errorTransformer?: (err: TError) => Error) => TValue;

@@ -8,15 +8,15 @@ unwrapOrElse: (handleError: (error: Error) => TValue) => TValue;

}
interface ResultError<TValue, TError extends Error> extends ResultBase<TValue, TError> {
interface ResultError<TError extends Error> extends ResultBase<unknown, TError> {
error: TError;
}
declare const error: <TValue, TError extends Error>(err: TError) => ResultError<TValue, TError>;
interface ResultValue<TValue, TError extends Error> extends ResultBase<TValue, TError> {
declare const error: <TError extends Error>(err: TError) => ResultError<TError>;
interface ResultValue<TValue> extends ResultBase<TValue, Error> {
value: TValue;
}
declare const value: {
<TValue extends undefined, TError extends Error>(): ResultValue<TValue, TError>;
<TValue, TError extends Error>(value: TValue): ResultValue<TValue, TError>;
<TValue extends undefined>(): ResultValue<TValue>;
<TValue>(value: TValue): ResultValue<TValue>;
};
declare type Result<TValue, TError extends Error> = ResultValue<TValue, TError> | ResultError<TValue, TError>;
declare type Result<TValue, TError extends Error> = ResultValue<TValue> | ResultError<TError>;
export type { ResultValue, ResultError, Result };
export { value, error };

@@ -0,1 +1,8 @@

# [7.3.0](https://github.com/thenativeweb/defekt/compare/7.2.3...7.3.0) (2021-07-03)
### Features
* Make early returns after error/value checks more convenient ([#326](https://github.com/thenativeweb/defekt/issues/326)) ([e27d0e5](https://github.com/thenativeweb/defekt/commit/e27d0e5c65822b8c36a519816f47cf5a3f04c411))
## [7.2.3](https://github.com/thenativeweb/defekt/compare/7.2.2...7.2.3) (2021-06-10)

@@ -2,0 +9,0 @@

interface ResultBase<TValue, TError extends Error> {
hasError: () => this is ResultError<TValue, TError>;
hasValue: () => this is ResultValue<TValue, TError>;
hasError: () => this is ResultError<TError>;
hasValue: () => this is ResultValue<TValue>;

@@ -10,7 +10,7 @@ unwrapOrThrow: (errorTransformer?: (err: TError) => Error) => TValue;

interface ResultError<TValue, TError extends Error> extends ResultBase<TValue, TError> {
interface ResultError<TError extends Error> extends ResultBase<unknown, TError> {
error: TError;
}
const error = function <TValue, TError extends Error>(err: TError): ResultError<TValue, TError> {
const error = function <TError extends Error>(err: TError): ResultError<TError> {
return {

@@ -30,6 +30,6 @@ hasError (): boolean {

},
unwrapOrElse (handleError: (error: TError) => TValue): TValue {
unwrapOrElse<TValue> (handleError: (error: TError) => TValue): TValue {
return handleError(err);
},
unwrapOrDefault (defaultValue: TValue): TValue {
unwrapOrDefault<TValue> (defaultValue: TValue): TValue {
return defaultValue;

@@ -41,3 +41,3 @@ },

interface ResultValue<TValue, TError extends Error> extends ResultBase<TValue, TError> {
interface ResultValue<TValue> extends ResultBase<TValue, Error> {
value: TValue;

@@ -47,5 +47,5 @@ }

const value: {
<TValue extends undefined, TError extends Error>(): ResultValue<TValue, TError>;
<TValue, TError extends Error>(value: TValue): ResultValue<TValue, TError>;
} = function <TValue, TError extends Error>(val?: TValue): ResultValue<TValue | undefined, TError> {
<TValue extends undefined>(): ResultValue<TValue>;
<TValue>(value: TValue): ResultValue<TValue>;
} = function <TValue>(val?: TValue): ResultValue<TValue | undefined> {
return {

@@ -71,3 +71,3 @@ hasError (): boolean {

type Result<TValue, TError extends Error> = ResultValue<TValue, TError> | ResultError<TValue, TError>;
type Result<TValue, TError extends Error> = ResultValue<TValue> | ResultError<TError>;

@@ -74,0 +74,0 @@ export type {

{
"name": "defekt",
"version": "7.2.3",
"version": "7.3.0",
"description": "defekt is custom errors made simple.",

@@ -35,5 +35,5 @@ "contributors": [

"devDependencies": {
"assertthat": "6.3.1",
"roboter": "11.7.3",
"semantic-release-configuration": "2.0.1"
"assertthat": "6.3.3",
"roboter": "11.7.7",
"semantic-release-configuration": "2.0.4"
},

@@ -40,0 +40,0 @@ "repository": {

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