@reix/bits
TypeScript icon, indicating that this package has built-in type declarations

0.2.2 • Public • Published

Bits

Bit-related utilites for the reix game engine

Usage

BitFieldEmitter

import { BitFieldEmitter } from '@reix/bits'

// create emitter
const emitter = new BitFieldEmitter<number>()

// each listener gets a data and a code parameter
const handler = (data: number, code: number) => console.log('fired')

emitter.on(0b011, handler)

// second param can be any number you want to pass to the handlers, I just like the digit 7:)
emitter.emit(0b001, 7) // fired
emitter.emit(0b100, 7) // nothing...
emitter.emit(0b101, 7) // fired
emitter.emit(0b110, 7) // fired

Package Sidebar

Install

npm i @reix/bits

Weekly Downloads

1

Version

0.2.2

License

MIT

Unpacked Size

8.65 kB

Total Files

7

Last publish

Collaborators

  • adrielus