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

transit

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

transit

- **🚀 5kb publishing subscription tool** - **🍭 Written in TypeScript** - **💪 Unit testing provides stability assurance** ## Install

latest
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

transit

  • 🚀 5kb publishing subscription tool
  • 🍭 Written in TypeScript
  • đź’Ş Unit testing provides stability assurance

Install

$ npm install --save transit
// using ES6 modules
import transit from 'transit'

// using  modules
var transit = require('transit')

Usage

import transit from 'transit'

const event = transit()

event.on('foo', (data) => {
  console.log(data) // abc
})
event.on('add', (data) => {
  console.log(data) // 1
})

event.emit('foo', 'abc')
event.emit('add', 1)

event.off('foo')
event.clear()

Typescript

import transit from 'transit'

interface Events {
  foo: string
  bar?: number
  add: symbol
}

const event = transit<Events>()
event.on('foo', (data) => {
  // (parameter) data: string
  console.log(data) // abc
})
event.on('bar', (data) => {
  // (parameter) data: number
  console.log(data) // 1
})

event.emit('foo', 'abc')
event.emit('bar')
event.emit('add', 1) // Argument of type 'number' is not assignable to parameter of type 'symbol'
event.emit('divide', 1) // Argument of type '"add1"' is not assignable to parameter of type 'keyof Events'.

API

  • on

    eventType: string | symbol

    handler: (data?: unknown) => void

  • emit

    eventType: string | symbol

    data?: unknown

  • off

    eventType: string | symbol

  • clear

FAQs

Package last updated on 27 Dec 2024

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