open-index/open-npm huggingface dataset:
npm package: @slimio/lock
Description: SlimIO Asynchronous Lock Handler
Author: SlimIO
Latest version: 1.0.0

# Lock
![version](https://img.shields.io/badge/dynamic/json.svg?url=https://raw.githubusercontent.com/SlimIO/Lock/master/package.json&query=$.version&label=Version)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/SlimIO/Lock/commit-activity)
![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)
![dep](https://img.shields.io/david/SlimIO/Lock)
![size](https://img.shields.io/bundlephobia/min/@slimio/lock)
[![Known Vulnerabilities](https://snyk.io//test/github/SlimIO/Lock/badge.svg?targetFile=package.json)](https://snyk.io//test/github/SlimIO/Lock?targetFile=package.json)
[![Build Status](https://travis-ci.com/SlimIO/Lock.svg?branch=master)](https://travis-ci.com/SlimIO/Lock)

SlimIO Asynchronous Handler Mutex "Like" Lock. This package has been created to easily lock parallel execution of JavaScript Asynchronous function.

## Requirements
- [Node.js](https://nodejs.org/en/) v12 or higher

## Getting Started

This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).

```bash
$ npm i @slimio/lock
# or
$ yarn add @slimio/lock
```

## Usage example
```js
const Lock = require("@slimio/lock");

const asyncLocker = new Lock({ maxConcurrent: 3 });

async function npmInstall() {
    const free = await asyncLocker.acquireOne();
    try {
        await new Promise((resolve) => setTimeout(resolve, 1000));
        console.log("npm install resolved!");
    }
    finally {
        free();
    }
}

// Run 3 per 3 methods
Promise.all([
    npmInstall(),
    npmInstall(),
    npmInstall(),
    npmInstall(),
    npmInstall()
]).then(() => console.log("all done!")).catch(console.error);
```

## API

### Properties

```ts
declare class Lock {
    public readonly max: number;
    public readonly running: number;
}
```

### Methods

<details><summary>acquireOne(): Promise< () => void ></summary>
<br />
Create a new lock counter. Return a function that you need to execute to free the counter/lock.

</details>

<details><summary>freeOne(error?: Error): void</summary>
<br />
free an acquired lock (or do nothing if there is no lock acquired yet).

</details>

<details><summary>rejectAll(errorMessage?: string): void</summary>
<br />
Reject all promises and available locks. This will throw an Error for each called acquireOne. The default error is `Lock acquisition rejected!`.

</details>

<details><summary>reset(): void</summary>
<br />
Reset the Object (will reject if any locks or promises are detected active).

</details>

## Dependencies

This project have no dependencies.

## License
MIT
npm package: @slimio/logger
Description: SlimIO Sonic Logger
Author: SlimIO
Latest version: 0.1.2

# Logger
![version](https://img.shields.io/badge/version-0.1.0-blue.svg)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/SlimIO/is/commit-activity)
![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)

SlimIO Sonic Logger. Very simple logger designed to be used in SlimIO. This package is inspired by pino logger.

## Requirements
- [Node.js](https://nodejs.org/en/) v10 or higher

## Getting Started

This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).

```bash
$ npm i @slimio/logger
# or
$ yarn add @slimio/logger
```

## Usage example
```js
const log = new Logger(void 0, {
    title: "MY-LOG"
});
for (let id = 0; id < 10; ++id) {
    log.writeLine("hello world!");
}

// end and flush writestream.
await log.close();
```

## API

### constructor(fd?: string | number, options?: Logger.ConstructorOptions)
Create a new Logger. The default value of `fd` is `process.stdout.fd`.

Options is described by the following TypeScript interface:
```ts
interface ConstructorOptions {
    title?: string;
    local?: string;
}
```

### writeLine(msg?: string): void
Write a new line in the write stream. If the **msg** is undefined or equal to Empty String, then we write `\n` in the WriteStream.

```js
log.writeLine("hello");
log.writeLine(void 0);
log.writeLine("bye bye !");
```

It will produce the following stdout
```
[my-log] Jul 10, 2019, 3:24:25 PM - hello

[my-log] Jul 10, 2019, 3:24:25 PM - bye bye !
```

### close(): Promise< void >
Close and flush the stream.

## Dependencies

|Name|Refactoring|Security Risk|Usage|
|---|---|---|---|
|[flatstr](https://github.com/davidmarkclements/flatstr#readme)|Minor|Low|TBC|
|[sonic-boom](https://github.com/mcollina/sonic-boom#readme)|Minor|High|TBC|


## License
MIT
npm package: @slimio/lstree
Description: System Tree Printer
Author: SlimIO
Latest version: 0.1.0

# lstree
![V0.1.0](https://img.shields.io/badge/version-0.1.0-blue.svg)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/SlimIO/lstree/commit-activity)
![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)

System Tree Printer as CLI (with a Node.js API). Stdout to the terminal the current working dir tree.

<p align="center">
    <img src="https://i.imgur.com/PTo2okT.png">
</p>

## Requirements
- Node.js v10 or higher.

## Getting Started
This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).

```bash
$ npm install @slimio/lstree -g
# or
$ npx @slimio/lstree
```

## Usage example
The package can be used as a binary command or as an API.

```js
const tree = require("@slimio/lstree");
const lstree = tree({ depth: 2, ignore: ["test"] });

lstree(process.cwd()).catch(console.error);
```

To use it as a cmd:
```bash
$ lstree -d 2
```

Available script arguments are:

| name | type | defaultValue |
| --- | --- | --- |
| -d --depth | number | **0** |
| -s --showfd | boolean | **false** |
| -i --ignore | array | **[]** |


## API

### three(options?: lstree.options): lstree
Create a new lstree clojure function. Available options are:
```ts
interface options {
    ignore?: string[];
    description?: Map<string, string>;
    depth?: number;
    showFilesDescriptor?: boolean;
}
```

Default ignored files and directories are: `node_modules`, `coverage`, `docs`, `.nyc_output`, `.git`.

### lstree(dir: string, depth?: number): Promise< void >
Call lstree at the wanted location. lstree is an Asynchronous function.

```js
lstree(__dirname).catch(console.error);
```

## License
MIT
npm package: @slimio/micro
Description: NodeJS C NAPI low level binding to get high resolution timestamp (in microseconds)
Author: SlimIO
Latest version: 0.1.0

# Micro

NodeJS C++ NAPI low level binding to get high resolution timestamp.

This API is synchronous.

## Getting Started

This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).

```bash
$ npm i @slimio/micro
# or
$ yarn add @slimio/micro
```

## Usage example

```js
const { now, gettimeofday, clock } = require("@slimio/micro");

console.log(now()); // 1538484472718548
console.log(gettimeofday()); // { sec: 1538484493, usec: 222313 }
console.log(clock.now());
console.log(clock.gettime());
```

## API

### now(): number
Return the current timestamp as **microsecond**. You can achieve the same result with gettimeofday():
```js
const tv = micro.gettimeofday();
const now = (tv.sec * 1000000) + tv.usec;
console.log(now); // 1538484472718548
```

> Warning: Micro.now() suffers the effects of drift like Date.now()

### gettimeofday(): timeval
UNIX gettimeofday binding (polyfill has been added for Windows too). Return a **timeval** interface Object.
```ts
interface timeval {
    sec: number;
    usec: number;
}

export function gettimeofday(): timeval;
```

### clock.gettime(): timespec;
UNIX clock_gettime binding (polyfill has been added for Windows too). Return a **timespec** interface Object. This method work like NodeJS process.hrtime.

### clock.now(): number;
Return a millisecond no-drift timestamp. You can achieve the same with `clock.gettime()`:

```js
const { sec, usec } = micro.clock.gettime();
console.log(sec * 1e3 + usec / 1e6);

// same as:
console.log(micro.clock.now());
```

## How to build the project

Before building the project, be sure to get the following npm package installed:

- Install (or upgrade to) NodeJS v10+ and npm v6+
- [Windows build tools](https://www.npmjs.com/package/windows-build-tools)

Then, just run normal npm install command:

```bash
$ npm install
```

## Available commands

All projects commands are described here:

| command | description |
| --- | --- |
| npm run prebuild | Generate addon prebuild |
| npm run doc | Generate JSDoc .HTML documentation (in the /docs root directory) |
| npm run coverage | Generate coverage of tests |
| npm run report | Generate .HTML report of tests coverage |

> the report command have to be triggered after the coverage command.
npm package: @slimio/oop
Description: JavaScript OOP library
Author: SlimIO
Latest version: 2.0.0

# Oop
![version](https://img.shields.io/badge/dynamic/json.svg?url=https://raw.githubusercontent.com/SlimIO/oop/master/package.json&query=$.version&label=version)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/SlimIO/oop/commit-activity)
![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)
![dep](https://img.shields.io/david/SlimIO/oop)
![size](https://img.shields.io/github/languages/code-size/SlimIO/oop)
![known vulnerabilities](https://img.shields.io/snyk/vulnerabilities/github/SlimIO/oop)
[![Build Status](https://travis-ci.com/SlimIO/oop.svg?branch=master)](https://travis-ci.com/SlimIO/oop)

JavaScript OOP library created to help designing behaviorial and meta based code. The idea is to resonate much more in pure object and avoid any explicit assertion. Also one of the big point is to prefer conversion over strict type (ADT).

One of the long-term goals is to find a model to work with the autognosis rule.

> An autognostic object can only have detailed knowledge of itself.

## Requirements
- [Node.js](https://nodejs.org/en/) v12 or higher

## Getting Started

This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).

```bash
$ npm i @slimio/oop
# or
$ yarn add @slimio/oop
```

## Usage example

```js
import { toIterable } from "@slimio/oop";

function doTheWork(anyValue) {
    const iter = toIterable(anyValue);

    for (const item of iter) {
        console.log(item);
    }
}

doTheWork(new Set([1, 2, 3]));
doTheWork(["foo", "bar"]);
```

## API

```ts
declare namespace oop {
    export function toNumber(value: bigint): bigint;
    export function toNumber(value: any): number;
    export function toString(value: any): string;
    export function toSymString(value: symbol): symbol;
    export function toSymString(value: any): string;
    export function toBigInt(value: any): bigint;
    export function toIterable(value: Iterable<any>): Iterable<any>
    export function toIterable(value: Array<any> | ArrayLike<any>): Array<any>;
    export function toPlainObject(value: Iterable<any> | null | undefined | object, handleNullAndUndefined?: boolean): object;
    export function toNullableString(value: any): string;
    export function toNullableString(value: null | undefined): null;
    export function toNullableNumber(value: bigint): bigint;
    export function toNullableNumber(value: null | undefined): null;
    export function toNullableNumber(value: any): number;
    export function toNullableBoolean(value: any): boolean;
    export function toNullableBoolean(value: null | undefined): null;

    export namespace utils {
        export function toNullable(predicate: (value: any) => any): Function;
    }
}

export = oop;
export as namespace oop;
```

## Dependencies
This project have no dependencies.

## License
MIT
npm package: @slimio/pretty-json
Description: Stdout JSON in your terminal
Author: SlimIO
Latest version: 1.3.0

# pretty-json
![version](https://img.shields.io/badge/dynamic/json.svg?url=https://raw.githubusercontent.com/SlimIO/Pretty-JSON/master/package.json?token=AOgWw3vrgQuu-U4fz1c7yYZyc7XJPNtrks5catjdwA%3D%3D&query=$.version&label=Version)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/SlimIO/Pretty-JSON/commit-activity)
![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)
![dep](https://img.shields.io/david/SlimIO/Pretty-JSON)
![size](https://img.shields.io/bundlephobia/min/@slimio/pretty-json)
[![Known Vulnerabilities](https://snyk.io//test/github/SlimIO/Pretty-JSON/badge.svg?targetFile=package.json)](https://snyk.io//test/github/SlimIO/Pretty-JSON?targetFile=package.json)
[![Build Status](https://travis-ci.com/SlimIO/Pretty-JSON.svg?branch=master)](https://travis-ci.com/SlimIO/Pretty-JSON)
[![Greenkeeper badge](https://badges.greenkeeper.io/SlimIO/Pretty-JSON.svg)](https://greenkeeper.io/)

Stdout JSON in your terminal with colors. This package has been created to stdout clean and beautiful JSON in the SlimIO CLI.

## Requirements
- [Node.js](https://nodejs.org/en/) v10 or higher

## Getting Started

This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).

```bash
$ npm i @slimio/pretty-json
# or
$ yarn add @slimio/pretty-json
```

## Usage example
```js
const prettyJSON = require("@slimio/pretty-json");

prettyJSON({
    foo: "bar",
    hello: "world!",
    arr: [1, 2, 3]
});
```

It will produce the following stdout:

![stdout](https://i.imgur.com/R3fUoQH.png)

## API

### prettyJSON(obj: object): void
Stdout a given JSON Object (Plain Object, Objects Prototype of Object or Array).

## Dependencies

|Name|Refactoring|Security Risk|Usage|
|---|---|---|---|
|[@slimio/is](https://github.com/SlimIO/is)|Minor|Low|Type checker|
|[kleur](https://github.com/lukeed/kleur)|Minor|Low|TTY color|

## License
MIT
npm package: @slimio/pretty-stack
Description: Pretty Stack Trace to stdout in TTY
Author: SlimIO
Latest version: 0.4.2

# pretty-stack
![version](https://img.shields.io/badge/dynamic/json.svg?url=https://raw.githubusercontent.com/SlimIO/pretty-stack/master/package.json&query=$.version&label=Version)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/SlimIO/pretty-stack/commit-activity)
![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)
![dep](https://img.shields.io/david/SlimIO/pretty-stack)
![size](https://img.shields.io/github/languages/code-size/SlimIO/pretty-stack)
![known vulnerabilities](https://img.shields.io/snyk/vulnerabilities/github/SlimIO/pretty-stack)
[![Build Status](https://travis-ci.com/SlimIO/pretty-stack.svg?branch=master)](https://travis-ci.com/SlimIO/pretty-stack)
[![Greenkeeper badge](https://badges.greenkeeper.io/SlimIO/pretty-stack.svg)](https://greenkeeper.io/)

Pretty Stack Trace to stdout in TTY. Use clean-stack of sindresorhus under the hood to improve the whole experience.

<p align="center">
    <img src="https://i.imgur.com/YSPu6oV.png">
</p>

## Requirements
- [Node.js](https://nodejs.org/en/) v12 or higher

## Getting Started

This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).

```bash
$ npm i @slimio/pretty-stack
# or
$ yarn add @slimio/pretty-stack
```

## Usage example
```js
const prettyStack = require("@slimio/pretty-stack");

const err = new Error("hello world!");
prettyStack(err, true);
// or go with the stack array
prettyStack(err.stack, false);
```

## API

### prettyStack(error: Error | string | string[], printFile?: boolean): void
This method can handle many input types. In case the input is a string it will be splitted by `\n`.

## Dependencies

|Name|Refactoring|Security Risk|Usage|
|---|---|---|---|
|[clean-stack](https://github.com/sindresorhus/clean-stack#readme)|Minor|Low|Cleanup Javascript stack-trace|
|[kleur](https://github.com/lukeed/kleur)|Minor|Low|The fastest Node.js library for formatting terminal text with ANSI colors~!|

## License
MIT
npm package: @slimio/profiles
Description: Addon profiles manager
Author: SlimIO
Latest version: 0.1.2

# Profiles
![version](https://img.shields.io/badge/version-0.1.0-blue.svg)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/SlimIO/is/commit-activity)
![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)

Addon profiles manager.

## Requirements
- [Node.js](https://nodejs.org/en/) v10 or higher

## Getting Started
This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).

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

## Usage example
```js
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
```ts
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](https://github.com/SlimIO/Config#readme)|Minor|High|TBC|
|[@slimio/is](https://github.com/SlimIO/is)|Minor|Low|Type checker|
|[@slimio/safe-emitter](https://github.com/SlimIO/Safe-emitter)|Minor|Medium|Node.js Safe Emitter|
|[@slimio/scheduler](https://github.com/SlimIO/Scheduler#readme)|Minor|Low|TBC|
|[@slimio/timer](https://github.com/SlimIO/Timer)|Minor|Low|Driftless interval|
|[ms](https://github.com/zeit/ms#readme)|⚠️Major|Low|TBC|

## License
MIT
npm package: @slimio/queue
Description: Simple Node.js Queue
Author: SlimIO
Latest version: 0.2.1

# Queue

[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/SlimIO/Queue/commit-activity)
[![GitHub license](https://img.shields.io/github/license/Naereen/StrapDown.js.svg)](https://github.com/SlimIO/Queue/blob/master/LICENSE)
![V1.0](https://img.shields.io/badge/version-0.2.1-blue.svg)
[![Known Vulnerabilities](https://snyk.io/test/github/SlimIO/Queue/badge.svg?targetFile=package.json)](https://snyk.io/test/github/SlimIO/Queue?targetFile=package.json)

SlimIO - Simple Queue system

## Getting Started

This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).

```bash
$ npm i @slimio/queue
# or
$ yarn add @slimio/queue
```

## Usage exemple

```js
const Queue = require("@slimio/queue");
const queue = new Queue();

queue.enqueue("foo", "bar");
console.log(queue.idLenght("foo")); // 1
console.log(queue.dequeue("foo")); // "bar"
```

## API
```ts
declare namespace Queue {
    type id = string|number|symbol;
}
```

### Queue.enqueue(id: Queue.id, value: any): void;
Enqueue data in a queue
```js
const queue = new Queue();

queue.enqueue(100, 1);
queue.enqueue(100, 2);

queue.enqueue("foo", "bar");
```

### Queue.dequeue(id: Queue.id): any;
Dequeue the first data that was enqueued in a queue
```js
const queue = new Queue();

queue.enqueue(100, 1);
queue.enqueue("foo", "bar");

console.log(queue.dequeue(100)); // 1
console.log(queue.dequeue("foo")); // "bar"
```

### Queue.dequeueAll(id: Queue.id): Iterator<any>;
Dequeue all data that was enqueued in a queue
```js
const queue = new Queue();

queue.enqueue(100, 1);
queue.enqueue(100, 2);
queue.enqueue(100, 3);

const data = [...queue.dequeueAll(100)];
console.log(data); // [1, 2, 3]
```

### Queue.has(id: Queue.id): boolean;
Check if a QueueID exist
```js
const queue = new Queue();

queue.enqueue("foo", "bar");

console.log(queue.has("foo")); // true
console.log(queue.has("fo")); // false
```

### Queue.ids(): string[];
Get all queues keys
```js
const queue = new Queue();

queue.enqueue(100, 1);
queue.enqueue("foo", "bar");
queue.enqueue("test", 20);

console.log(queue.ids()); // [100, "foo", "test"]
```

### Queue.idLength(id: Queue.id): Number;
Return the number of elements of a given QueueID.
```js
const queue = new Queue();

queue.enqueue("test", 20);
queue.enqueue("test", 21);
queue.enqueue("test", 22);

console.log(queue.idLength("test")); // 3
```

## LICENCE
MIT
npm package: @slimio/stdin
Description: Node.js light standard input (stdin) crafted for REPL experience
Author: SlimIO
Latest version: 1.0.3

# Stdin
![version](https://img.shields.io/badge/dynamic/json.svg?url=https://raw.githubusercontent.com/SlimIO/stdin/master/package.json&query=$.version&label=Version)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/SlimIO/stdin/commit-activity)
![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)
![dep](https://img.shields.io/david/SlimIO/stdin)
![size](https://img.shields.io/github/languages/code-size/SlimIO/stdin)

Node.js light standard input (stdin) crafted for REPL experience

## Requirements
- [Node.js](https://nodejs.org/en/) v10 or higher

## Getting Started

This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).

```bash
$ npm i @slimio/stdin
# or
$ yarn add @slimio/stdin
```

## Usage example
```js
const stdin = require("@slimio/stdin");

async function main() {
    const result = await stdin("Question title > ", {
        history: ["command in history 1", "command in history 2"],
        autocomplete: [
            "events",
            "events.get_info"
        ]
    });
    console.log(result);
}
main().catch(console.error);
```

## API

### stdin(query: null | string, options?: Options): Promise< string >
Query paramaters can be set to `null` to disable the title. Options is described by the following TypeScript interface:

```ts
interface Options {
    history?: string[];
    autocomplete?: string[];
}
```

## Dependencies

|Name|Refactoring|Security Risk|Usage|
|---|---|---|---|
|[fast-levenshtein](https://github.com/hiddentao/fast-levenshtein#readme)|Major|Low|Implementation of levenshtein algo to found similar strings for auto-completion|
|[string-length](https://github.com/sindresorhus/string-length#readme)|Major|Low|Get the real string length|

## License
MIT
npm package: @slimio/tarball
Description: SlimIO archive tarball packer/extractor
Author: SlimIO
Latest version: 0.1.0

# Tarball
![version](https://img.shields.io/badge/version-0.1.0-blue.svg)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/SlimIO/is/commit-activity)
![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)

SlimIO archive (for addons and modules) tarball packer/extractor.

## Requirements
- [Node.js](https://nodejs.org/en/) v10 or higher

## Getting Started

This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).

```bash
$ npm i @slimio/tarball
# or
$ yarn add @slimio/tarball
```

## Usage example
```js
const { pack, extract } = require("@slimio/tarball");
const { resolve } = require("path");

async function main() {
    const archiveName = resolve("myArchive.tar");

    // Create .tar archive
    await pack(resolve("directory"), archiveName);

    // Extract .tar to the given directory
    await extract(archiveName, resolve("directoryBis"), {
        deleteTar: true
    });
}
main().catch(console.error);
```

## API

### pack(location: string, destination: string, options?: PackOptions): Promise< void >
Pack a location (that must be a directory) into a **tar** archive.

Options is described by the following interface:
```ts
interface PackOptions {
    include?: Set<string>;
}
```

Example that include only `index.js` & `slimio.toml`:
```js
await pack("./myAddon", "myAddon.tar", {
    include: new Set(["index.js", "slimio.toml"])
});
```

### extract(location: string, destination: string, options?: ExtractOptions): Promise< void >
Extract a **tar** archive to a given destination.

Options is described by the following interface:
```ts
interface ExtractOptions {
    deleteTar?: boolean;
    deleteDestinationOnFail?: boolean;
}
```

By default **deleteTar** and **deleteDestinationOnFail** are equal to **false**.

## Dependencies

|Name|Refactoring|Security Risk|Usage|
|---|---|---|---|
|[premove](https://github.com/lukeed/premove#readme)|Minor|Low|Recursive unlink/rmdir|
|[tar-fs](https://github.com/mafintosh/tar-fs)|Minor|High|Pack and extract .tar archive|
|[uuid](https://github.com/kelektiv/node-uuid#readme)|Minor|Low|Generate unique id for temporary filename|

## License
MIT
npm package: @slimio/tcp-sdk
Description: SlimIO TCP Socket SDK
Author: SlimIO
Latest version: 0.4.6

# Tcp-Sdk
SlimIO TCP Socket SDK. This package has been created to help developer to communicate with the production (Socket addon).

## Requirements
- Node.js v10 or higher

## Getting Started

This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).

```bash
$ npm i @slimio/tcp-sdk
# or
$ yarn add @slimio/tcp-sdk
```

## Usage example

```js
const TcpSdk = require("@slimio/tcp-sdk");
const CONNECT_TIMEOUT_MS = 1000;

async function main() {
    const client = new TcpSdk();
    await client.once("connect", CONNECT_TIMEOUT_MS);

    const info = await new Promise((resolve, reject) => {
        client.sendMessage("cpu.get_info").subscribe(resolve, reject);
    });
    console.log(info);

    client.close();
}
```

## API

<details><summary>constructor(options?: TcpClient.ConstructorOptions)</summary>

Create and instanciate a new TCP Connection to the socket server. Listen for event **connection** to known when you'r ready to send messages.

Options is described by the following interface:
```ts
interface ConstructorOptions {
    host?: string;
    port?: number;
}
```

Default value of port would be **TcpClient.DEFAULT_PORT**.
</details>

<details><summary>getActiveAddons(): Promise< String[] ></summary>

Return the list of active addons on the current agent.
</details>

<details><summary>ping(): Promise< void ></summary>

Send a ping event (avoid timeout).
</details>

<details><summary>sendMessage(target: string, args?: any[]): ZenObservable.ObservableLike< any ></summary>

send a callback message.
</details>

<details><summary>sendOne< T >(target: string, args?: any[]): Promise< any ></summary>

send a callback message wrapped by a Promise.
</details>

<details><summary>connect(): Promise< void ></summary>

Connect (or re-connect) the Net.socket. If the Socket is alive it will return.
</details>

<details><summary>close(): void</summary>

Close the TCP (Socket) connection.
</details>

### Properties

<details><summary>readonly agent(): TcpClient.AgentInfo | null</summary>

The readonly getter is described by the following TypeScript interface:
```ts
interface AgentInfo {
    location: string;
    version: string;
}
```
</details>

## Dependencies

|Name|Refactoring|Security Risk|Usage|
|---|---|---|---|
|[@slimio/safe-emitter](https://github.com/SlimIO/safeEmitter#readme)|Minor|Medium|Node.js Safe Emitter|
|[zen-observable](https://github.com/zenparsing/zen-observable)|Minor|Low|Observable Implementation|

## License
MIT
npm package: @slimio/text-align
Description: A wide-character aware text alignment function for use in terminals / on the console.
Author: SlimIO
Latest version: 1.0.0

# text-align
![version](https://img.shields.io/badge/dynamic/json.svg?url=https://raw.githubusercontent.com/SlimIO/text-align/master/package.json&query=$.version&label=Version)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/SlimIO/text-align/commit-activity)
![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)
![dep](https://img.shields.io/david/SlimIO/text-align)
![size](https://img.shields.io/github/repo-size/SlimIO/text-align)
![known vulnerabilities](https://img.shields.io/snyk/vulnerabilities/github/SlimIO/text-align)
[![Build Status](https://travis-ci.com/SlimIO/text-align.svg?branch=master)](https://travis-ci.com/SlimIO/text-align)

A wide-character aware text alignment function for use in terminals / on the console. This package is a modern implementation of [wide-align](https://github.com/iarna/wide-align) with String.prototype.padLeft and String.prototype.padRight.

## Requirements
- [Node.js](https://nodejs.org/en/) v12 or higher

## Getting Started

This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).

```bash
$ npm i @slimio/text-align
# or
$ yarn add @slimio/text-align
```

### Usage example

```js
const align = require("@slimio/text-align");

console.log(align.center('abc', 10));     // '   abc    '
console.log(align.center('古古古', 10));   // '  古古古  '
console.log(align.left('abc', 10));       // 'abc       '
console.log(align.left('古古古', 10));     // '古古古    '
console.log(align.right('abc', 10));      // '       abc'
console.log(align.right('古古古', 10));    // '    古古古'
```

## API

### `align.center(str: string, length: number)` → string
Returns *str* with spaces added to both sides such that that it is *length*
chars long and centered in the spaces.

### `align.left(str: string, length: number)` → string
Returns *str* with spaces to the right such that it is *length* chars long.

### `align.right(str: string, length: number)` → string
Returns *str* with spaces to the left such that it is *length* chars long.

## Dependencies

|Name|Refactoring|Security Risk|Usage|
|---|---|---|---|
|[@slimio/wcwidth](https://github.com/SlimIO/wcwidth)|Minor|Low|Determine columns needed for a fixed-size wide-character string|

## License
MIT
npm package: @slimio/timer
Description: SlimIO - NodeJS Driftless &amp; Safe Timers
Author: SlimIO
Latest version: 1.0.2

# Timer
![Version](https://img.shields.io/badge/dynamic/json.svg?url=https://raw.githubusercontent.com/SlimIO/Timer/master/package.json?token=Aeue0P3eryCYRikk9tHZScyXOpqtMvFIks5ca-XwwA%3D%3D&query=$.version&label=Version)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/SlimIO/Timer/commit-activity)
![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)
![dep](https://img.shields.io/david/SlimIO/Timer.svg)
![size](https://img.shields.io/github/repo-size/SlimIO/Timer.svg)
[![Known Vulnerabilities](https://snyk.io/test/github/SlimIO/Timer/badge.svg?targetFile=package.json)](https://snyk.io/test/github/SlimIO/Timer?targetFile=package.json)
[![Build Status](https://travis-ci.com/SlimIO/Timer.svg?branch=master)](https://travis-ci.com/SlimIO/Timer) [![Greenkeeper badge](https://badges.greenkeeper.io/SlimIO/Timer.svg)](https://greenkeeper.io/)

SlimIO - Node.js Driftless Interval Timer. This package is inspired by [driftless](https://github.com/dbkaplun/driftless)

> ⚠️ This package is experimental (Please dont use it outside).

## Requirements
- [Node.js](https://nodejs.org/en/) v10 or higher

## Getting Started

This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).

```bash
$ npm i @slimio/timer
# or
$ yarn add @slimio/timer
```

## Why

Node.js timer (interval and timeout) drift with the time. This package aim to implement a no-drift setInterval.

## Usage example

```js
const timer = require("@slimio/timer");

const timerId = timer.setInterval(() => {
    console.log("hello world!");
}, 1000);

// Later...
timer.clearInterval(timerId);
```

## API

### timer.setInterval(handler: Function, intervalMs: number): number
Create a new interval. Same API as Node.js !

### timer.clearInterval(intervalId: number): void
Clear a given interval id (the number returned by setInterval).

## Dependencies
This project have no dependencies.

## License
MIT
npm package: @slimio/tsd
Description: SlimIO TypeScript definition
Author: SlimIO
Latest version: 0.2.0

# tsd
![V0.2.0](https://img.shields.io/badge/version-0.2.0-blue.svg)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/SlimIO/github/commit-activity)
![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)

SlimIO TypeScript definition

## Getting started

This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).

```bash
$ npm i @slimio/tsd -D
```

## Usage example
Include the ref in your project `d.ts` files !
```ts
/// <reference types="@slimio/tsd" />
```

## Members

### interfaces

<details><summary>SlimIO.RawEntity</summary>
<br />

```ts
interface RawEntity {
    name: string;
    description: string;
    descriptors?: {
        [key: string]: string;
    };
    parent?: number;
}
```
</details>

<details><summary>SlimIO.RawIdentityCard</summary>
<br />

```ts
interface RawIdentityCard {
    unit: string;
    entityId: number;
    description?: string;
    max?: number;
    interval?: number;
}
```
</details>

<details><summary>SlimIO.RawAlarm</summary>
<br />

```ts
interface RawAlarm {
    message: string;
    entityId: number;
    correlateKey: string;
    severity: number;
}
```
</details>

### enum

<details><summary>SlimIO.AlarmSeverity</summary>
<br />

```ts
enum AlarmSeverity {
    Critical,
    Major,
    Minor
}
```
</details>

### types

<details><summary>SlimIO.CID</summary>
<br />

```ts
type CID = string;
```
</details>

## License
MIT
npm package: @slimio/unit-testing
Description: SlimIO Unit testing framework
Author: SlimIO
Latest version: 1.0.0

# unit-testing
![version](https://img.shields.io/badge/version-1.0.0-blue.svg)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/SlimIO/is/commit-activity)
![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)

Simple, secure and blazing fast Unit testing framework with no assert lib.

## Requirements
- [Node.js](https://nodejs.org/en/) v12 or higher

## Goals
- Avoid fancy and useless features.
- No bundled assertion framework (chose what you want).
- The best startup across packages.
- Synchronous and Asynchronous Unit-testing (with Worker threads API).
- Keep it simple and secure as hell.

## Getting Started

This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).

```bash
$ npm i @slimio/unit-testing
# or
$ yarn add @slimio/unit-testing
```

## Usage example
```js
import test from "@slimio/unit-testing";
import { strict as assert } from "assert";

test.before = function before() {
    console.log("before");
};

test("plan 1 must be ok", (curr) => {
    curr.plan(1);
    curr.pass();
});

test("true must be false", () => {
    assert.equal(true, false, "expect true to be strict equal to false");
});
```

## API
TBC

## Dependencies

|Name|Refactoring|Security Risk|Usage|
|---|---|---|---|
|[@slimio/is](https://github.com/SlimIO/is)|Minor|Low|Type checker|
|[@slimio/pretty-stack](https://github.com/SlimIO/pretty-stack#readme)|Minor|High|TBC|
|[kleur](https://github.com/lukeed/kleur)|Minor|Low|TTY color|

## License
MIT
npm package: @slimio/unzipper
Description: SlimIO unzipper
Author: SlimIO
Latest version: 0.2.0

# Unzipper
![Version](https://img.shields.io/badge/dynamic/json.svg?url=https://raw.githubusercontent.com/SlimIO/unzipper/master/package.json?token=Aeue0P3eryCYRikk9tHZScyXOpqtMvFIks5ca-XwwA%3D%3D&query=$.version&label=Version)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/SlimIO/unzipper/commit-activity)
![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)
![dep](https://img.shields.io/david/SlimIO/unzipper.svg)
![size](https://img.shields.io/bundlephobia/min/@slimio/unzipper.svg)
[![Known Vulnerabilities](https://snyk.io/test/github/SlimIO/unzipper/badge.svg?targetFile=package.json)](https://snyk.io/test/github/SlimIO/unzipper?targetFile=package.json)
[![Build Status](https://travis-ci.com/SlimIO/unzipper.svg?branch=master)](https://travis-ci.com/SlimIO/unzipper) [![Greenkeeper badge](https://badges.greenkeeper.io/SlimIO/unzipper.svg)](https://greenkeeper.io/)

Modern unzipper with support of `async/await`. This module use [yauzl](https://github.com/thejoshwolfe/yauzl) under the hood and has been designed to replace [extract-zip](https://github.com/maxogden/extract-zip#readme).

## Requirements
- [Node.js](https://nodejs.org/en/) v10 or higher

## Getting Started

This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).

```bash
$ npm i @slimio/unzipper
# or
$ yarn add @slimio/unzipper
```

## Usage example
```js
const { join } = require("path");
const unzip = require("@slimio/unzipper");

const filePath = "your/zip/file.zip";
await unzip(filePath);
// or
await unzip(filePath, { dir: join(__dirname, "yourDirectory") });
```

## API

### Unzipper(filePath: string, options?: Unzipper.ConstructorOptions): void

Extract a zip file

> ⚠️ dir must be an absolute path.

Available options are described by the following TypeScript interface:
```ts
interface ConstructorOptions {
    dir?: string;
    log?: boolean;
}
```

- `dir` : unzip directory target. (Default: `process.cwd()`)
- `log` : Log directories and files path (Default: `false`).

## Dependencies

|Name|Refactoring|Security Risk|Usage|
|---|---|---|---|
|[yauzl](https://github.com/thejoshwolfe/yauzl)|⚠️Major|High|Unzipper for Node.js|

## License
MIT
npm package: @slimio/validate-addon-name
Description: SlimIO Addon name validator/sanitizer
Author: SlimIO
Latest version: 1.2.0

# Validate-addon-name
![version](https://img.shields.io/badge/dynamic/json.svg?url=https://raw.githubusercontent.com/SlimIO/validate-addon-name/master/package.json&query=$.version&label=Version)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/SlimIO/validate-addon-name/commit-activity)
![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)
![dep](https://img.shields.io/david/SlimIO/validate-addon-name)
![size](https://img.shields.io/github/languages/code-size/SlimIO/validate-addon-name)
[![Known Vulnerabilities](https://snyk.io//test/github/SlimIO/validate-addon-name/badge.svg?targetFile=package.json)](https://snyk.io//test/github/SlimIO/validate-addon-name?targetFile=package.json)
[![Build Status](https://travis-ci.com/SlimIO/validate-addon-name.svg?branch=master)](https://travis-ci.com/SlimIO/validate-addon-name)
[![Greenkeeper badge](https://badges.greenkeeper.io/SlimIO/validate-addon-name.svg)](https://greenkeeper.io/)

SlimIO Addon name validator/sanitizer. This package has been created to centralize **validation** and **sanitization** of addons names. So if tomorrow we decide to change the way addon name are constructed we only need to update the package everywhere.

## Requirements
- [Node.js](https://nodejs.org/en/) v12 or higher

## Getting Started

This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).

```bash
$ npm i @slimio/validate-addon-name
# or
$ yarn add @slimio/validate-addon-name
```

## Usage example
```js
const assert = require("assert").strict;
const { validate, sanitize } = require("@slimio/validate-addon-name");

// Validate addon name
assert.equal(validate("Addon"), false);
assert.equal(validate("myaddon5"), true);
assert.equal(validate("1"), false);

// Sanitize addon name
assert.equal(sanitize("Addon-Name"), "addonname");
assert.equal(sanitize("??CPU-DB>>"), "cpudb");
```

## API

### validate(addonName: string): boolean
Validate and return a boolean to tell if the name is a valid and acceptable name for a SlimIO Addon. This method does not throw if **addonName** is not a string (it will return false instead).

```js
validate(10); // false
```

### sanitize(addonName: string): string
Remove non-valid (wide) characters from a given string. This method will throw a TypeError if **addonName** is not a string primitive.

```js
sanitize(10); // Throw
```

### decamelize(str: string): string
Decamelize a string and transform it to **snake_case**.

```js
decamelize("sayHello"); // say_hello
```

### CONSTANTS
The package export a freezed **CONSTANTS** object that contain a **VALIDATE_REGEX** key.

```js
const { validate, CONSTANTS } = require("@slimio/validate-addon-name");

const addonName = "Addon";
if (!validate(addonName)) {
    console.log(`addon '${addonName}' not matching expected regex ${CONSTANTS.VALIDATE_REGEX}`)
}
```

## Dependencies
This project have no dependencies.

## License
MIT
npm package: @slimio/wcwidth
Description: Port of C's wcwidth() and wcswidth()
Author: SlimIO
Latest version: 1.0.0

# wcwidth
![version](https://img.shields.io/badge/dynamic/json.svg?url=https://raw.githubusercontent.com/SlimIO/wcwidth/master/package.json?token=AOgWw3vrgQuu-U4fz1c7yYZyc7XJPNtrks5catjdwA%3D%3D&query=$.version&label=Version)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/SlimIO/wcwidth/commit-activity)
![MIT](https://img.shields.io/github/license/mashape/apistatus.svg)
![dep](https://img.shields.io/david/SlimIO/wcwidth)
[![Known Vulnerabilities](https://snyk.io//test/github/SlimIO/wcwidth/badge.svg?targetFile=package.json)](https://snyk.io//test/github/SlimIO/wcwidth?targetFile=package.json)
[![Build Status](https://travis-ci.com/SlimIO/wcwidth.svg?branch=master)](https://travis-ci.com/SlimIO/wcwidth)

Determine columns needed for a fixed-size wide-character string

> wcwidth is a simple JavaScript port of [wcwidth](http://man7.org/linux/man-pages/man3/wcswidth.3.html) implemented in C by Markus Kuhn.
>
> JavaScript port [originally](https://github.com/mycoboco/wcwidth.js) written by Woong Jun <woong.jun@gmail.com> (http://code.woong.org/)

## Why

This package is a fork of [wcwidth](https://github.com/timoxley/wcwidth#readme).

- Drop old Node.js version support.
- Drop useless `defaults` package wich introduce an indirect dependencies.
- Cleanup npm tarball (only ship required files).
- Supported by the SlimIO Team.

## Requirements
- [Node.js](https://nodejs.org/en/) v10 or higher

## Getting Started

This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).

```bash
$ npm i @slimio/wcwidth
# or
$ yarn add @slimio/wcwidth
```

## Usage example

```js
const wcwidth = require("@slimio/wcwidth");

'한'.length    // => 1
wcwidth('한');   // => 2

'한글'.length    // => 2
wcwidth('한글'); // => 4
```

`wcwidth()` and its string version, `wcswidth()` are defined by IEEE Std
1002.1-2001, a.k.a. POSIX.1-2001, and return the number of columns used
to represent the given wide character and string.

Markus's implementation assumes the wide character given to those
functions to be encoded in ISO 10646, which is almost true for
JavaScript's characters.

[Further explaination here](https://github.com/timoxley/wcwidth/tree/master/docs)

## API
TBC

## Dependencies
This project have no dependencies.

## License
MIT
npm package: @slimio/winelog
Description: Windows Events log reader - low-level C++/Node.js N-API binding
Author: SlimIO
Latest version: 1.0.0

# Winelog
![version](https://img.shields.io/badge/dynamic/json.svg?url=https://raw.githubusercontent.com/SlimIO/Winelog/master/package.json&query=$.version&label=Version)
![N-API](https://img.shields.io/badge/N--API-v3-green.svg)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/SlimIO/Winelog/commit-activity)
[![mit](https://img.shields.io/github/license/Naereen/StrapDown.js.svg)](https://github.com/SlimIO/Winelog/blob/master/LICENSE)
![dep](https://img.shields.io/badge/Dependencies-2-yellow.svg)
![size](https://img.shields.io/github/languages/code-size/SlimIO/winelog)
![known vulnerabilities](https://img.shields.io/snyk/vulnerabilities/github/SlimIO/winelog)
[![Build Status](https://travis-ci.com/SlimIO/Winelog.svg?branch=master)](https://travis-ci.com/SlimIO/Winelog)
[![Greenkeeper badge](https://badges.greenkeeper.io/SlimIO/Winelog.svg)](https://greenkeeper.io/)

Windows Events log reader - Node.JS low-level binding

## Requirements
- [Node.js](https://nodejs.org/en/) v13 or higher

## Getting Started

This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).

```bash
$ npm i @slimio/winelog
# or
$ yarn add @slimio/winelog
```

## Usage example
```js
const { readEventLog, files } = require("@slimio/winelog");

async function main() {
    for await (const event of readEventLog(files.Security)) {
        console.log(event);
        break;
    }
}
main().catch(console.error);
```

## API

<details>
<summary>readEventLog(logName: keyof EventsLogFiles, reverseDirection?: boolean): AsyncIterableIterator< EventLog ></summary>
<br />

Read a given event log in reverse direction (direction can be updated to be forward). Return an Async Iterable that can be stopped at any time.
```ts
interface EventLog {
    eventId: number;
    providerName: string;
    providerGUID: string;
    channel: string;
    computer: string;
    timeCreated: string;
    level: number;
    task: number;
    opcode: number;
    keywords: number;
    eventRecordID: number;
    processID: number;
    threadID: number;
}
```

</details>

## Contribution Guidelines
To contribute to the project, please read the [code of conduct](https://github.com/SlimIO/Governance/blob/master/COC_POLICY.md) and the guide for [N-API compilation](https://github.com/SlimIO/Governance/blob/master/docs/native_addons.md).

## Dependencies

|Name|Refactoring|Security Risk|Usage|
|---|---|---|---|
|[node-addon-api](https://github.com/nodejs/node-addon-api)|⚠️Major|Low|Node.js C++ addon api|
|[node-gyp-build](https://github.com/prebuild/node-gyp-build)|⚠️Major|Low|Node-gyp builder|

## License
MIT