Registry / aws / vandium-utils

vandium-utils

JSON →
library2.0.0jsnpmunverified

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.

npm install vandium-utils
INSTALL
IMPORT
SIG · VANDIUM-UTILS
V
vandium-utils
awsjavascriptv2.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

templateString
import { templateString } from 'vandium-utils';
const templateString = require('vandium-utils').templateString;
The recommended way for named imports in both ESM and CJS contexts.
isArray
import { isArray } from 'vandium-utils';
import isArray from 'vandium-utils';
All utility functions are named exports; there is no default export.
clone
const { clone } = require('vandium-utils');
import * as VandiumUtils from 'vandium-utils';
While `import * as` works, directly importing the needed function is more tree-shakeable and idiomatic.

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 } }
Debug
Known issues
breakingWhile specific breaking changes from v1 to v2 are not extensively documented in the README excerpt, major version bumps often introduce API changes. Developers should consult the full change log or release notes when migrating from `vandium-utils@1.x` to `2.x` to identify potential breaking changes in function signatures or behavior.
fix
Review the official changelog or GitHub releases for `vandium-utils` for detailed migration guides between major versions.
affects: >=2.0.0
gotchaThe `clone` function performs a deep clone for objects and arrays. However, if the input `value` is not an object or `null`, the function simply returns the existing value without modification. This can be surprising if expecting a new instance for all data types.
fix
Be aware of `clone`'s behavior for non-object/non-array inputs. If a new instance is required for primitives, explicitly reassign them (e.g., `const newVar = oldVar;`).
affects: >=1.0.0
gotchaThe `parseBoolean` function has specific string values it recognizes as `true` or `false` (case-insensitive: "on", "yes", "true", "off", "no", "false"). Any other string or non-boolean value that doesn't match these specific strings will resolve to `false` (after internal string conversions like `String(value).toLowerCase()`), which might not be the expected boolean logic for all arbitrary inputs.
fix
Ensure inputs to `parseBoolean` are among the explicitly supported string values or actual boolean literals. For other values, perform explicit type conversions or checks before passing to `parseBoolean` if specific boolean outcomes are critical.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: (0 , vandium_utils_1.templateString) is not a function
This error typically occurs when using CommonJS `require` syntax (e.g., `const { templateString } = require('vandium-utils');`) in an environment configured for ES Modules, or when attempting to import a non-existent or incorrectly named export.
fix
Ensure your module context matches your import statement. For ESM, use `import { templateString } from 'vandium-utils';`. If in CJS, verify the export name and ensure the path is correct.
ReferenceError: require is not defined
Attempting to use the CommonJS `require()` function within an ECMAScript Module (ESM) file, where `import` statements are expected.
fix
Convert `require` statements to `import` statements: `const { funcName } = require('pkg');` becomes `import { funcName } from 'pkg';`. Ensure your `package.json` has `"type": "module"` if you intend to use ESM, or use a `.mjs` file extension.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
36 hits · last 30 days
node
32
Amazon
1
Resources
vandium-utils — npm install vandium-utils · libregistry