1.0.1 • Published 10 months ago

@wumpjs/utils v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@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

1.0.1

10 months ago

1.0.0

11 months ago