JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 41
  • Score
    100M100P100Q70966F
  • License MIT

secure-event-emitter is a tiny javascript package that uses restrict rules and mechanisms to build safer and protected event-driven architecture.

Package Exports

  • secure-event-emitter
  • secure-event-emitter/react

Readme

Secure Event Emitter

Description

secure-event-emitter is a tiny javascript package (for the browsers and node.js) that uses restrict rules and mechanisms to build safer and protected event-driven architecture. It's similar to nodejs EventEmitter, but dictates stricter rules to prevent misuse.

The Main Features

  • All event types that the emitter can use must be defined․
  • We can not emit events anywhere without emitterKey
  • We can define a strict payload structure and emitter can only work with that structured data

Installation

npm install secure-event-emitter

Usage

import {SecureEventEmitter} from 'secure-event-emitter'
// const {SecureEventEmitter} = require('secure-event-emitter')

const event_types = ["abc", "xyz"]
const emitter_key = Symbol('My Emmiter Key')

const myEmitter = new SecureEventEmitter(event_types, emitter_key)

myEmitter.on("abc", (e) => {
    // ...
})

myEmitter.on("xyz", (e) => {
    // ...
})

myEmitter.unlock(emitter_key).emit('abc', 2021)

Maintainers

License

MIT