
Research
/Security News
Popular Tinycolor npm Package Compromised in Supply Chain Attack Affecting 40+ Packages
Malicious update to @ctrl/tinycolor on npm is part of a supply-chain attack hitting 40+ packages across maintainers
@fsad-labs/toolly
Advanced tools
A lightweight wrappers around funtions or promises that simplifies:
npm i @fsad-labs/toolly
Retry executing your functions as many times as you want before displaying the error to the user.
await retryFn({
fn: function1, // your function
retry: 3,
delay: 1000, // milliseconds
fnError: (err: any) => { // CUSTOM MANAGE }
})
Parameter | Type | Description |
---|---|---|
fn | function | Required. Your function that will be wrapped to be executes |
retry | number | optional. number of attempts by default 3 times |
delay | number | optional. ms to wait before continue with the next execution by default 500 ms |
fnError | function | optional. async function to catch the error and customize it. Must return a value |
Result when retryFn is OK
Result (object) | Type | Description |
---|---|---|
success | boolean | status of the execution True |
result | any | result of your fn |
Result when retryFn throw an Error
Result (object) | Type | Description |
---|---|---|
success | boolean | status of the execution False |
message | string | message of the error Customizable |
code | string | code error "RETRY_ERROR" Customizable |
originalError | any | original error caught |
Join your functions in a container, share args and control the execution.
const fn1 = async (shared) => { //TODO }
const fn2 = async (shared) => { //TODO }
await joinFns({
fns: [fn1, fn2, ...],
args_shared: {
arsg1: "A",
arsg2: "B",
arsg3: "C",
},
})
Parameter | Type | Description |
---|---|---|
fns | functions | Required. Array of functions that will be wrapped to be executes |
args_shared | number | optional. args to be passed into all functions |
Result (object) | SubProp | Type | Description |
---|---|---|---|
execute | function | execute function | |
status | isCompleted | boolean | status of the container, true when all functions were executed |
isError | boolean | status error, true if joinFns throw error | |
message | string | original message error caught | |
fnsStatus | any | status of the all functions |
const { retryFn } = require('@fsad-labs/toolly');
const fn1 = async () => {
//TODO
throw { code: "NETWORK", message: "cancel" }
}
const fn2 = async () => {
try {
//TODO
throw new Error("Something was wrong in test2");
}
catch (e) {
throw e;
}
}
const fn3 = () => async () => {
//TODO
throw new Error("Something was wrong in test3");
}
const result = await retryFn({
fn: fn1,
retry: 4, // four times
delay: 1000, // 1 second
fnError: async (e) => {
// "Error callback executed";
await new Promise(resolve => setTimeout(resolve, 1000));
return { customProp: true };
}
});
const { joinFns } = require('@fsad-labs/toolly');
const fn1 = async (arg_shared) => {
//TODO
};
const fn2 = async (arg_shared) => {
//TODO
throw Error("Don't start middleware 3");
};
const fn3 = async (arg_shared) => {
//TODO
throw { code:"01" message: "Don't start middleware 3" } ;
};
const run = joinFns({
fns: [fn1, fn2, fn3],
args_shared: {
arsg1: "A",
arsg2: "B",
arsg3: "C",
}
});
// EXECUTE
run.execute();
// CHECK
run.status;
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License © fullstack-ad
FAQs
Tools functions
We found that @fsad-labs/toolly demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Malicious update to @ctrl/tinycolor on npm is part of a supply-chain attack hitting 40+ packages across maintainers
Security News
pnpm's new minimumReleaseAge setting delays package updates to prevent supply chain attacks, with other tools like Taze and NCU following suit.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.