zakir-core 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +168 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,7 +1,174 @@
1
1
  # @zakir/core
2
2
 
3
- Zero-dependency core utility library.
3
+ Zero-dependency, lightweight utility library for modern JavaScript & TypeScript projects.
4
+ Focuses on **performance**, **correct Unicode handling**, and **predictable behavior**.
5
+
6
+ ---
7
+
8
+ ## Features
9
+
10
+ - 🚫 Zero dependencies
11
+ - ⚡ Fast & minimal
12
+ - 🌍 Locale-aware string utilities (Unicode safe)
13
+ - 🧠 LRU-based memoization
14
+ - ⏱️ Debounce & throttle with full control
15
+ - 🧩 Functional helpers (pipe / compose)
16
+ - ✅ TypeScript-first
17
+
18
+ ---
4
19
 
5
20
  ## Install
21
+
6
22
  ```bash
7
23
  npm i @zakir/core
24
+ ```
25
+
26
+ ```ts
27
+ import { debounce, slugify, memoize } from "@zakir/core"
28
+ ```
29
+
30
+ ---
31
+
32
+ ## Core Utilities
33
+
34
+ ### Functions
35
+ - `noop`, `identity`
36
+ - `once`, `onceAsync`
37
+ - `delay`, `defer`
38
+ - `tryCatch`
39
+
40
+ ```ts
41
+ const init = once(() => console.log("init"))
42
+ init()
43
+ init() // ignored
44
+ ```
45
+
46
+ ---
47
+
48
+ ## Timing
49
+
50
+ ### debounce / throttle
51
+
52
+ Fully featured (leading, trailing, maxWait):
53
+
54
+ ```ts
55
+ const fn = debounce(
56
+ () => console.log("run"),
57
+ 300,
58
+ { leading: true }
59
+ )
60
+
61
+ fn.cancel()
62
+ fn.flush()
63
+ fn.pending()
64
+ ```
65
+
66
+ `throttle` is implemented via `debounce` for consistency.
67
+
68
+ ---
69
+
70
+ ## Memoization
71
+
72
+ ### memoize
73
+
74
+ - Optional key resolver
75
+ - Optional LRU cache (`maxSize`)
76
+ - Manual cache control
77
+
78
+ ```ts
79
+ const fib = memoize(
80
+ (n: number): number => n <= 1 ? n : fib(n - 1) + fib(n - 2),
81
+ n => n,
82
+ { maxSize: 100 }
83
+ )
84
+
85
+ fib.cache.clear()
86
+ ```
87
+
88
+ ### memoizeAsync
89
+
90
+ - Caches Promises
91
+ - Auto-cleans rejected results
92
+
93
+ ---
94
+
95
+ ## Functional Composition
96
+
97
+ ```ts
98
+ const fn = pipe(
99
+ (x: number) => x + 1,
100
+ x => x * 2
101
+ )
102
+
103
+ fn(2) // 6
104
+ ```
105
+
106
+ Also available: `compose(...)`
107
+
108
+ ---
109
+
110
+ ## String Utilities (Unicode-Safe)
111
+
112
+ Locale-aware, grapheme-safe string helpers:
113
+
114
+ - `capitalize`, `capitalizeWords`
115
+ - `lower`, `upper`
116
+ - `truncate`, `reverse`
117
+ - `slugify`
118
+ - `extractInitials`
119
+ - `removeDiacritics`
120
+ - `equalsIgnoreCase`
121
+ - `startsWithIgnoreCase`, `includesIgnoreCase`
122
+
123
+ ```ts
124
+ slugify("Heydər Əliyev")
125
+ // => "heyder-eliyev"
126
+ ```
127
+
128
+ ---
129
+
130
+ ## Transliteration
131
+
132
+ Built-in support for AZ/TR characters. Extendable:
133
+
134
+ ```ts
135
+ extendTransliteration({
136
+ "ß": "ss"
137
+ })
138
+ ```
139
+
140
+ ---
141
+
142
+ ## Locale-Aware Comparison
143
+
144
+ ```ts
145
+ compareLocale("ə", "z", "az-AZ")
146
+ ```
147
+
148
+ Uses `Intl.Collator` when available with LRU caching.
149
+
150
+ ---
151
+
152
+ ## Browser & Node
153
+
154
+ Works in:
155
+ - Browsers
156
+ - Node.js
157
+ - Bun / Deno
158
+
159
+ Uses `performance.now()` when available, falls back safely.
160
+
161
+ ---
162
+
163
+ ## Philosophy
164
+
165
+ - Explicit > Magic
166
+ - Correctness > Shortcuts
167
+ - Zero runtime dependencies
168
+ - Small primitives you can trust
169
+
170
+ ---
171
+
172
+ ## License
173
+
174
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zakir-core",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Core utility functions – zero dependency",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",