Huge News!Announcing our $40M Series B led by Abstract Ventures.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 1.0.4 to 1.1.0

4

lib/index.d.ts
declare type ResultError = Error;
declare type ResultData = null | void | string | number | boolean | object | any[];
declare type ErrorProcessing = (error: ResultError) => ResultData;
declare type ErrorProcessingAsync = (error: ResultError) => Promise<ResultData>;
export declare class Result {

@@ -8,2 +10,4 @@ #private;

unwrapAsync(): Promise<ResultData>;
onError(func: ErrorProcessing): ResultData;
onErrorAsync(func: ErrorProcessingAsync): Promise<ResultData>;
}

@@ -10,0 +14,0 @@ export declare const ResultOk: (data: ResultData) => Result;

@@ -20,4 +20,16 @@ export class Result {

}
onError(func) {
if (this.#error !== null) {
return func(this.#error);
}
return this.#data;
}
async onErrorAsync(func) {
if (this.#error !== null) {
return func(this.#error);
}
return Promise.resolve(this.#data);
}
}
export const ResultOk = (data) => new Result(null, data);
export const ResultFail = (error) => new Result(error, void 0);

2

package.json
{
"name": "node-result",
"type": "module",
"version": "1.0.4",
"version": "1.1.0",
"description": "result",

@@ -6,0 +6,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