Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
catchify
Advanced tools
Changelog
[v2.6.1] - 2017-09-07
Readme
An set of async/await utilities:
Also see array destructuring with default values for handling returned arrays.
const catchify = require('catchify');
const all = require('catchify/all');
const catchify = require('catchify');
async function example(promise) {
const [error, value] = await catchify(promise);
if (error) console.log(error);
}
const catchify = require('catchify');
async function example(promise) {
const [error, value={message:'Hello'}]
= await catchify(promise);
if (error) console.log(error);
return value;
}
const some = require('catchify/some');
async function example() {
const [ [error1, error2], [value1, value2] ] = await some([
Promise.resolve(1),
Promise.reject(2)
]);
if (error2) console.error('error2');
if (value1) console.log('value1');
}
const catchify = require('catchify');
let pending = null;
async function example() {
if (pending) return pending;
const handle = catchify.newPromiseHandle();
pending = handle.promise;
const [error, value] = await catchify.resolve('example');
pending = null;
if (error) return handle.reject('rejected');
return handle.resolve('resolved');
}
catchify(value)
is an alias for catchify.resolve(value)
const [error, value]
= await catchify(promise)
catchify.resolve(value)
is an alias for catchify(value)
const [error, value]
= await catchify.resolve('Quickly test the success path')
const [error, value]
= await catchify.reject('Quickly test the error path')
const [error, value]
= await catchify.race([promise1, promise2])
const [error, [value1, value2]]
= await catchify.all([promise1, promise2])
const [error, {a: value1, b: value2}]
= await catchify.all({a: promise1, b: promise2})
catchify.all(iterable||object)
but an error does not prevent resolution of the restconst [[error1, error2], [value1, value2]]
= await catchify.some([promise1, promise2])
const [{a: error1, b: error2}, {a: value1, b: value2}]
= await catchify.some({a: promise1, b: promise2})
catchify.some(iterable||object)
but it allows limiting concurrent asynchronous tasksPromise.resolve()
before proceedingcatchify.some(iterable)
but execution
will halt if there is an error// The promises from fn1 and fn2 execute concurrently
// fn3 is called after promises from fn1 and fn2 resolve
const [
[error1, error2, error3],
[value1, value2, value3]
] = await catchify.limit([fn1, fn2, fn3])
const [
{a: error1, b: error2, c: error3},
{a: value1, b: value2, c: value3}
] = await catchify.limit({a: fn1, b: fn2, c: fn3})
// Access the promise
let pending;
const handle = catchify.newPromiseHandle();
pending = handle.promise;
// Reject the promise
const handle = catchify.newPromiseHandle();
handle.reject('rejected');
// Resolve the promise
const handle = catchify.newPromiseHandle();
handle.resolve('resolved');
FAQs
An async/await utility to eliminate try/catch in favor of error values.
The npm package catchify receives a total of 388 weekly downloads. As such, catchify popularity was classified as not popular.
We found that catchify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.