npm install arc-libArc Library (arc-lib) is a unified collection of modular utilities designed for modern Node.js and browser environments.
Each submodule focuses on a specific domain β from validation and hashing to arrays, dates, and structured error handling β and can be used independently or through this aggregate package.
---
``bash`
npm install arc-lib
---
arc-lib provides an umbrella API that consolidates all core ARC libraries under a single import.
It automatically re-exports each library's default export, along with grouped error classes and utility functions.
| Library | Description |
|-----------------------|----------------------------------------------------------------------|
| arc-is | Lightweight runtime type checker (is(value) -> string) |validateTypes()
| arc-array | Extended array utilities with additional mapping and joining helpers |
| arc-check | Simple include/exclude rule engine for string validation |
| arc-date | Date/time utilities with timezone formatting and arithmetic |
| arc-events | Minimal event emitter for managing async event hooks |
| arc-hash | Consistent object, array, and string hashing (MD5, SHA256, Base64) |
| arc-object | Object manipulation helpers for key sorting, flattening, and cloning |
| arc-promise-queue | Concurrency-safe queue for managing asynchronous tasks |
| arc-reg-exp | Collection of pre-built and dynamic regular expression helpers |
| arc-router | Lightweight in-memory route matching and pattern parsing |
| arc-validate | Strong input validation via |throwByStatus()
| arc-errors | Structured HTTP-style errors and a generic helper |
| arc-logger | Lightweight, environment-aware logging and profiling |
---
`js
import ArcLib from 'arc-lib';
const { is, ArcArray, ArcErrors, validateTypes } = ArcLib;
console.log(is(123)); // 'number'
const arr = new ArcArray('A', 'B', 'C');
console.log(arr.joinCallback(v => v.toLowerCase(), '-')); // 'a-b-c'
validateTypes('example@example.com', ['email']); // passes silently
throw new ArcErrors.BadRequest('Missing parameter', { field: 'email' });
`
`js
import { validateTypes, Errors, ArcHash, PromiseQueue } from 'arc-lib';
// Validation
validateTypes('123', ['string']); // Throws if not a string
// Hashing
console.log(ArcHash.sha256('hello world'));
// Promise queue
const queue = new PromiseQueue();
queue.addToQueue(fetch('https://api.example.com/data'));
`
---
arc-lib re-exports each moduleβs primary export for direct use, and also provides a clean default bundle:
`js
import ArcLib, { Errors, validateTypes, ArcHash } from 'arc-lib';
ArcLib.ArcRouter; // router instance class
ArcLib.validateTypes; // type validation helper
Errors.NotFound; // structured HTTP error
`
The default export object has this structure:
`js`
{
is,
ArcArray,
ArcCheck,
ArcDate,
ArcEvents,
ArcHash,
ArcObject,
PromiseQueue,
ArcRegExp,
ArcRouter,
validateTypes,
Errors
}
---
`js
import { Errors } from 'arc-lib';
try {
throw new Errors.Unauthorized('Session expired');
} catch (e) {
if (e.status === 401) {
console.log('Please reauthenticate');
}
}
`
---
`js
import { PromiseQueue } from 'arc-lib';
const queue = new PromiseQueue();
queue.setAllowedActive(2);
queue.addToQueue(new Promise(r => setTimeout(r, 500)));
queue.addToQueue(new Promise(r => setTimeout(r, 500)));
queue.addToQueue(new Promise(r => setTimeout(r, 500)));
await queue.settleQueued();
console.log('All promises settled');
`
---
`js
import { ArcDate } from 'arc-lib';
const now = new ArcDate();
console.log(now.format('YYYY-MM-DD HH:mm:ss', 'America/New_York'));
`
---
`js
import { ArcRegExp } from 'arc-lib';
console.log(ArcRegExp.email.test('example@example.com')); // true
``
---