Skip to content

Commit 239b6db

Browse files
committed
add tye
1 parent 0d2e3a1 commit 239b6db

18 files changed

+311
-15
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.6.0] - 2025-09-06
11+
12+
### Added
13+
14+
- **TypeScript Function Overloads** for improved type inference
15+
- Added overload signatures to 13 functions with optional parameters
16+
- Better IDE autocomplete and parameter hints
17+
- More precise return type inference based on arguments
18+
- Functions with overloads: `truncate`, `pad`, `padStart`, `padEnd`, `template`, `templateSafe`, `excerpt`, `highlight`, `fuzzyMatch`, `memoize`, `randomString`, `toASCII`, `removeNonPrintable`
19+
- No breaking changes - fully backward compatible
20+
1021
## [0.5.2] - 2025-09-06
1122

1223
### Added

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ Ultra-lightweight string utilities with zero dependencies. Tree-shakeable, fully
1414
- 🚀 **Zero dependencies** - No bloat, just pure functions
1515
- 📦 **< 1KB per function** - Minimal bundle impact
1616
- 🌳 **Tree-shakeable** - Only import what you need
17-
- 💪 **Fully typed** - Complete TypeScript support
17+
- 💪 **Fully typed** - Complete TypeScript support with function overloads
1818
-**Fast performance** - 2-25x faster than lodash for many operations
1919
-**ESM & CJS** - Works everywhere
2020
- 🧪 **100% tested** - Reliable and production-ready
21-
- 🔒 **Type-safe** - Written in strict TypeScript
21+
- 🔒 **Type-safe** - Written in strict TypeScript with enhanced type inference
2222
- 📝 **Well documented** - JSDoc comments for all functions
2323

2424
## Installation

jsr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zheruel/nano-string-utils",
3-
"version": "0.5.2",
3+
"version": "0.6.0",
44
"exports": "./src/index.ts",
55
"publish": {
66
"include": ["src/**/*.ts", "README.md", "LICENSE", "CHANGELOG.md"],

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nano-string-utils",
3-
"version": "0.5.2",
3+
"version": "0.6.0",
44
"description": "Ultra-lightweight string utilities with zero dependencies",
55
"type": "module",
66
"main": "./dist/index.cjs",

src/excerpt.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ const TRAILING_PUNCT = /[,;:\-–—]+$/;
1111
* excerpt('The quick brown fox jumps over the lazy dog', 20) // 'The quick brown fox...'
1212
* excerpt('Hello world. This is a test.', 15) // 'Hello world...'
1313
*/
14+
export function excerpt(text: string, length: number): string;
15+
export function excerpt(text: string, length: number, suffix: string): string;
1416
export function excerpt(text: string, length: number, suffix = "..."): string {
1517
if (!text || text.length <= length) {
1618
return text;

src/fuzzyMatch.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ export interface FuzzyMatchResult {
4646
* // { matched: false, score: 0 }
4747
* ```
4848
*/
49+
export function fuzzyMatch(
50+
query: string,
51+
target: string
52+
): FuzzyMatchResult | null;
53+
export function fuzzyMatch(
54+
query: string,
55+
target: string,
56+
options: FuzzyMatchOptions
57+
): FuzzyMatchResult | null;
4958
export function fuzzyMatch(
5059
query: string,
5160
target: string,

src/highlight.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ export interface HighlightOptions {
1919
* highlight("Error: Connection failed", ["error", "failed"], { wrapper: ['**', '**'] })
2020
* // => "**Error**: Connection **failed**"
2121
*/
22+
export function highlight(text: string, terms: string): string;
23+
export function highlight(text: string, terms: string[]): string;
24+
export function highlight(
25+
text: string,
26+
terms: string,
27+
options: HighlightOptions
28+
): string;
29+
export function highlight(
30+
text: string,
31+
terms: string[],
32+
options: HighlightOptions
33+
): string;
2234
export function highlight(
2335
text: string,
2436
terms: string | string[],

src/memoize.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ export interface MemoizeOptions {
5555
* });
5656
* ```
5757
*/
58+
export function memoize<T extends (...args: any[]) => any>(fn: T): T;
59+
export function memoize<T extends (...args: any[]) => any>(
60+
fn: T,
61+
options: MemoizeOptions
62+
): T;
5863
export function memoize<T extends (...args: any[]) => any>(
5964
fn: T,
6065
options: MemoizeOptions = {}

src/pad.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* pad('Hi', 6, '-') // '--Hi--'
1010
* pad('Hi', 7, '-') // '--Hi---'
1111
*/
12+
export function pad(str: string, length: number): string;
13+
export function pad(str: string, length: number, chars: string): string;
1214
export function pad(str: string, length: number, chars = " "): string {
1315
// Quick check for Unicode (emoji, combining chars, etc)
1416
const hasUnicode =

src/padEnd.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
* padEnd('Hi', 6, '=-') // 'Hi=-=-'
1010
* padEnd('5', 3, '0') // '500'
1111
*/
12+
export function padEnd(str: string, length: number): string;
13+
export function padEnd(str: string, length: number, chars: string): string;
1214
export function padEnd(str: string, length: number, chars = " "): string {
1315
const strLen = Array.from(str).length;
1416

0 commit comments

Comments
 (0)