Skip to content

Repository files navigation

A set of helpers for JavaScript/Node.js

@vbarbarosh/node-helpers CI status License npm stars

@vbarbarosh/node-helpers

Installation

npm install @vbarbarosh/node-helpers

A subset of @vbarbarosh/node-helpers is available for browser:

<script src="https://unpkg.com/@vbarbarosh/node-helpers@3.78.0/dist/browser.js"></script>

⚠️ All browser functions are exposed globally.

Usage

Each helper is a single file — require exactly what you need:

const array_chunk = require('@vbarbarosh/node-helpers/src/array_chunk');
const fcmpx = require('@vbarbarosh/node-helpers/src/fcmpx');
const fs_tempdir = require('@vbarbarosh/node-helpers/src/fs_tempdir');
const http_get_json = require('@vbarbarosh/node-helpers/src/http_get_json');
const wait_while = require('@vbarbarosh/node-helpers/src/wait_while');

array_chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]

items.sort(fcmpx(['-age', 'name'])); // age desc, then name asc

await fs_tempdir(async function (d) {
    // ... `d` is removed after this function settles
});

const json = await http_get_json('https://api.example.com/items');

await wait_while(() => download_in_progress);

The full list of helpers is available at vbarbarosh.github.io/node-helpers.

Test

npm test

📖 Conventions

concurrency - limit for parallel processes.

user_friendly_status - a function that accepts a string ready to present for the end-user (i.e. string which is guaranteed contains no sensitive information like usernames or passwords).

About

A set of helpers for JavaScript/Node.js

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages