@gzl10/ts-helpers
v4.2.5
Published
Universal TypeScript utility library with 150+ functions for validation, strings, dates, math, async operations and data import/export.
Downloads
545
Maintainers
Readme
@gzl10/ts-helpers
Universal TypeScript utility library for modern JavaScript environments.
Features
- Flat API: Direct access to 150+ functions without nesting
- Universal: Works in Node.js, browsers, Web Workers, and all bundlers
- Tree-shakeable: Import only what you need for minimal bundles
- TypeScript-first: Full type inference and strict mode
- Spanish validation: NIF, NIE, CIF, IBAN, phone numbers, and more
Installation
pnpm add @gzl10/ts-helpers
# or
npm install @gzl10/ts-helpersUsage
Flat API (Recommended)
import g from '@gzl10/ts-helpers'
// Validation
g.validateNIF('12345678Z')
g.generateSpanishNIF()
// Strings
g.toCamelCase('hello-world')
g.sanitizeString('<script>alert("xss")</script>')
// Math & Finance
g.calculateNPV(0.1, [-1000, 300, 400, 500])
g.calculateIRR([-1000, 300, 400, 500])
// Async
g.sleep(1000)
g.runBatch(items, processFn, { concurrency: 5 })
// Data
g.exportData(data, 'file.csv')
g.detectUniversalFormat('report.xlsx')
// Objects
g.deepEqual(obj1, obj2)
g.setDeepValue(config, 'database.host', 'localhost')
// Dates
g.formatNow('DD/MM/YYYY')
g.addDays(new Date(), 7)
// Environment
g.isDevelopment()
g.isProduction()
g.detectProtocol(req)Tree-shaking Imports
import { validateNIF, generateSpanishNIF } from '@gzl10/ts-helpers/validation'
import { exportData, importData } from '@gzl10/ts-helpers/data'
import { toCamelCase, sanitizeString } from '@gzl10/ts-helpers/strings'
import { sleep, runBatch } from '@gzl10/ts-helpers/async'
import { calculateNPV, calculateIRR } from '@gzl10/ts-helpers/math'
import { formatNow, addDays } from '@gzl10/ts-helpers/dates'
import { deepEqual, setDeepValue } from '@gzl10/ts-helpers/objects'
import { isDevelopment, isProduction } from '@gzl10/ts-helpers/environment'Documentation
- API Reference - Complete function list
- Changelog - Version history
Development
pnpm install
pnpm build
pnpm test
pnpm lintSupport
License
MIT © Gonzalo Díez
