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 5.6.0 to 6.0.0

38

lib/index.d.ts
export { ResultError } from 'node-result-error';
declare type ErrorProcessing<Error, Data> = (error: Error) => Data;
declare type ErrorProcessingAsync<Error, Data> = (error: Error) => Promise<Data>;
export declare class Result<Error, Data> {
private readonly error;
private readonly data;
constructor(error: Error | null | undefined, data: Data);
unwrap(): Data;
unwrapAsync(): Promise<Data>;
onError(func: ErrorProcessing<Error, Data>): Data;
onErrorAsync(func: ErrorProcessingAsync<Error, Data>): Promise<Data>;
declare type ErrorProcessing<E, D> = (error: E) => D;
declare type ErrorProcessingAsync<E, D> = (error: E) => Promise<D>;
export declare class Result<E, D> {
protected readonly error: E | null;
protected readonly data: D;
constructor(error: E | null | undefined, data: D);
onError(func: ErrorProcessing<E, D>): D;
onErrorAsync(func: ErrorProcessingAsync<E, D>): Promise<D>;
isOk(): boolean;
isFail(): boolean;
}
export declare class ResultOK<Data> extends Result<null, Data> {
constructor(data: Data);
export declare class ResultOK<D> extends Result<null, D> {
constructor(data: D);
unwrap(): D;
unwrapAsync(): Promise<D>;
}
export declare class ResultFAIL<Error> extends Result<Error, undefined> {
constructor(error: Error);
export declare class ResultFAIL<E> extends Result<E, undefined> {
constructor(error: E);
unwrap(): never;
unwrapAsync(): Promise<E>;
}
export declare const ResultOk: <Data>(data: Data) => ResultOK<Data>;
export declare const ResultFail: <Error_1>(error: Error_1) => ResultFAIL<Error_1>;
export declare const ResultOk: <D>(data: D) => ResultOK<D>;
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 tryCatchWrapperAsync(target: {
[Key: string]: unknown;
}, property: string, descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise<any>>): TypedPropertyDescriptor<(...args: any[]) => Promise<ResultOK<any> | ResultFAIL<Error>>>;

@@ -11,14 +11,2 @@ "use strict";

}
unwrap() {
if (this.error !== null) {
throw this.error;
}
return this.data;
}
unwrapAsync() {
if (this.error !== null) {
return Promise.reject(this.error);
}
return Promise.resolve(this.data);
}
onError(func) {

@@ -48,2 +36,8 @@ if (this.error !== null) {

}
unwrap() {
return this.data;
}
unwrapAsync() {
return Promise.resolve(this.data);
}
}

@@ -55,2 +49,8 @@ exports.ResultOK = ResultOK;

}
unwrap() {
throw this.error;
}
unwrapAsync() {
return Promise.reject(this.error);
}
}

@@ -57,0 +57,0 @@ exports.ResultFAIL = ResultFAIL;

{
"name": "node-result",
"version": "5.6.0",
"version": "6.0.0",
"description": "result",

@@ -14,13 +14,17 @@ "keywords": [

"repository": "github:WatchDG/node-result",
"private": false,
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": [
"lib/**/*"
],
"scripts": {
"fmt": "npx prettier --write \"src/**/*.ts\"",
"lint": "eslint --ext=ts src",
"build": "npx tsc",
"_postinstall": "husky install",
"prepublishOnly": "pinst --disable",
"prepare": "npm run lint && npm run build",
"build": "npx tsc"
"postpublish": "pinst --enable"
},
"files": [
"lib/**/*"
],
"dependencies": {

@@ -34,2 +38,3 @@ "node-result-error": "^1.1.0"

"husky": "^5.0.6",
"pinst": "^2.1.1",
"prettier": "^2.2.1",

@@ -36,0 +41,0 @@ "typescript": "^4.1.3"

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