# Quick Start ## Installation ```bash npm install @triplef/helpers ``` Install peer dependencies: ```bash npm install @nestjs/common @nestjs/swagger joi ``` ## Usage Examples ### Environment Variables ```typescript import { getBooleanEnv, getNumberEnv, } from "@triplef/helpers/get-boolean-env"; // Parse boolean environment variables const isEnabled = getBooleanEnv(process.env.FEATURE_FLAG); // "true" -> true const verbose = getBooleanEnv(process.env.VERBOSE, false); // fallback to false // Parse numeric environment variables const port = getNumberEnv(process.env.PORT, 3000); // "8080" -> 8080 const rate = getNumberEnv(process.env.RATE, 1.5); // "1,5" -> 1.5 ``` ### Object Operations ```typescript import { clone, merge, pick, omit, isEmpty, } from "@triplef/helpers/object-io"; // Clone an object const original = { a: 1, b: { c: 2 } }; const copy = clone(original); // Deep merge objects const merged = merge({ a: 1 }, { b: 2 }, true); // Pick specific keys const picked = pick({ id: 1, name: "John", age: 30 }, ["id", "name"]); // Omit specific keys const withoutPassword = omit(user, ["password", "token"]); // Check if object/array is empty isEmpty({}); // true isEmpty({ a: 1 }); // false ``` ### Hash Payload ```typescript import { hashPayload } from "@triplef/helpers/hash-payload"; // Hash a string const hash1 = hashPayload("hello"); // SHA-256, hex encoded // Hash an object (automatically JSON.stringified) const hash2 = hashPayload({ foo: "bar" }, "sha512", "base64"); // Hash with different algorithms const sha384 = hashPayload(data, "sha384"); ``` ### Text to Lines ```typescript import { TextToLines } from "@triplef/helpers/text-to-lines"; // Split text into sentences const splitter = new TextToLines("Hello world! How are you?"); splitter.lines; // 2 splitter.build(); // ["Hello world!", "How are you?"] // Chain and append more text const text = new TextToLines("First sentence...") .append("Second sentence...") .append(["Third sentence.", "Fourth sentence!"]); ```