New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

wing-register

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wing-register

JavaScript register

latest
Source
npmnpm
Version
0.0.4
Version published
Maintainers
1
Created
Source

wing-register

Install

$ npm install wing-register

Usage

  • example1
import Register from 'wing-register';

const register = new Register();
const fn1 = () => console.log('fn1 called');
const fn2 = () => console.log('fn2 called');

register.register(fn1);
register.register(fn2);
register.register(fn2);

/* ****************************** */
register.excute();
/**
 * will output:
 *
 * fn1 called
 * fn2 called
 */

/* ****************************** */
register.unregister(fn1);
register.excute();
/**
 * will output:
 *
 * fn2 called
 */

/* ****************************** */
register.clear();
register.excute();
/**
 * nothing will output
 */
  • example2
import Register from 'wing-register';

interface Device {
  id: string;
}
type CallBack = (d: Device) => void;

const register = new Register<CallBack, Device>();

const fn = (v: Device) => console.log('---', v.id);
register.register((v) => console.log('+++', v.id));
register.register((v) => console.log('+++', v.id));
register.register(fn);
register.register(fn);
register.register(fn);

setInterval(() => {
  const id = `${Math.random()}`;
  register.excute({ id });
}, 1000);

setTimeout(() => {
  register.unregister(fn);
}, 2000);

setTimeout(() => {
  register.clear();
}, 5000);

Keywords

register

FAQs

Package last updated on 16 Jan 2025

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