
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
A set of useful utility functions for formatting numbers, strings, dates, and generating UUIDs.
npm install ts-utix
import { formatNumber, kebabCase, UUID, relativeTime, getEmails } from 'ts-utix';
1. NumbersformatNumber(num: number, unit?: "K" | "M" | "B" | "") => stringFormats numbers with optional unit suffixes (K, M, B).
formatNumber(1500); // "1.5K"
formatNumber(2500000); // "2.5M"
formatNumber(3140000000); // "3.1B"
formatNumber(900, "K"); // "900" (doesn't reach 1K)
formatNumber(2500, "K"); // "2.5K"
2. StirngskebabCase(str: string) => stringConverts strings to kebab-case format.
kebabCase("HelloWorld"); // "hello-world"
kebabCase("someMixed_string"); // "some-mixed-string"
kebabCase("GET_DATA_FROM_API"); // "get-data-from-api"
UUID() => stringGenerates RFC 4122 compliant UUID v4.
UUID(); // e.g. "f47ac10b-58cc-4372-a567-0e02b2c3d479"
getEmails() => string[]Get all the emails from an text
getEmails(text: string, domains?: string[]) => string[]
const text = "Contact support@sanjeet.com and admin@gmail.com for help.";
console.log(getEmails(text)); // ["support@sanjeet.com", "admin@gmail.com"]
console.log(getEmails(text, ["sanjeet.com"]));
// ["support@sanjeet.com"]
console.log(getEmails(text, ["sanjeet.com", "gmail.com"]));
// ["support@sanjeet.com", "admin@gmail.com"]
3. Date And Timea. relativeTime(date: Date) => stringReturns human-readable relative time strings.
import { formatDate, timeAgo, isLeapYear, getDaysInMonth, addDays, timeDifference, timestampToDate } from 'ts-utix'
b. formatDate(date: Date | string | number , format: "YYYY-MM-DD HH-mm-ss") => stringconsole.log(formatDate("2025-03-02", "YYYY-MM-DD")); // "2025-03-02"
console.log(formatDate(new Date(), "DD/MM/YYYY HH:mm:ss")); // "02/03/2025 14:30:45" (example output)
c. timeAgo(input: Date | string | number) => stringconsole.log(timeAgo(new Date(Date.now() - 1000 * 60 * 60 * 24 * 2))); // "2 days ago"
console.log(timeAgo(new Date(Date.now() + 1000 * 60 * 60 * 5))); // "in 5 hours"
d. isLeapYear(input: Date | number)console.log(isLeapYear(2024)); // true
console.log(isLeapYear(new Date)); // 2025 => false
e. getDaysInMonth(input : Date | number , month?: number ) => numberconsole.log(getDaysInMonth(2025, 2)); // 28 (February 2025)
console.log(getDaysInMonth(new Date(2025, 3, 15))); // 30 (April 2025)
console.log(getDaysInMonth(new Date())); // Returns days in the current getDaysInMonth
f. addDays(input: Date | string | number, days: number) => string | Dateconsole.log(addDays("2025-03-02", 10)); // "2025-03-12"
console.log(addDays(new Date(), -5)); // Date 5 days package-lock.json
g. timeDifference(input1: Date | string | number, input2: Date | string | number) => console.log(timeDifference("2025-03-02", "2025-03-05")); // { days: 3, hours: 0, minutes: 0, seconds: 0 }
console.log(timeDifference(new Date(), new Date(Date.now() + 1000 * 60 * 60 * 24 * 7))); // { days: 7, hours: 0, minutes: 0, seconds: 0 }
FAQs
A lightweight utility library for TypeScript and JavaScript
The npm package ts-utix receives a total of 0 weekly downloads. As such, ts-utix popularity was classified as not popular.
We found that ts-utix demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.