
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
await-event-emitter
Advanced tools
Await events library like EventEmitter
The concept of Webpack plugin has lots of lifecycle hooks, they implement this via EventEmitter. In the primitive events module on nodejs, the usage as follows
const EventEmitter = require('events')
const emitter = new EventEmitter()
emitter
.on('event', () => {
// do something *synchronously*
})
.emit('event', '...arguments')
The listener must be synchronous, that is way i wrote it.
And await-event-emitter support synchronous emitter magically :smile:
npm install --save await-event-emitter
const AwaitEventEmitter = require('await-event-emitter').default
const emitter = new AwaitEventEmitter()
const tick = () =>
new Promise((resolve) => {
setTimeout(() => {
console.log('tick')
resolve()
}, 1000)
})
emitter.on('event', async () => {
// wait to print
await tick()
})
async function run() {
// NOTE: it's important to `await` the reset process
await emitter.emit('event', '...arguments')
await emitter.emit('event', 'again')
// support emit it synchronously
emitter.emitSync('event', 'again')
}
run()
AwaitEventEmitter
addListener(event, listener)
: AwaitEventEmitteron
once(event, listener)
prependListener(event, listener)
: AwaitEventEmitterprepend
prependOnceListener(event, listener)
: AwaitEventEmitterprependOnce
removeListener(event, listener)
: AwaitEventEmitteroff
listeners(event)
: []emit(event, ...args)
: Promise.resolve(boolean)emitSync(event, ...args)
: boolean
emit listeners synchronouslynpm test
git checkout -b feature-new
or git checkout -b fix-which-bug
git commit -am 'feat: some description (close #123)'
or git commit -am 'fix: some description (fix #123)'
git push
This library is written and maintained by imcuttle, imcuttle@163.com.
MIT - imcuttle 🐟
FAQs
Await events library like EventEmitter
The npm package await-event-emitter receives a total of 11,621 weekly downloads. As such, await-event-emitter popularity was classified as popular.
We found that await-event-emitter 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
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.