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

node-result

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-result - npm Package Compare versions

Comparing version 7.0.0 to 8.0.0

23

lib/index.d.ts
export { ResultError } from 'node-result-error';
declare type ErrorProcessing<E, D> = (error: E) => D;
declare type ErrorProcessingAsync<E, D> = (error: E) => Promise<D>;
export declare type ResultType<E, D> = ResultOK<E> | ResultFAIL<D>;
export declare class Result<E, D> {
declare type ErrorProcessing<D, E> = (error: E) => D;
declare type ErrorProcessingAsync<D, E> = (error: E) => Promise<D>;
export declare type ReturningResult<D, E> = ResultOK<D> | ResultFAIL<E>;
export declare type ReturningResultAsync<D, E> = Promise<ResultOK<D> | ResultFAIL<E>>;
export declare class Result<D, E> {
protected readonly error: E | null;
protected readonly data: D;
constructor(error: E | null | undefined, data: D);
constructor(data: D, error?: E | null);
unwrap(): D | never;
unwrapAsync(): Promise<D | E>;
onError(func: ErrorProcessing<E, D>): D;
onErrorAsync(func: ErrorProcessingAsync<E, D>): Promise<D>;
onError(func: ErrorProcessing<D, E>): D;
onErrorAsync(func: ErrorProcessingAsync<D, E>): Promise<D>;
isOk(): boolean;
isFail(): boolean;
}
export declare class ResultOK<D> extends Result<null, D> {
export declare class ResultOK<D> extends Result<D, null> {
constructor(data: D);

@@ -21,3 +22,3 @@ unwrap(): D;

}
export declare class ResultFAIL<E> extends Result<E, undefined> {
export declare class ResultFAIL<E> extends Result<undefined, E> {
constructor(error: E);

@@ -29,3 +30,3 @@ unwrap(): never;

export declare const ResultFail: <E>(error: E) => ResultFAIL<E>;
export declare function tryCatchWrapper(target: Record<any, any>, property: string, descriptor: TypedPropertyDescriptor<(...args: any[]) => any>): TypedPropertyDescriptor<(...args: any[]) => ResultOK<any> | ResultFAIL<Error>>;
export declare function tryCatchWrapperAsync(target: Record<any, any>, property: string, descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise<any>>): TypedPropertyDescriptor<(...args: any[]) => Promise<ResultOK<any> | ResultFAIL<Error>>>;
export declare function tryCatchWrapper<C, D, E>(target: C, property: string, descriptor: TypedPropertyDescriptor<(...args: never[]) => D | ResultFAIL<E>>): TypedPropertyDescriptor<(...args: never[]) => D | ResultFAIL<E>>;
export declare function tryCatchWrapperAsync<C, D, E>(target: C, property: string, descriptor: TypedPropertyDescriptor<(...args: never[]) => Promise<D | ResultFAIL<E>>>): TypedPropertyDescriptor<(...args: never[]) => Promise<D | ResultFAIL<E>>>;

@@ -7,3 +7,3 @@ "use strict";

class Result {
constructor(error = null, data) {
constructor(data, error = null) {
this.error = error;

@@ -46,3 +46,3 @@ this.data = data;

constructor(data) {
super(null, data);
super(data, null);
}

@@ -59,3 +59,3 @@ unwrap() {

constructor(error) {
super(error, void 0);
super(void 0, error);
}

@@ -78,3 +78,8 @@ unwrap() {

try {
return self === null || self === void 0 ? void 0 : self.call(this, ...args);
if (self instanceof Function) {
return self.call(this, ...args);
}
else {
return exports.ResultFail(new TypeError('Descriptor value is not a function.'));
}
}

@@ -92,3 +97,8 @@ catch (error) {

try {
return await (self === null || self === void 0 ? void 0 : self.call(this, ...args));
if (self instanceof Function) {
return self.call(this, ...args);
}
else {
return exports.ResultFail(new TypeError('Descriptor value is not a function.'));
}
}

@@ -95,0 +105,0 @@ catch (error) {

{
"name": "node-result",
"version": "7.0.0",
"version": "8.0.0",
"description": "result",

@@ -5,0 +5,0 @@ "keywords": [

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