1.0.20 • Published 2 years ago

amitt v1.0.20

Weekly downloads
-
License
MIT
Repository
github
Last release
2 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

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.9

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.20

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.2

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago