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(): stringGenerate a random UUID v4 identifier.
Example
import { uuid }from '@toolpouch/sdk/generators' ;const id = uuid();// ' 550 e8400 -e29 b-41 d4 -a716 -446655440000 '
Returns
UUID v4 string
randomNumber
Signature
randomNumber(min: number, max: number): numberGenerate 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): stringGenerate a random string of specified length with optional custom charset.
Example
import { randomString }from '@toolpouch/sdk/generators' ;const str = randomString(12 );// 'aBcDeF 123456 '
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' ,'sha );256 '// ' 2 cf24 dba5 fb0 a30 e26 e...'
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@ssw );0 rd!'// { score: 5 , label:'Strong' }
Returns
Object with score (0-5) and strength label