-
-
Notifications
You must be signed in to change notification settings - Fork 0
5.8 quick start
wiki[bot] edited this page Aug 23, 2026
·
1 revision
npm install @triplef/helpersInstall peer dependencies:
npm install @nestjs/common @nestjs/swagger joiimport {
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.5import {
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 }); // falseimport { 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");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!"]);