@appolo/utils
Advanced tools
Comparing version 8.0.34 to 8.0.35
@@ -68,2 +68,10 @@ "use strict"; | ||
} | ||
static toNull(fn) { | ||
try { | ||
return fn(); | ||
} | ||
catch (e) { | ||
return null; | ||
} | ||
} | ||
static emptyFn() { | ||
@@ -70,0 +78,0 @@ } |
@@ -75,3 +75,3 @@ import {Arrays} from "./arrays"; | ||
public static to<T, K>(fn: Function): [K, T?] { | ||
public static to<T, K = any>(fn: Function): [K, T?] { | ||
try { | ||
@@ -84,6 +84,14 @@ return [null, fn()] | ||
public static emptyFn(){ | ||
public static toNull<T>(fn: Function): T { | ||
try { | ||
return fn() | ||
} catch (e) { | ||
return null | ||
} | ||
} | ||
public static emptyFn() { | ||
} | ||
} |
@@ -29,3 +29,3 @@ import {Arrays} from "./arrays"; | ||
public static isEmpty(obj: { [index: string]: any }): boolean { | ||
public static isEmpty(obj: { [index: string]: any } | any[]): boolean { | ||
return Object.keys(obj || {}).length === 0 | ||
@@ -32,0 +32,0 @@ } |
@@ -56,2 +56,11 @@ "use strict"; | ||
} | ||
static async toNull(promise) { | ||
try { | ||
let result = await promise; | ||
return result; | ||
} | ||
catch (e) { | ||
return null; | ||
} | ||
} | ||
static allSettled(promises) { | ||
@@ -58,0 +67,0 @@ let settled = []; |
@@ -66,3 +66,13 @@ import {Deferred} from "./deferred"; | ||
public static async toNull<T>(promise: Promise<T>): Promise<T> { | ||
try { | ||
let result = await promise; | ||
return result | ||
} catch (e) { | ||
return null; | ||
} | ||
} | ||
public static allSettled<T>(promises: Promise<T>[]): Promise<({ status: "fulfilled"; value: T; } | { status: "rejected"; reason: any; })[]> { | ||
@@ -69,0 +79,0 @@ |
@@ -20,3 +20,3 @@ { | ||
"main": "./index.js", | ||
"version": "8.0.34", | ||
"version": "8.0.35", | ||
"license": "MIT", | ||
@@ -34,12 +34,12 @@ "repository": { | ||
"@types/benchmark": "^2.1.1", | ||
"@types/chai": "^4.2.22", | ||
"@types/lodash": "^4.14.175", | ||
"@types/mocha": "^9.0.0", | ||
"@types/node": "^16.10.3", | ||
"@types/chai": "^4.3.0", | ||
"@types/lodash": "^4.14.179", | ||
"@types/mocha": "^9.1.0", | ||
"@types/node": "^17.0.21", | ||
"benchmark": "^2.1.4", | ||
"chai": "^4.3.4", | ||
"mocha": "^9.1.2", | ||
"chai": "^4.3.6", | ||
"mocha": "^9.2.1", | ||
"tslib": "^2.3.1", | ||
"typescript": "^4.4.3" | ||
"typescript": "^4.6.2" | ||
} | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
236681
4337