New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

flak

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flak

Powerfull universal JavaScript event emitter for browser and server.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-88.14%
Maintainers
1
Weekly downloads
 
Created
Source




Powerfull universal JavaScript event emitter for browser and server.

Installation

Node.js

npm install flak --save

Example

const Flak = require('flak');
const emitter = new Flak();

// Adds listener for the event
emitter.on('myEvent1', (param1, param2)=>{
    console.log(param1, param2);
});

// Adds a one time listener function for the event 
emitter.once('myEvent2', (param1, param2)=>{
    console.log(param1, param2);
});

// Adds listener for the event that can be call just 4 time
emitter.on('myEvent3', (param1, param2)=>{
    console.log(param1, param2);
}, {
    maxCalls: 4
});

// Adds the listener function to the beginning of the listeners array for the event named myEvent1
emitter.on('myEvent1', (param1, param2)=>{
    console.log(param1, param2);
}, {
    prepend: true
});

// Catch all events
emitter.onCatchAll(params=>{
    console.log(params);
});

// Fire event
emitter.fire('myEvent1', true, {a: 1});

// Fire async method
emitter.fireAsync('myEvent2', true, {a: 1});

// Remove all listeners for myEvent1
emitter.off('myEvent1');

// Returning data using "fireTheFirst"
emitter.on('myEvent', (param1, param2)=>{
    return param1 + '-' + param2;
});
console.log('foo-bar' === emitter.fireTheFirst('myEvent', 'foo', 'bar')) //=> true;

// Suspend event
emitter.suspendEvent('myEvent');
emitter.fire('myEvent'); // will not be fired!

// Resume event
emitter.resumeEvent('myEvent');

API Documentation

See full documentation here

Browser

Local
<script src="node_modules/flak/dist/flak.min.js"></script>
CDN unpkg
<script src="https://unpkg.com/flak/dist/flak.min.js"></script>
CDN jsDeliver
<script src="https://cdn.jsdelivr.net/npm/flak/dist/flak.min.js"></script>

Changelog

You can view the changelog here

License

Flak is open-sourced software licensed under the MIT license

Author

Fabio Ricali

Keywords

FAQs

Package last updated on 23 Nov 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc