utils 1.0.1
Install from the command line:
Learn more about npm packages
$ npm install @pnstack/utils@1.0.1
Install via package.json:
"@pnstack/utils": "1.0.1"
About this version
A collection of utility functions for PNStack applications.
pnpm add @pnstack/utils
import { get, isEmpty, delay, randomString } from "@pnstack/utils";
// Access nested object properties safely
const obj = { user: { profile: { name: "John" } } };
const name = get(obj, "user.profile.name"); // 'John'
const age = get(obj, "user.profile.age", 0); // 0 (default value)
// Check if value is empty
isEmpty(""); // true
isEmpty([]); // true
isEmpty({}); // true
isEmpty(null); // true
isEmpty(undefined); // true
isEmpty("hello"); // false
// Delay execution
await delay(1000); // waits for 1 second
// Generate random string
const id = randomString(10); // e.g. "a1b2c3d4e5"
Safely access nested object properties using dot notation or array syntax.
Check if a value is empty (null, undefined, empty string, empty array, empty object).
Creates a promise that resolves after the specified number of milliseconds.
Generates a random string of the specified length using alphanumeric characters.
MIT