Skip to content

wumpjs/utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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