
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@baethon/promise-duck
Advanced tools
Converts given callback to Thenable
object.
Such object is compatible with Promise spec so it can be used as it was a real Promise.
The difference is that computation is deferred until then()
method is called or await
keyword is used.
It's quite fair to say that in the way how it works such Promise is quite similar to Task
The idea came from little support library which was responsible for building a query (using sort-of fluent API) which was responsible for checking if given value is unique in the database.
I was wondering if object with then()
method can be used as a regular Promise. Turned out that its possible.
This little discovery opened me a way to define friendly syntax:
const emailUnique = await isUnique.in('users').where({ email: 'jon@winterfell.com' })
The defined object can be stored in a variable and none query will be executed until calling then()
or using await
keyword.
// define details of query (no query is executed!)
const query = isUnique.in('users').where({ email: 'jon@winterfell.com' })
// query the database and return the results
const emailUnique = await query
npm i @baethon/promise-duck
# or with yarn
yarn add @baethon/promise-duck
Package exposes two functions:
thenable()
converts given function to Thenable
object.bind()
converts given function and binds it to the selected objectconst { thenable } = require('@baethon/promise-duck')
const heavyStuff = Math.random
const p = thenable(heavyStuff)
const result = await p
const { bind } = require('@baethon/promise-duck')
const heavyStuff = function () {
return `Hello ${this.name}`
}
const object = { name: 'Jon' }
bind(heavyStuff).to(object)
const result = await object
By default results generated by given function will be cached.
Both, thenable()
and bind()
allow to disable cache by passing memoize: false
option:
const { thenable } = require('@baethon/promise-duck')
const fn = Math.random
const p = thenable(fn, { memoize: false })
If you're planning to contribute to the package please make sure to adhere to following conventions.
npm run lint
to check if there are any linting errorsFAQs
Converts object to be promise-like
The npm package @baethon/promise-duck receives a total of 4 weekly downloads. As such, @baethon/promise-duck popularity was classified as not popular.
We found that @baethon/promise-duck demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.