Skip to content

SlimIO/Profiles

Repository files navigation

Profiles

version Maintenance MIT size dep known vulnerabilities Build Status

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

import profilesLoader from "@slimio/profiles";
import Addon from "@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);
    });

    await CPU.ready();
});

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

export default 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

Name Refactoring Security Risk Usage
@slimio/config Minor High TBC
@slimio/is Minor Low Type checker
@slimio/safe-emitter Minor Medium Node.js Safe Emitter
@slimio/scheduler Minor Low TBC
@slimio/timer Minor Low Driftless interval
ms ⚠️Major Low TBC

License

MIT

About

SlimIO - Addon Profiles Manager

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •