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

evnty

Package Overview
Dependencies
Maintainers
1
Versions
419
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

evnty

0-Deps, simple, fast, for browser and node js anonymous event library

  • 0.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10K
increased by12.51%
Maintainers
1
Weekly downloads
 
Created
Source

Evnty

0-Deps, simple, fast, for browser and node js anonymous event library

Coverage Status Build Status NPM version Downloads Snyk

Interface

declare type Unsubscribe = () => void;
declare type Listener = (...args: any[]) => void;
declare type Filter = (...args: any[]) => boolean;

declare class Event {
    static merge(...events: Event[]): Event;

    readonly size: Number;

    has(listener: Listener): boolean;
    off(listener: Listener): void;
    on(listener: Listener): Unsubscribe;
    once(listener: Listener): Unsubscribe;
    clear(): void;
    filter(filter: Filter): Event;
}

Usage

import event from 'evnty';

function handleClick({ button }) {
  console.log('Clicked button is', button);
}
const clickEvent = event();
const unsubscribe = clickEvent.on(handleClick);

const keyPressEvent = event();

function handleInput({ button, key }) {

}

const inputEvent = Event.merge(clickEvent, keyPressEvent);
inputEvent.on(handleInput);

function handleLeftClick() {
  console.log('Left button is clicked');
}
const leftClickEvent = clickEvent.filter(({ button }) => button === 'left');
leftClickEvent.on(handleLeftClick);


clickEvent({ button: 'right' });
clickEvent({ button: 'left' });
clickEvent({ button: 'middle' });
keyPressEvent({ key: 'A' });
keyPressEvent({ key: 'B' });
keyPressEvent({ key: 'C' });

leftClickEvent.off(handleLeftClick);
unsubscribe();

License

License The MIT License Copyright (c) 2019 Ivan Zakharchanka

Keywords

FAQs

Package last updated on 08 Oct 2019

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