Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

return-style

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

return-style - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

1

lib/return-result/return-result-from-async-function.d.ts
export declare function returnResultFromAsyncFunction<T, U extends unknown[] = any[]>(fn: (...args: U) => PromiseLike<T>): (...args: U) => Promise<T | null>;
export declare function returnResultFromAsyncFunction<T, U extends unknown[] = any[]>(fn: (...args: U) => PromiseLike<T>, defaultValue: T): (...args: U) => Promise<T>;

6

lib/return-result/return-result-from-async-function.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function returnResultFromAsyncFunction(fn) {
function returnResultFromAsyncFunction(fn, defaultValue = null) {
return async function (...args) {

@@ -8,4 +8,4 @@ try {

}
catch (err) {
return null;
catch {
return await Promise.resolve(defaultValue);
}

@@ -12,0 +12,0 @@ };

export declare function returnResultFromFunction<T, U extends unknown[] = any[]>(fn: (...args: U) => PromiseLike<T>): (...args: U) => Promise<T | null>;
export declare function returnResultFromFunction<T, U extends unknown[] = any[]>(fn: (...args: U) => PromiseLike<T>, defaultValue: T): (...args: U) => Promise<T>;
export declare function returnResultFromFunction<T, U extends unknown[] = any[]>(fn: (...args: U) => T): (...args: U) => T | null;
export declare function returnResultFromFunction<T, U extends unknown[] = any[]>(fn: (...args: U) => T, defaultValue: T): (...args: U) => T;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const extra_promise_1 = require("extra-promise");
function returnResultFromFunction(fn) {
function returnResultFromFunction(fn, defaultValue = null) {
return function (...args) {

@@ -10,4 +10,4 @@ let result;

}
catch (err) {
return null;
catch {
return defaultValue;
}

@@ -19,4 +19,4 @@ if (extra_promise_1.isPromise(result)) {

}
catch (err) {
return null;
catch {
return defaultValue;
}

@@ -23,0 +23,0 @@ })(result);

export declare function returnResultFromPromise<T>(promise: PromiseLike<T>): Promise<T | null>;
export declare function returnResultFromPromise<T>(promise: PromiseLike<T>, defaultValue: T): Promise<T>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function returnResultFromPromise(promise) {
function returnResultFromPromise(promise, defaultValue = null) {
return (async () => {

@@ -8,4 +8,4 @@ try {

}
catch (err) {
return null;
catch {
return defaultValue;
}

@@ -12,0 +12,0 @@ })();

export declare function returnResultFromSyncFunction<T, U extends unknown[] = any[]>(fn: (...args: U) => T): (...args: U) => T | null;
export declare function returnResultFromSyncFunction<T, U extends unknown[] = any[]>(fn: (...args: U) => T, defaultValue: T): (...args: U) => T;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function returnResultFromSyncFunction(fn) {
function returnResultFromSyncFunction(fn, defaultValue = null) {
return function (...args) {

@@ -8,4 +8,4 @@ try {

}
catch (err) {
return null;
catch {
return defaultValue;
}

@@ -12,0 +12,0 @@ };

export declare function returnResult<T>(promise: PromiseLike<T>): Promise<T | null>;
export declare function returnResult<T>(promise: PromiseLike<T>, defaultValue: T): Promise<T>;
export declare function returnResult<T, U extends unknown[] = any[]>(fn: (...args: U) => PromiseLike<T>): (...args: U) => Promise<T | null>;
export declare function returnResult<T, U extends unknown[] = any[]>(fn: (...args: U) => PromiseLike<T>, defaultValue: T): (...args: U) => Promise<T>;
export declare function returnResult<T, U extends unknown[] = any[]>(fn: (...args: U) => T): (...args: U) => T | null;
export declare function returnResult<T, U extends unknown[] = any[]>(fn: (...args: U) => T, defaultValue: T): (...args: U) => T;

@@ -5,8 +5,8 @@ "use strict";

const return_result_from_promise_1 = require("./return-result-from-promise");
function returnResult(promiseOrFn) {
function returnResult(promiseOrFn, defaultValue = null) {
if (typeof promiseOrFn === 'function') {
return return_result_from_function_1.returnResultFromFunction(promiseOrFn);
return return_result_from_function_1.returnResultFromFunction(promiseOrFn, defaultValue);
}
else {
return return_result_from_promise_1.returnResultFromPromise(promiseOrFn);
return return_result_from_promise_1.returnResultFromPromise(promiseOrFn, defaultValue);
}

@@ -13,0 +13,0 @@ }

{
"name": "return-style",
"version": "0.1.0",
"version": "0.1.1",
"main": "lib/index.js",

@@ -5,0 +5,0 @@ "types": "lib/index.d.ts",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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