A TypeScript utility library for working with JSON, data, strings, time, and other common operations. Suitable for use in both Node.js and browser projects.
- Type-Safe: Fully written in TypeScript.
- Modular: Import only what you need.
- Universal: Works in Node.js and the browser.
- Zero Dependencies: Has no production dependencies.
- Tested: Covered by unit tests using Jest.
pnpm installpnpm testIf you are using Jest, make sure you have the types installed:
pnpm add -D @types/jestimport { JsonGenerate } from "@/JsonGenerate";
// Generates a JSON object with random data based on a template
const template = {
id: "{{Number}}",
name: "{{String}}",
active: "{{Boolean}}",
};
const result = JsonGenerate.generate(template);
console.log(result);
// { id: 123, name: "randomString", active: true }import { TimeUtils } from "@/nalch/su/utils/TimeUtils";
// Checks if a year is a leap year
console.log(TimeUtils.isLeapYear(2024)); // true
// Converts milliseconds to a readable time format
console.log(TimeUtils.msToTime(1234567)); // 00:20:34.567src/– Source TypeScript fileslib/– Built JS files (if you use a build process)test/– Unit tests (Jest)
- JSON handling (
JsonGenerate,JsonStringifySanitizers) - Date and time handling (
RandomDate,TimeUtils) - Utilities for strings, arrays, objects
- Helpers for testing and parsing
This project is licensed under the terms of the LICENSE file.
Pull requests and issues are welcome!