{"id":12344,"library":"vandium-utils","title":"Vandium Utils","description":"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.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/vandium-io/vandium-utils","tags":["javascript","JWT","AWS","Lambda","util","utility","serverless"],"install":[{"cmd":"npm install vandium-utils","lang":"bash","label":"npm"},{"cmd":"yarn add vandium-utils","lang":"bash","label":"yarn"},{"cmd":"pnpm add vandium-utils","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The recommended way for named imports in both ESM and CJS contexts.","wrong":"const templateString = require('vandium-utils').templateString;","symbol":"templateString","correct":"import { templateString } from 'vandium-utils';"},{"note":"All utility functions are named exports; there is no default export.","wrong":"import isArray from 'vandium-utils';","symbol":"isArray","correct":"import { isArray } from 'vandium-utils';"},{"note":"While `import * as` works, directly importing the needed function is more tree-shakeable and idiomatic.","wrong":"import * as VandiumUtils from 'vandium-utils';","symbol":"clone","correct":"const { clone } = require('vandium-utils');"}],"quickstart":{"code":"import { templateString, isObjectEmpty, clone } from 'vandium-utils';\n\n// Example 1: Basic string templating\nconst user = { name: 'Alice', city: 'Wonderland' };\nconst greeting = templateString('Hello ${name} from ${city}!', user);\nconsole.log(greeting); // Expected: \"Hello Alice from Wonderland!\"\n\n// Example 2: Checking for empty objects\nconst emptyObj = {};\nconst filledObj = { id: 1 };\nconsole.log(`Is emptyObj empty? ${isObjectEmpty(emptyObj)}`); // Expected: \"Is emptyObj empty? true\"\nconsole.log(`Is filledObj empty? ${isObjectEmpty(filledObj)}`); // Expected: \"Is filledObj empty? false\"\n\n// Example 3: Cloning an object\nconst originalObject = { a: 1, b: { c: 2 } };\nconst clonedObject = clone(originalObject);\nclonedObject.b.c = 99;\nconsole.log('Original object after clone modification:', originalObject); // Expected: { a: 1, b: { c: 2 } }\nconsole.log('Cloned object:', clonedObject); // Expected: { a: 1, b: { c: 99 } }","lang":"typescript","description":"Demonstrates `templateString` for string interpolation, `isObjectEmpty` for object validation, and `clone` for deep object copying."},"warnings":[{"fix":"Review the official changelog or GitHub releases for `vandium-utils` for detailed migration guides between major versions.","message":"While 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.","severity":"breaking","affected_versions":">=2.0.0"},{"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;`).","message":"The `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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"The `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.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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.","cause":"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.","error":"TypeError: (0 , vandium_utils_1.templateString) is not a function"},{"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.","cause":"Attempting to use the CommonJS `require()` function within an ECMAScript Module (ESM) file, where `import` statements are expected.","error":"ReferenceError: require is not defined"}],"ecosystem":"npm"}