@e280/stz 0.0.0-32 → 0.0.0-34

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 +57 -6
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -10,7 +10,6 @@ zero dependencies.
10
10
  <br/>
11
11
 
12
12
  ## 🧰 STZ PRIMITIVES
13
- > cool concepts we use all over the place
14
13
 
15
14
  ### 🍏 MapG
16
15
  > extended js map
@@ -122,8 +121,7 @@ import {pub, sub} from "@e280/stz"
122
121
 
123
122
  <br/>
124
123
 
125
- ## 🧰 FN TOOLS
126
- > function-oriented tools
124
+ ## 🧰 STZ FN TOOLS
127
125
 
128
126
  ### 🍏 `queue(fn)`
129
127
  > execute calls in sequence (not concurrent)
@@ -171,6 +169,26 @@ await fn()
171
169
  // DeadlineError: deadline exceeded (0.1 seconds)
172
170
  ```
173
171
 
172
+ ### 🍏 `debounce(100, fn)`
173
+ > wait some time before actually executing the fn (absorbing redundant calls)
174
+
175
+ we use `debounce` a lot in ui code, like on a user's keyboard input in a form field, but rendering the form input can actually be slow enough that it causes problems when they type fast — to eliminate the jank, we `debounce` with like 400 ms, so we wait for the user to finish typing for a moment before actually running the validation.
176
+
177
+ ```ts
178
+ import {debounce} from "@e280/stz"
179
+
180
+ const fn = debounce(100, async() => {
181
+ await coolAction()
182
+ })
183
+
184
+ // each fn() call resets the timer
185
+ fn()
186
+ fn()
187
+ fn()
188
+
189
+ // coolAction is only called once here, other calls are redundant
190
+ ```
191
+
174
192
  ### 🍏 `repeat(fn)`
175
193
  > execute a function over and over again, back to back
176
194
 
@@ -193,11 +211,44 @@ stop()
193
211
 
194
212
  <br/>
195
213
 
196
- ## 🧰 DATA UTILITIES
197
- > transforming and representing binary data
214
+ ## 🧰 STZ DATA UTILITIES
215
+
216
+ ### 🍏 Hex
217
+ > convert to/from hexadecimal string format
218
+ - `Hex.fromBytes(bytes)` — bytes to hex string
219
+ - `Hex.toBytes(string)` — hex string to bytes
220
+ - `Hex.random(32)` — generate random hex string (32 bytes)
221
+
222
+ ### 🍏 Base64
223
+ > convert to/from base64 string format
224
+ - `Base64.fromBytes(bytes)` — bytes to string
225
+ - `Base64.toBytes(string)` — string to bytes
226
+ - `Base64.random(32)` — generate random string (32 bytes)
227
+
228
+ ### 🍏 Base64url
229
+ > convert to/from base64 string format
230
+ - `Base64url.fromBytes(bytes)` — bytes to string
231
+ - `Base64url.toBytes(string)` — string to bytes
232
+ - `Base64url.random(32)` — generate random string (32 bytes)
233
+
234
+ ### 🍏 Base58
235
+ > convert to/from base64 string format
236
+ - `Base58.fromBytes(bytes)` — bytes to string
237
+ - `Base58.toBytes(string)` — string to bytes
238
+ - `Base58.random(32)` — generate random string (32 bytes)
239
+
240
+ ### 🍏 Txt
241
+ > convert to/from utf8 string format
242
+ - `Txt.fromBytes(bytes)` — bytes to string
243
+ - `Txt.toBytes(string)` — string to bytes
244
+
245
+ ### 🍏 Bytes
246
+ > utilities for dealing with Uint8Array
247
+ - `Bytes.eq(bytesA, bytesB)` — check if two byte arrays are equal
248
+ - `Bytes.random(32)` — generate crypto-random bytes
198
249
 
199
250
  ### 🍏 BaseX
200
- > represent data in arbitrary encodings
251
+ > convert data into arbitrary data encodings
201
252
  - make a BaseX instance
202
253
  ```ts
203
254
  import {BaseX} from "@e280/stz"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e280/stz",
3
- "version": "0.0.0-32",
3
+ "version": "0.0.0-34",
4
4
  "description": "everyday ts fns for everything",
5
5
  "license": "MIT",
6
6
  "author": "Chase Moskal <chasemoskal@gmail.com>",
@@ -26,7 +26,7 @@
26
26
  "_tscw": "tsc -w"
27
27
  },
28
28
  "devDependencies": {
29
- "@e280/science": "^0.0.5",
29
+ "@e280/science": "^0.0.6",
30
30
  "@types/node": "^24.2.0",
31
31
  "npm-run-all": "^4.1.5",
32
32
  "typescript": "^5.9.2"