@corentinth/chisels
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -114,7 +114,7 @@ /** | ||
/** | ||
* Safely executes a function and return a tuple with the result and an error if any. | ||
* Safely executes an async function or promise and return a tuple with the result and an error if any. | ||
* | ||
* @example | ||
* ```typescript | ||
* const [result, error] = safely(myFunction); | ||
* const [result, error] = await safely(myFunction); | ||
* | ||
@@ -128,9 +128,9 @@ * if (error) { | ||
*/ | ||
declare function safelySync<T>(fn: () => T): [T, null] | [null, Error]; | ||
declare function safely<T>(fn: (() => Promise<T> | T) | Promise<T>): Promise<[T, null] | [null, Error]>; | ||
/** | ||
* Safely executes an async function or promise and return a tuple with the result and an error if any. | ||
* Safely executes a function and return a tuple with the result and an error if any. | ||
* | ||
* @example | ||
* ```typescript | ||
* const [result, error] = await safely(myFunction); | ||
* const [result, error] = safelySync(myFunction); | ||
* | ||
@@ -144,4 +144,4 @@ * if (error) { | ||
*/ | ||
declare function safely<T>(fn: (() => Promise<T> | T) | Promise<T>): Promise<[T, null] | [null, Error]>; | ||
declare function safelySync<T>(fn: () => T): [T, null] | [null, Error]; | ||
export { type DeepPartial, type Dictionary, type Expand, type PartialBy, type Subtract, castError, formatBytes, injectArguments, safely, safelySync }; |
{ | ||
"name": "@corentinth/chisels", | ||
"type": "module", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"packageManager": "pnpm@9.9.0", | ||
@@ -6,0 +6,0 @@ "description": "Collection of utilities for JavaScript and TypeScript, lightweight and tree-shakable.", |
@@ -75,3 +75,3 @@ # Chisels - JS/TS utilities and types | ||
Function - [See source](./src/safely.ts#L20) | ||
Function - [See source](./src/safely.ts#L43) | ||
@@ -82,3 +82,3 @@ Safely executes a function and return a tuple with the result and an error if any. | ||
```typescript | ||
const [result, error] = safely(myFunction); | ||
const [result, error] = safelySync(myFunction); | ||
@@ -94,3 +94,3 @@ if (error) { | ||
Function - [See source](./src/safely.ts#L42) | ||
Function - [See source](./src/safely.ts#L20) | ||
@@ -97,0 +97,0 @@ Safely executes an async function or promise and return a tuple with the result and an error if any. |
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
Sorry, the diff of this file is not supported yet
30980