@vbarbarosh/node-helpers
v3.76.0
Published
A set of helpers for JavaScript/Node.js
Readme
A set of helpers for JavaScript/Node.js
Installation
npm install @vbarbarosh/node-helpersA subset of @vbarbarosh/node-helpers is available for browser:
<script src="https://unpkg.com/@vbarbarosh/[email protected]/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).
