Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
promised-until
Advanced tools
Transforms a (promised) value until it satisfies the given predicate.
Transforms a (promised) value until it satisfies the given predicate. Full support for Promises.
until(predicate, transform)(value) -> Promise(newValue)
Calling until(predicate, transform)
returns a function that takes one parameter. Calling that function with value
returns a promise, which resolves if predicate(value)
is truthy. While predicate(value)
is falsey, the value
is transformed with transform(value)
until predicate(value)
returns a truthy value.
predicate(x) -> true|false or Promise(true|false)
A function that accepts one parameter x
and returns a truthy or falsey value, or Promise of such a value.
transform(x) -> y or Promise(y)
A function that accepts one parameter x
and transforms it into a new value y
, or Promise of such a value.
value
The value, or Promise of a value to be transformed.
const until = require('promised-until')
until(
(c) => c >= 5,
(c) => c + 1
)(0)
.then(result => console.log(result)) // logs '5' to the console
const until = require('promised-until')
until(
(c) => Promise.resolve(c >= 5),
(c) => Promise.resolve(c + 1)
)(Promise.resolve(0))
.then(result => console.log(result)) // logs '5' to the console
until(
(pageToken) => !pageToken
(pageToken) => {
return fetchPage(pageToken)
.then(page => {
socket.send(page)
return page.nextPageToken
})
)(getFirstPageToken())
.then(() => console.log('done'))
The module is CI-tested with Node versions 0.10, 4.5 (LTS) and the latest (currently 6.5).
Uses any-promise which defaults to the native Promise
implementation. If you want to use a different Promise library, make sure to register it with any-promise
. For example require('any-promise/register/bluebird')
for bluebird.
For Node versions <= 0.12
a 3rd-party Promise library is required. More details here.
FAQs
Transforms a (promised) value until it satisfies the given predicate.
The npm package promised-until receives a total of 1 weekly downloads. As such, promised-until popularity was classified as not popular.
We found that promised-until 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.