ToolPouch

Generators

Generate random data: UUIDs, passwords, hashes, and random values.

Install the SDK

npm install @toolpouch/sdkView on npm →

Import from this module

import { functionName } from '@toolpouch/sdk/generators'

uuid

Signature

uuid(): string

Generate a random UUID v4 identifier.

Example

import { uuid } from '@toolpouch/sdk/generators';
const id = uuid();
// '550e8400-e29b-41d4-a716-446655440000'

Returns

UUID v4 string

randomNumber

Signature

randomNumber(min: number, max: number): number

Generate a random integer between min and max (inclusive).

Example

import { randomNumber } from '@toolpouch/sdk/generators';
const num = randomNumber(1, 100);
// 42

Returns

Random integer

randomString

Signature

randomString(length: number, charset?: string): string

Generate a random string of specified length with optional custom charset.

Example

import { randomString } from '@toolpouch/sdk/generators';
const str = randomString(12);
// 'aBcDeF123456'

Returns

Random string

randomPick

Signature

randomPick<T>(items: T[], count?: number): T[]

Randomly pick items from an array.

Example

import { randomPick } from '@toolpouch/sdk/generators';
const picked = randomPick(['a','b','c'], 2);
// ['c', 'a']

Returns

Array of randomly picked items

hash

Signature

hash(text: string, algorithm?: 'sha256' | 'md5'): Promise<string>

Generate a hash of text using SHA-256 or MD5.

Example

import { hash } from '@toolpouch/sdk/generators';
const h = await hash('hello', 'sha256');
// '2cf24dba5fb0a30e26e...'

Returns

Promise resolving to hash string

passwordStrength

Signature

passwordStrength(password: string): { score: number; label: string }

Evaluate password strength with score and label.

Example

import { passwordStrength } from '@toolpouch/sdk/generators';
const strength = passwordStrength('P@ssw0rd!');
// { score: 5, label: 'Strong' }

Returns

Object with score (0-5) and strength label