0.1.2 • Published 5 years ago

@slimio/profiles v0.1.2

Weekly downloads
8
License
MIT
Repository
github
Last release
5 years ago

Profiles

version Maintenance MIT

Addon profiles manager.

Requirements

Getting Started

This package is available in the Node Package Repository and can be easily installed with npm or yarn.

$ npm i @slimio/profiles
# or
$ yarn add @slimio/profiles

Usage example

const profilesLoader = require("@slimio/profiles");
const Addon = require("@slimio/addon");

const CPU = new Addon("cpu");
let profiles;

CPU.on("start", async() => {
    profiles = await profilesLoader("./config.json");
    profiles.events.on("walk", (name, payload) => {
        console.log(`profile name => ${name}`);
        console.log(payload);
    });

    CPU.ready();
});

CPU.on("stop", () => {
    profiles.free(); // use free() to cleanup everything
});

module.exports = CPU;

API

interface Event<T> {
    walk: (name: string, payload: T) => any;
}

declare function profiles<T>(configPath: string, predicate?: Function) : {
    events: SafeEmitter<Event<T>>;
    get: (profileName: string) => object | null;
    free: () => any;
}

Predicate can be used to filter profiles before calling walk event.

Dependencies

NameRefactoringSecurity RiskUsage
@slimio/configMinorHighTBC
@slimio/isMinorLowType checker
@slimio/safe-emitterMinorMediumNode.js Safe Emitter
@slimio/schedulerMinorLowTBC
@slimio/timerMinorLowDriftless interval
ms⚠️MajorLowTBC

License

MIT