Socket
Socket
Sign inDemoInstall

async-events-listener

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    async-events-listener

async-events-listener


Version published
Weekly downloads
2
decreased by-75%
Maintainers
1
Install size
13.8 kB
Created
Weekly downloads
 

Readme

Source

Async EventsEmitter

Fork from offical events module

Async

change normal events by using async handler.

Example

Sourtce Code:

const a = new EventEmitter();
a.on('aaa', async () => {
    console.log('start:', '1 = ', 'aaa', '->', new Date().getTime());
    await new Promise(resolve => setTimeout(resolve, 3000));
    console.log('end:', '1 = ', 'aaa', '->', new Date().getTime());
});
a.on('aaa', async () => {
    console.log('start:', '2 = ', 'aaa', '->', new Date().getTime());
    await new Promise(resolve => setTimeout(resolve, 3000));
    console.log('end:', '2 = ', 'aaa', '->', new Date().getTime());
});
a.on('aaa', async () => {
    console.log('start:', '3 = ', 'aaa', '->', new Date().getTime());
    await new Promise(resolve => setTimeout(resolve, 3000));
    console.log('end:', '3 = ', 'aaa', '->', new Date().getTime());
});
 
(async () => {
    await a.emit('aaa');
    console.log('all done');
})();

Output:

/**
 * @output:
 * start: 1 =  aaa -> 1487673861652
 * end: 1 =  aaa -> 1487673864656
 * start: 2 =  aaa -> 1487673864657
 * end: 2 =  aaa -> 1487673867663
 * start: 3 =  aaa -> 1487673867663
 * end: 3 =  aaa -> 1487673870664
 * all done
 *
 */

FAQs

Last updated on 04 Apr 2018

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc