1.0.20 • Published 3 years ago

amitt v1.0.20

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Description

amitt helps you build functional event emitter / pubsub

Documentations for types - https://webigorkiev.github.io/amitt/

Installation

npm i amitt
// using ES6 modules
import {amitt} from "amitt";
 
// using CommonJS modules
const {amitt} = require("amitt");

Features

  • Zero Dependencies
  • Tiny ~800b
  • Very simple small library
  • Focus on usability and performance
  • Testing coverage
  • RegExp event filters for emit
  • once execute handlers
  • emit can return array of Promise for async use

Usage

Simple example

import {amitt} from 'amitt';

const emitter = amitt();

emitter.on("fire", () => console.log("handler"));
emitter.emit("fire");

async example

const {amitt} = require('../dist/index.js');
const emitter = amitt();

(async() => {
    try {
        const handler1 = async() => await new Promise(resolve => setTimeout(resolve, 1000));
        const handler2 = async() => await new Promise(resolve => setTimeout(resolve, 1000));

        emitter.on("fire", handler1);
        emitter.on("fire-fight", handler2);

        await Promise.all([...emitter.emit(/^fi/)]);

        console.log("end");
    } catch(e) {
        console.log(e);
    }
})();
1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.9

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.20

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago