@arkyn/shared@arkyn/shared is a comprehensive utility library designed to provide a collection of well-tested, reusable functions for common development tasks. Built with TypeScript and optimized for modern JavaScript environments, it offers a modular approach to handling data formatting, generation, parsing, validation, and general-purpose utilities.@arkyn/shared?@arkyn/shared solves this problem by providing a curated set of tools that handle common tasks with a consistent, well-documented API.package.json, keeping the install footprint smalllibphonenumber-js (>=1.13.7) is the package's declared peer dependency, required by formatToPhone for parsing and validating phone numbers. See formatToPhone for details.formatToCurrency and findCountryMask—internally import from @arkyn/templates at runtime, even though it is not currently declared as a dependency or peer dependency in package.json.bash
bun add @arkyn/shared
ts
import { formatDate } from "@arkyn/shared/formatDate";import { formatToCurrency } from "@arkyn/shared/formatToCurrency";import { formatToCpf } from "@arkyn/shared/formatToCpf";formatDate(["25/12/2025"], "brazilianDate", "YYYY-MM-DD");// → "2025-12-25"formatToCurrency(1234.56, "BRL");// → "R$ 1.234,56"formatToCpf("12345678909");// → "123.456.789-09"
ts
import { generateId } from "@arkyn/shared/generateId";import { generateSlug } from "@arkyn/shared/generateSlug";import { generateColorByString } from "@arkyn/shared/generateColorByString";generateId("text", "v7");// → "018e4c5a-1b2c-7d3e-8f4a-5b6c7d8e9f0a"generateSlug("Hello, World! This is a Test.");// → "hello-world-this-is-a-test"generateColorByString("user@email.com");// → "#d4b9fa" (consistent color for the same input)
ts
import { parseSensitiveData } from "@arkyn/shared/parseSensitiveData";import { parseToDate } from "@arkyn/shared/parseToDate";parseSensitiveData('{"password":"secret123"}', ["password"]);// → '{"password":"****"}'
ts
import { ValidateDateService } from "@arkyn/shared/validateDateService";const validator = new ValidateDateService();validator.validateDateParts(2024, 2, 29); // Validates leap year date
ts
import { stripHtmlTags } from "@arkyn/shared/stripHtmlTags";import { calculateCardInstallment } from "@arkyn/shared/calculateCardInstallment";import { isHtml } from "@arkyn/shared/isHtml";stripHtmlTags("<p>Hello <strong>World</strong></p>");// → "Hello World"calculateCardInstallment({ cashPrice: 1000, numberInstallments: 12 });// → { totalPrice: 1241.04, installmentPrice: 103.42 }
@arkyn/shared follows these core principles: