t0n 0.20260703.0 → 0.20260706.1

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 (3) hide show
  1. package/package.json +1 -1
  2. package/src/cli.ts +4 -3
  3. package/src/id.ts +4 -4
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "t0n",
3
3
  "description": "Collection of elegant typescript resources for web artisans",
4
- "version": "0.20260703.0",
4
+ "version": "0.20260706.1",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
7
7
  "files": ["src"],
package/src/cli.ts CHANGED
@@ -34,11 +34,12 @@ export function shutdown(cb: (signal: string, e: unknown) => void | Promise<void
34
34
 
35
35
  export async function watch(
36
36
  cb: (e: ChokidarEventName | string, file: string) => Promise<void>,
37
- paths: string[],
38
- root?: string
37
+ paths: string | string[],
38
+ root?: string,
39
+ ignore?: string | RegExp | ((testString: string) => boolean)
39
40
  ) {
40
41
  const codeWatcher = chokidar.watch(paths, {
41
- ignored: /(^|[/\\])\../, // ignore hidden files
42
+ ignored: ignore ? ignore : /(^|[/\\])\../, // ignore hidden files
42
43
  persistent: true,
43
44
  ignoreInitial: true,
44
45
  awaitWriteFinish: {
package/src/id.ts CHANGED
@@ -9,14 +9,14 @@ export function newID() {
9
9
  do {
10
10
  const bytes = new Uint8Array(8)
11
11
  crypto.getRandomValues(bytes)
12
-
12
+
13
13
  id = UrlSafeBase64.encode(String.fromCharCode(...bytes)).slice(0, 8)
14
-
14
+
15
15
  attempts++
16
16
  } while (idCache.has(id) && attempts < maxAttempts)
17
-
17
+
18
18
  if (idCache.has(id))
19
19
  id = id.slice(0, 5) + Date.now().toString(36).slice(-3)
20
20
 
21
- return id
21
+ return id.replace(/[-_]/g, '')
22
22
  }