Vandium Utils

2.0.0 · active · verified Sun Apr 19

Vandium Utils is a JavaScript utility library providing a collection of common, reusable functions primarily intended for use within Vandium-io projects, though suitable for general Node.js applications. Currently at stable version 2.0.0, the library offers functionalities such as deep object cloning, date-to-ISO string conversion, various type-checking predicates (e.g., `isArray`, `isFunction`, `isObject`, `isPromise`), null/undefined checks, object emptiness determination, boolean parsing from diverse inputs, and a robust string templating engine. The library maintains a steady release cadence driven by the needs of the Vandium ecosystem. Its key differentiators include a focused set of utilities designed for serverless environments (given its association with AWS Lambda keywords), lightweight footprint, and built-in TypeScript definitions, promoting type-safe development. It supports Node.js versions 10.16 and above.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates `templateString` for string interpolation, `isObjectEmpty` for object validation, and `clone` for deep object copying.

import { templateString, isObjectEmpty, clone } from 'vandium-utils';

// Example 1: Basic string templating
const user = { name: 'Alice', city: 'Wonderland' };
const greeting = templateString('Hello ${name} from ${city}!', user);
console.log(greeting); // Expected: "Hello Alice from Wonderland!"

// Example 2: Checking for empty objects
const emptyObj = {};
const filledObj = { id: 1 };
console.log(`Is emptyObj empty? ${isObjectEmpty(emptyObj)}`); // Expected: "Is emptyObj empty? true"
console.log(`Is filledObj empty? ${isObjectEmpty(filledObj)}`); // Expected: "Is filledObj empty? false"

// Example 3: Cloning an object
const originalObject = { a: 1, b: { c: 2 } };
const clonedObject = clone(originalObject);
clonedObject.b.c = 99;
console.log('Original object after clone modification:', originalObject); // Expected: { a: 1, b: { c: 2 } }
console.log('Cloned object:', clonedObject); // Expected: { a: 1, b: { c: 99 } }

view raw JSON →