Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
async-any - manage various forms of asynchronous completion in a uniform way
$ npm install async-any
import asyncAny from 'async-any'
// async task taking a `done` callback
asyncAny(done => fs.stat(path, done), (error, result) => { ... })
// async task returning a promise or observable
asyncAny(() => fetch(url), (error, result) => { ... })
// returns a promise if the callback is omitted
let result = await asyncAny(task)
This module exports a function which provides a uniform way to handle tasks which signal completion asynchronously — either by calling a callback, returning a promise, or returning an observable.
I wanted a lightweight version of async-done without the bugs, with stricter detection of promises and observables, with an optional promise API, and with browser support.
async-any doesn't support event emitters, ChildProcess or other kinds of Node.js streams (unless they also happen to be promises or observables). If you need support for these, use async-done.
Signature:
function runTask (task) {
asyncAny(task, (error, result) => {
if (!error) console.log('got result:', result)
})
}
// or
async function runTask (task) {
let result = await asyncAny(task)
console.log('got result:', result)
}
Takes an asynchronous task (function) and a callback. The task is passed a done
"errorback"
function which can be used to signal completion. Alternatively, the task can return
a promise or an observable and will be deemed complete when that "future"
succeeds or fails.
Once the task has completed, its error/result is forwarded to the callback. If the callback is omitted, a promise is returned, which is fulfilled/rejected by the corresponding result/error.
If the task returns a value which is both a promise and an observable, it is treated as a promise.
The following NPM scripts are available:
The following Gulp tasks are available:
lint
and build
tasks1.0.0
Copyright © 2018 by chocolateboy.
This is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.
FAQs
Manage various forms of asynchronous completion in a uniform way
The npm package async-any receives a total of 2 weekly downloads. As such, async-any popularity was classified as not popular.
We found that async-any demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.