Skip to content

Latest commit

 

History

History
58 lines (36 loc) · 1.26 KB

README.md

File metadata and controls

58 lines (36 loc) · 1.26 KB

@wumpjs/utils

Some Utils for Wump.JS

Features

  • ESM, CJS and TS support.
  • Type-Safe
  • EventEmitter
  • Checker

Usage

import { Emitter, Checker } from "@wumpjs/utils";//on ESM(esmodule).

const { Emitter, Checker } = require("@wumpjs/utils");//on CJS(commonjs)


const checker = new Checker(Boolean(1));

checker.boolean//true
checker.number//false
checker.string//false


const emitter = new Emitter();

emitter.emit("test", "this is a test");
emitter.on("test", (str) => console.log(str));
//NOTE: this event emitter has extra functions.
import { Emitter, EventMap, EventSignature } from "@wumpjs/utils";

interface SomeEvents{
    test: (str: string) => unknown;
}

const emitter = new Emitter<SomeEvents>()


emitter.on("test", (str) => console.log(str));
emitter.emit("test", "this is a test");



//generic classes
class Test<Events extends EventSignature<Events> = EventMap> extends Emitter<Events>{}

Authors