@brianbuie/node-kit 0.9.2 → 0.11.0
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.
- package/README.md +102 -46
- package/dist/index.d.mts +41 -14
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +88 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -4
- package/src/Cache.ts +3 -4
- package/src/Dir.test.ts +5 -5
- package/src/Dir.ts +23 -20
- package/src/File.test.ts +1 -1
- package/src/File.ts +11 -0
- package/src/Format.test.ts +34 -0
- package/src/Format.ts +49 -0
- package/src/index.ts +1 -0
- package/src/snapshot.test.ts +2 -2
- package/tsconfig.json +11 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# Node Kit
|
|
4
4
|
|
|
5
|
-
Basic tools for
|
|
5
|
+
Basic tools for Node.js projects
|
|
6
6
|
|
|
7
7
|
# Installing
|
|
8
8
|
|
|
@@ -18,7 +18,7 @@ import { Fetcher, Log } from '@brianbuie/node-kit';
|
|
|
18
18
|
|
|
19
19
|
<!--#region ts2md-api-merged-here-->
|
|
20
20
|
|
|
21
|
-
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
21
|
+
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
22
22
|
|
|
23
23
|
# Classes
|
|
24
24
|
|
|
@@ -32,11 +32,12 @@ Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types
|
|
|
32
32
|
| [FileTypeCsv](#class-filetypecsv) |
|
|
33
33
|
| [FileTypeJson](#class-filetypejson) |
|
|
34
34
|
| [FileTypeNdjson](#class-filetypendjson) |
|
|
35
|
+
| [Format](#class-format) |
|
|
35
36
|
| [Log](#class-log) |
|
|
36
37
|
| [TempDir](#class-tempdir) |
|
|
37
38
|
| [TypeWriter](#class-typewriter) |
|
|
38
39
|
|
|
39
|
-
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
40
|
+
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
40
41
|
|
|
41
42
|
---
|
|
42
43
|
|
|
@@ -59,23 +60,24 @@ export class Cache<T> {
|
|
|
59
60
|
}
|
|
60
61
|
```
|
|
61
62
|
|
|
62
|
-
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
63
|
+
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
63
64
|
|
|
64
65
|
---
|
|
65
66
|
## Class: Dir
|
|
66
67
|
|
|
67
|
-
Reference to a specific directory with
|
|
68
|
-
|
|
68
|
+
Reference to a specific directory with methods to create and list files.
|
|
69
|
+
Created immediately if it doesn't exist
|
|
69
70
|
|
|
70
71
|
```ts
|
|
71
72
|
export class Dir {
|
|
72
73
|
path;
|
|
73
|
-
constructor(
|
|
74
|
-
create()
|
|
74
|
+
constructor(inputPath = "./")
|
|
75
75
|
dir(subPath: string)
|
|
76
|
-
|
|
76
|
+
tempDir(subPath: string)
|
|
77
|
+
sanitize(filename: string)
|
|
77
78
|
filepath(base: string)
|
|
78
79
|
file(base: string)
|
|
80
|
+
get files()
|
|
79
81
|
}
|
|
80
82
|
```
|
|
81
83
|
|
|
@@ -86,7 +88,7 @@ export class Dir {
|
|
|
86
88
|
### Constructor
|
|
87
89
|
|
|
88
90
|
```ts
|
|
89
|
-
constructor(
|
|
91
|
+
constructor(inputPath = "./")
|
|
90
92
|
```
|
|
91
93
|
|
|
92
94
|
Argument Details
|
|
@@ -105,15 +107,15 @@ dir(subPath: string)
|
|
|
105
107
|
Argument Details
|
|
106
108
|
|
|
107
109
|
+ **subPath**
|
|
108
|
-
+ to create
|
|
110
|
+
+ relative path to create
|
|
109
111
|
|
|
110
112
|
Example
|
|
111
113
|
|
|
112
114
|
```ts
|
|
113
115
|
const folder = new Dir('example');
|
|
114
|
-
// folder.path = '
|
|
115
|
-
const child = folder.
|
|
116
|
-
// child.path = '
|
|
116
|
+
// folder.path = '/absolute/path/to/example'
|
|
117
|
+
const child = folder.dir('path/to/dir');
|
|
118
|
+
// child.path = '/absolute/path/to/example/path/to/dir'
|
|
117
119
|
```
|
|
118
120
|
|
|
119
121
|
### Method filepath
|
|
@@ -137,7 +139,7 @@ const filepath = folder.resolve('file.json');
|
|
|
137
139
|
|
|
138
140
|
</details>
|
|
139
141
|
|
|
140
|
-
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
142
|
+
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
141
143
|
|
|
142
144
|
---
|
|
143
145
|
## Class: Fetcher
|
|
@@ -235,7 +237,7 @@ See also: [FetchOptions](#type-fetchoptions), [Route](#type-route)
|
|
|
235
237
|
|
|
236
238
|
</details>
|
|
237
239
|
|
|
238
|
-
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
240
|
+
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
239
241
|
|
|
240
242
|
---
|
|
241
243
|
## Class: File
|
|
@@ -245,6 +247,11 @@ WARNING: API will change!
|
|
|
245
247
|
```ts
|
|
246
248
|
export class File {
|
|
247
249
|
path;
|
|
250
|
+
root;
|
|
251
|
+
dir;
|
|
252
|
+
base;
|
|
253
|
+
ext;
|
|
254
|
+
name;
|
|
248
255
|
constructor(filepath: string)
|
|
249
256
|
get exists()
|
|
250
257
|
delete()
|
|
@@ -291,7 +298,7 @@ lines as strings, removes trailing '\n'
|
|
|
291
298
|
|
|
292
299
|
</details>
|
|
293
300
|
|
|
294
|
-
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
301
|
+
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
295
302
|
|
|
296
303
|
---
|
|
297
304
|
## Class: FileType
|
|
@@ -308,7 +315,7 @@ export class FileType {
|
|
|
308
315
|
}
|
|
309
316
|
```
|
|
310
317
|
|
|
311
|
-
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
318
|
+
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
312
319
|
|
|
313
320
|
---
|
|
314
321
|
## Class: FileTypeCsv
|
|
@@ -327,7 +334,7 @@ export class FileTypeCsv<Row extends object> extends FileType {
|
|
|
327
334
|
|
|
328
335
|
See also: [FileType](#class-filetype)
|
|
329
336
|
|
|
330
|
-
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
337
|
+
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
331
338
|
|
|
332
339
|
---
|
|
333
340
|
## Class: FileTypeJson
|
|
@@ -345,7 +352,7 @@ export class FileTypeJson<T> extends FileType {
|
|
|
345
352
|
|
|
346
353
|
See also: [FileType](#class-filetype)
|
|
347
354
|
|
|
348
|
-
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
355
|
+
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
349
356
|
|
|
350
357
|
---
|
|
351
358
|
## Class: FileTypeNdjson
|
|
@@ -362,7 +369,58 @@ export class FileTypeNdjson<T extends object> extends FileType {
|
|
|
362
369
|
|
|
363
370
|
See also: [FileType](#class-filetype)
|
|
364
371
|
|
|
365
|
-
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
372
|
+
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
373
|
+
|
|
374
|
+
---
|
|
375
|
+
## Class: Format
|
|
376
|
+
|
|
377
|
+
Helpers for formatting dates, times, and numbers as strings
|
|
378
|
+
|
|
379
|
+
```ts
|
|
380
|
+
export class Format {
|
|
381
|
+
static date(formatStr: "iso" | "ymd" | string = "iso", d: DateArg<Date> = new Date())
|
|
382
|
+
static round(n: number, places = 0)
|
|
383
|
+
static ms(ms: number)
|
|
384
|
+
static bytes(b: number)
|
|
385
|
+
}
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
<details>
|
|
389
|
+
|
|
390
|
+
<summary>Class Format Details</summary>
|
|
391
|
+
|
|
392
|
+
### Method date
|
|
393
|
+
|
|
394
|
+
date-fns format() with some shortcuts
|
|
395
|
+
|
|
396
|
+
```ts
|
|
397
|
+
static date(formatStr: "iso" | "ymd" | string = "iso", d: DateArg<Date> = new Date())
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
Argument Details
|
|
401
|
+
|
|
402
|
+
+ **formatStr**
|
|
403
|
+
+ 'iso' to get ISO date, 'ymd' to format as 'yyyy-MM-dd', full options: https://date-fns.org/v4.1.0/docs/format
|
|
404
|
+
|
|
405
|
+
### Method ms
|
|
406
|
+
|
|
407
|
+
Make millisecond durations actually readable (eg "123ms", "3.56s", "1m 34s", "3h 24m", "2d 4h")
|
|
408
|
+
|
|
409
|
+
```ts
|
|
410
|
+
static ms(ms: number)
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### Method round
|
|
414
|
+
|
|
415
|
+
Round a number to a specific set of places
|
|
416
|
+
|
|
417
|
+
```ts
|
|
418
|
+
static round(n: number, places = 0)
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
</details>
|
|
422
|
+
|
|
423
|
+
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
366
424
|
|
|
367
425
|
---
|
|
368
426
|
## Class: Log
|
|
@@ -427,7 +485,7 @@ static prepare(...input: unknown[]): {
|
|
|
427
485
|
|
|
428
486
|
</details>
|
|
429
487
|
|
|
430
|
-
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
488
|
+
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
431
489
|
|
|
432
490
|
---
|
|
433
491
|
## Class: TempDir
|
|
@@ -436,14 +494,13 @@ Extends Dir class with method to `clear()` contents
|
|
|
436
494
|
|
|
437
495
|
```ts
|
|
438
496
|
export class TempDir extends Dir {
|
|
439
|
-
dir(subPath: string)
|
|
440
497
|
clear()
|
|
441
498
|
}
|
|
442
499
|
```
|
|
443
500
|
|
|
444
501
|
See also: [Dir](#class-dir)
|
|
445
502
|
|
|
446
|
-
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
503
|
+
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
447
504
|
|
|
448
505
|
---
|
|
449
506
|
## Class: TypeWriter
|
|
@@ -477,7 +534,7 @@ async toString()
|
|
|
477
534
|
|
|
478
535
|
</details>
|
|
479
536
|
|
|
480
|
-
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
537
|
+
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
481
538
|
|
|
482
539
|
---
|
|
483
540
|
# Functions
|
|
@@ -485,9 +542,10 @@ Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types
|
|
|
485
542
|
| |
|
|
486
543
|
| --- |
|
|
487
544
|
| [snapshot](#function-snapshot) |
|
|
545
|
+
| [temp](#function-temp) |
|
|
488
546
|
| [timeout](#function-timeout) |
|
|
489
547
|
|
|
490
|
-
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
548
|
+
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
491
549
|
|
|
492
550
|
---
|
|
493
551
|
|
|
@@ -500,7 +558,18 @@ functions are removed
|
|
|
500
558
|
export function snapshot(i: unknown, max = 50, depth = 0): any
|
|
501
559
|
```
|
|
502
560
|
|
|
503
|
-
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
561
|
+
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
562
|
+
|
|
563
|
+
---
|
|
564
|
+
## Function: temp
|
|
565
|
+
|
|
566
|
+
Creates a '.temp' directory in current working directory
|
|
567
|
+
|
|
568
|
+
```ts
|
|
569
|
+
export function temp()
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
504
573
|
|
|
505
574
|
---
|
|
506
575
|
## Function: timeout
|
|
@@ -509,7 +578,7 @@ Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types
|
|
|
509
578
|
export async function timeout(ms: number)
|
|
510
579
|
```
|
|
511
580
|
|
|
512
|
-
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
581
|
+
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
513
582
|
|
|
514
583
|
---
|
|
515
584
|
# Types
|
|
@@ -520,7 +589,7 @@ Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types
|
|
|
520
589
|
| [Query](#type-query) |
|
|
521
590
|
| [Route](#type-route) |
|
|
522
591
|
|
|
523
|
-
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
592
|
+
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
524
593
|
|
|
525
594
|
---
|
|
526
595
|
|
|
@@ -540,7 +609,7 @@ export type FetchOptions = RequestInit & {
|
|
|
540
609
|
|
|
541
610
|
See also: [Query](#type-query), [timeout](#function-timeout)
|
|
542
611
|
|
|
543
|
-
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
612
|
+
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
544
613
|
|
|
545
614
|
---
|
|
546
615
|
## Type: Query
|
|
@@ -549,7 +618,7 @@ Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types
|
|
|
549
618
|
export type Query = Record<string, QueryVal | QueryVal[]>
|
|
550
619
|
```
|
|
551
620
|
|
|
552
|
-
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
621
|
+
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
553
622
|
|
|
554
623
|
---
|
|
555
624
|
## Type: Route
|
|
@@ -558,21 +627,8 @@ Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types
|
|
|
558
627
|
export type Route = string | URL
|
|
559
628
|
```
|
|
560
629
|
|
|
561
|
-
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
562
|
-
|
|
563
|
-
---
|
|
564
|
-
# Variables
|
|
565
|
-
|
|
566
|
-
## Variable: temp
|
|
567
|
-
|
|
568
|
-
```ts
|
|
569
|
-
temp = new TempDir(".temp")
|
|
570
|
-
```
|
|
571
|
-
|
|
572
|
-
See also: [TempDir](#class-tempdir)
|
|
573
|
-
|
|
574
|
-
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
630
|
+
Links: [API](#api), [Classes](#classes), [Functions](#functions), [Types](#types)
|
|
575
631
|
|
|
576
632
|
---
|
|
577
633
|
|
|
578
|
-
<!--#endregion ts2md-api-merged-here-->
|
|
634
|
+
<!--#endregion ts2md-api-merged-here-->
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import { Readable } from "node:stream";
|
|
3
|
-
import { Duration } from "date-fns";
|
|
3
|
+
import { DateArg, Duration } from "date-fns";
|
|
4
4
|
import { ChalkInstance } from "chalk";
|
|
5
5
|
import * as qt from "quicktype-core";
|
|
6
6
|
import * as quicktype_core_dist_TargetLanguage_js0 from "quicktype-core/dist/TargetLanguage.js";
|
|
@@ -19,6 +19,11 @@ import * as quicktype_core_dist_language_Smithy4s_language_js0 from "quicktype-c
|
|
|
19
19
|
*/
|
|
20
20
|
declare class File {
|
|
21
21
|
path: string;
|
|
22
|
+
root: string;
|
|
23
|
+
dir: string;
|
|
24
|
+
base: string;
|
|
25
|
+
ext: string;
|
|
26
|
+
name: string;
|
|
22
27
|
constructor(filepath: string);
|
|
23
28
|
get exists(): boolean;
|
|
24
29
|
delete(): void;
|
|
@@ -85,27 +90,27 @@ declare class FileTypeCsv<Row extends object> extends FileType {
|
|
|
85
90
|
//#endregion
|
|
86
91
|
//#region src/Dir.d.ts
|
|
87
92
|
/**
|
|
88
|
-
* Reference to a specific directory with
|
|
89
|
-
*
|
|
93
|
+
* Reference to a specific directory with methods to create and list files.
|
|
94
|
+
* Created immediately if it doesn't exist
|
|
90
95
|
*/
|
|
91
96
|
declare class Dir {
|
|
92
97
|
path: string;
|
|
93
98
|
/**
|
|
94
99
|
* @param path can be relative to workspace or absolute
|
|
95
100
|
*/
|
|
96
|
-
constructor(
|
|
97
|
-
create(): void;
|
|
101
|
+
constructor(inputPath?: string);
|
|
98
102
|
/**
|
|
99
103
|
* Create a new Dir inside the current Dir
|
|
100
|
-
* @param subPath to create
|
|
104
|
+
* @param subPath relative path to create
|
|
101
105
|
* @example
|
|
102
106
|
* const folder = new Dir('example');
|
|
103
|
-
* // folder.path = '
|
|
104
|
-
* const child = folder.
|
|
105
|
-
* // child.path = '
|
|
107
|
+
* // folder.path = '/absolute/path/to/example'
|
|
108
|
+
* const child = folder.dir('path/to/dir');
|
|
109
|
+
* // child.path = '/absolute/path/to/example/path/to/dir'
|
|
106
110
|
*/
|
|
107
111
|
dir(subPath: string): Dir;
|
|
108
|
-
|
|
112
|
+
tempDir(subPath: string): TempDir;
|
|
113
|
+
sanitize(filename: string): string;
|
|
109
114
|
/**
|
|
110
115
|
* @param base - The file name with extension
|
|
111
116
|
* @example
|
|
@@ -115,18 +120,18 @@ declare class Dir {
|
|
|
115
120
|
*/
|
|
116
121
|
filepath(base: string): string;
|
|
117
122
|
file(base: string): File;
|
|
123
|
+
get files(): File[];
|
|
118
124
|
}
|
|
119
125
|
/**
|
|
120
126
|
* Extends Dir class with method to `clear()` contents
|
|
121
127
|
*/
|
|
122
128
|
declare class TempDir extends Dir {
|
|
123
|
-
dir(subPath: string): TempDir;
|
|
124
129
|
clear(): void;
|
|
125
130
|
}
|
|
126
131
|
/**
|
|
127
|
-
*
|
|
132
|
+
* Creates a '.temp' directory in current working directory
|
|
128
133
|
*/
|
|
129
|
-
declare
|
|
134
|
+
declare function temp(): TempDir;
|
|
130
135
|
//#endregion
|
|
131
136
|
//#region src/Cache.d.ts
|
|
132
137
|
/**
|
|
@@ -211,6 +216,28 @@ declare class Fetcher {
|
|
|
211
216
|
fetchJson<T>(route: Route, opts?: FetchOptions): Promise<[T, Response, Request]>;
|
|
212
217
|
}
|
|
213
218
|
//#endregion
|
|
219
|
+
//#region src/Format.d.ts
|
|
220
|
+
/**
|
|
221
|
+
* Helpers for formatting dates, times, and numbers as strings
|
|
222
|
+
*/
|
|
223
|
+
declare class Format {
|
|
224
|
+
/**
|
|
225
|
+
* date-fns format() with some shortcuts
|
|
226
|
+
* @param formatStr
|
|
227
|
+
* 'iso' to get ISO date, 'ymd' to format as 'yyyy-MM-dd', full options: https://date-fns.org/v4.1.0/docs/format
|
|
228
|
+
*/
|
|
229
|
+
static date(formatStr?: 'iso' | 'ymd' | string, d?: DateArg<Date>): string;
|
|
230
|
+
/**
|
|
231
|
+
* Round a number to a specific set of places
|
|
232
|
+
*/
|
|
233
|
+
static round(n: number, places?: number): string;
|
|
234
|
+
/**
|
|
235
|
+
* Make millisecond durations actually readable (eg "123ms", "3.56s", "1m 34s", "3h 24m", "2d 4h")
|
|
236
|
+
*/
|
|
237
|
+
static ms(ms: number): string;
|
|
238
|
+
static bytes(b: number): string;
|
|
239
|
+
}
|
|
240
|
+
//#endregion
|
|
214
241
|
//#region src/Log.d.ts
|
|
215
242
|
type Severity = 'DEFAULT' | 'DEBUG' | 'INFO' | 'NOTICE' | 'WARNING' | 'ERROR' | 'CRITICAL' | 'ALERT' | 'EMERGENCY';
|
|
216
243
|
type Options = {
|
|
@@ -717,5 +744,5 @@ declare class TypeWriter {
|
|
|
717
744
|
toFile(): Promise<void>;
|
|
718
745
|
}
|
|
719
746
|
//#endregion
|
|
720
|
-
export { Cache, Dir, type FetchOptions, Fetcher, File, FileType, FileTypeCsv, FileTypeJson, FileTypeNdjson, Log, type Query, type Route, TempDir, TypeWriter, snapshot, temp, timeout };
|
|
747
|
+
export { Cache, Dir, type FetchOptions, Fetcher, File, FileType, FileTypeCsv, FileTypeJson, FileTypeNdjson, Format, Log, type Query, type Route, TempDir, TypeWriter, snapshot, temp, timeout };
|
|
721
748
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/File.ts","../src/Dir.ts","../src/Cache.ts","../src/Fetcher.ts","../src/Log.ts","../src/snapshot.ts","../src/timeout.ts","../src/TypeWriter.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;cAUa,IAAA;;;;;;;;;;oBA2BG,EAAA,CAAA,aAAA;EA3BH,IAAA,WAAI,CAAA,CAAA,EA+BA,EAAA,CAAA,WA/BA;EA2BD,KAAA,CAAA,QAAA,EAAA,MAAA,GASW,cATX,CAAA,EAAA,IAAA,GASyB,OATzB,CAAA,IAAA,CAAA;EAAA;;;;EA0BK,MAAA,CAAA,KAAA,EAAA,MAAA,GAAA,MAAA,EAAA,CAAA,EAAA,IAAA;EAIA,WAAA,QAAA,CAAA,CAAA,EAAA,OAJA,QAIA;EAAC,IAAA,CAAA,CAAA,CAAA,CAAA,QAAA,CAAA,EAAD,CAAC,CAAA,EAAA,YAAA,CAAA,CAAA,CAAA;EAAA,WAAA,IAAA,CAAA,CAAA,EAAA,OAIL,YAJK;EAIL,MAAA,CAAA,UAAA,MAAA,CAAA,CAAA,KAAA,CAAA,EAIkB,CAJlB,GAIsB,CAJtB,EAAA,CAAA,EAIyB,cAJzB,CAIyB,CAJzB,CAAA;EAIkB,WAAA,MAAA,CAAA,CAAA,EAAA,OAIhB,cAJgB;EAAI,GAAA,CAAA,UAAA,MAAA,CAAA,CAAA,IAAA,CAAA,EAQF,CARE,EAAA,EAAA,IAAA,CAAA,EAAA,CAAA,MAQiB,CARjB,CAAA,EAAA,CAAA,EAQqB,OARrB,CAQqB,WARrB,CAQqB,CARrB,CAAA,CAAA;EAAG,WAAA,GAAA,CAAA,CAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAIsE,CAAA,CAAA,0DAAA,CAAA;MAAX,SAAA,0DAAA,CAAA,WAAA,EAAA;QAgBnB,SAAA,YAAA,EAAA,MAAA;QAK/B,SAAA,KAAA,EAAA,OAAA;QAUF,SAAA,OAAA,EAAA,SAAA;MAAA,CAAA,EAAA,YAAA,GAAA,OAAA,GAAA,SAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA/BoD,QAAQ,EAAA,CAAG;4CAgB9B;cAK/B;YAUF"}
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/File.ts","../src/Dir.ts","../src/Cache.ts","../src/Fetcher.ts","../src/Format.ts","../src/Log.ts","../src/snapshot.ts","../src/timeout.ts","../src/TypeWriter.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;cAUa,IAAA;;;;;;;;;;;EAAA;;;EA0CI,KAAA,CAAA,CAAA,EAAA,MAAA,EAAA;EAKU,IAAA,UAAA,CAAA,CAAA,EATX,EAAA,CAAA,UASW,GATX,QASW;EAAc,IAAA,WAAA,CAAA,CAAA,EALxB,EAAA,CAAA,WAKwB;EAiBpB,KAAA,CAAA,QAAA,EAAA,MAAA,GAjBM,cAiBN,CAAA,EAAA,IAAA,GAjBoB,OAiBpB,CAAA,IAAA,CAAA;EAIA;;;;EAQc,MAAA,CAAA,KAAA,EAAA,MAAA,GAAA,MAAA,EAAA,CAAA,EAAA,IAAA;EAAI,WAAA,QAAA,CAAA,CAAA,EAAA,OAZlB,QAYkB;EAAG,IAAA,CAAA,CAAA,CAAA,CAAA,QAAA,CAAA,EARrB,CAQqB,CAAA,EARpB,YAQoB,CARpB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SAAA,YAAA,8DAAA;MAAX,CAAA,EAAA,YAAA,CAAA;MAgBnB,WAAA,4DAAA,CAAA,SAAA,CAAA;IAK/B,CAAA,CAAA,0DAAA,CAAA;MAUF,SAAA,6DAAA,CAAA,YAAA,CAAA;MAAA,uBAAA,6DAAA,CAAA,cAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA/BoD,QAAQ,EAAA,CAAG;4CAgB9B;cAK/B;YAUF"}
|
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { Readable } from "node:stream";
|
|
|
5
5
|
import { finished } from "node:stream/promises";
|
|
6
6
|
import { parseStream, writeToStream } from "fast-csv";
|
|
7
7
|
import { isObjectLike, merge } from "lodash-es";
|
|
8
|
-
import { add, isAfter } from "date-fns";
|
|
8
|
+
import { add, format, formatISO, isAfter } from "date-fns";
|
|
9
9
|
import extractDomain from "extract-domain";
|
|
10
10
|
import { inspect } from "node:util";
|
|
11
11
|
import chalk from "chalk";
|
|
@@ -44,8 +44,19 @@ function snapshot(i, max = 50, depth = 0) {
|
|
|
44
44
|
*/
|
|
45
45
|
var File = class {
|
|
46
46
|
path;
|
|
47
|
+
root;
|
|
48
|
+
dir;
|
|
49
|
+
base;
|
|
50
|
+
ext;
|
|
51
|
+
name;
|
|
47
52
|
constructor(filepath) {
|
|
48
53
|
this.path = filepath;
|
|
54
|
+
const { root, dir, base, ext, name } = path.parse(filepath);
|
|
55
|
+
this.root = root;
|
|
56
|
+
this.dir = dir;
|
|
57
|
+
this.base = base;
|
|
58
|
+
this.ext = ext;
|
|
59
|
+
this.name = name;
|
|
49
60
|
}
|
|
50
61
|
get exists() {
|
|
51
62
|
return fs.existsSync(this.path);
|
|
@@ -200,34 +211,35 @@ var FileTypeCsv = class extends FileType {
|
|
|
200
211
|
//#endregion
|
|
201
212
|
//#region src/Dir.ts
|
|
202
213
|
/**
|
|
203
|
-
* Reference to a specific directory with
|
|
204
|
-
*
|
|
214
|
+
* Reference to a specific directory with methods to create and list files.
|
|
215
|
+
* Created immediately if it doesn't exist
|
|
205
216
|
*/
|
|
206
217
|
var Dir = class Dir {
|
|
207
218
|
path;
|
|
208
219
|
/**
|
|
209
220
|
* @param path can be relative to workspace or absolute
|
|
210
221
|
*/
|
|
211
|
-
constructor(
|
|
212
|
-
this.path =
|
|
213
|
-
}
|
|
214
|
-
create() {
|
|
222
|
+
constructor(inputPath = "./") {
|
|
223
|
+
this.path = path.resolve(inputPath);
|
|
215
224
|
fs.mkdirSync(this.path, { recursive: true });
|
|
216
225
|
}
|
|
217
226
|
/**
|
|
218
227
|
* Create a new Dir inside the current Dir
|
|
219
|
-
* @param subPath to create
|
|
228
|
+
* @param subPath relative path to create
|
|
220
229
|
* @example
|
|
221
230
|
* const folder = new Dir('example');
|
|
222
|
-
* // folder.path = '
|
|
223
|
-
* const child = folder.
|
|
224
|
-
* // child.path = '
|
|
231
|
+
* // folder.path = '/absolute/path/to/example'
|
|
232
|
+
* const child = folder.dir('path/to/dir');
|
|
233
|
+
* // child.path = '/absolute/path/to/example/path/to/dir'
|
|
225
234
|
*/
|
|
226
235
|
dir(subPath) {
|
|
227
236
|
return new Dir(path.resolve(this.path, subPath));
|
|
228
237
|
}
|
|
229
|
-
|
|
230
|
-
return
|
|
238
|
+
tempDir(subPath) {
|
|
239
|
+
return new TempDir(path.resolve(this.path, subPath));
|
|
240
|
+
}
|
|
241
|
+
sanitize(filename) {
|
|
242
|
+
return sanitizeFilename(filename.replace("https://", "").replace("www.", ""), { replacement: "_" }).slice(-200);
|
|
231
243
|
}
|
|
232
244
|
/**
|
|
233
245
|
* @param base - The file name with extension
|
|
@@ -242,30 +254,31 @@ var Dir = class Dir {
|
|
|
242
254
|
file(base) {
|
|
243
255
|
return new File(this.filepath(base));
|
|
244
256
|
}
|
|
257
|
+
get files() {
|
|
258
|
+
return fs.readdirSync(this.path).map((filename) => this.file(filename));
|
|
259
|
+
}
|
|
245
260
|
};
|
|
246
261
|
/**
|
|
247
262
|
* Extends Dir class with method to `clear()` contents
|
|
248
263
|
*/
|
|
249
|
-
var TempDir = class
|
|
250
|
-
dir(subPath) {
|
|
251
|
-
return new TempDir(path.resolve(this.path, subPath));
|
|
252
|
-
}
|
|
264
|
+
var TempDir = class extends Dir {
|
|
253
265
|
clear() {
|
|
254
266
|
fs.rmSync(this.path, {
|
|
255
267
|
recursive: true,
|
|
256
268
|
force: true
|
|
257
269
|
});
|
|
258
|
-
this.
|
|
270
|
+
fs.mkdirSync(this.path, { recursive: true });
|
|
259
271
|
}
|
|
260
272
|
};
|
|
261
273
|
/**
|
|
262
|
-
*
|
|
274
|
+
* Creates a '.temp' directory in current working directory
|
|
263
275
|
*/
|
|
264
|
-
|
|
276
|
+
function temp() {
|
|
277
|
+
return new TempDir(".temp");
|
|
278
|
+
}
|
|
265
279
|
|
|
266
280
|
//#endregion
|
|
267
281
|
//#region src/Cache.ts
|
|
268
|
-
const cacheDir = temp.dir("cache");
|
|
269
282
|
/**
|
|
270
283
|
* Save data to a local file with an expiration.
|
|
271
284
|
* Fresh/stale data is returned with a flag for if it's fresh or not,
|
|
@@ -275,7 +288,7 @@ var Cache = class {
|
|
|
275
288
|
file;
|
|
276
289
|
ttl;
|
|
277
290
|
constructor(key, ttl, initialData) {
|
|
278
|
-
this.file =
|
|
291
|
+
this.file = new TempDir(".cache").file(key).json();
|
|
279
292
|
this.ttl = typeof ttl === "number" ? { minutes: ttl } : ttl;
|
|
280
293
|
if (initialData) this.write(initialData);
|
|
281
294
|
}
|
|
@@ -398,6 +411,58 @@ var Fetcher = class {
|
|
|
398
411
|
}
|
|
399
412
|
};
|
|
400
413
|
|
|
414
|
+
//#endregion
|
|
415
|
+
//#region src/Format.ts
|
|
416
|
+
/**
|
|
417
|
+
* Helpers for formatting dates, times, and numbers as strings
|
|
418
|
+
*/
|
|
419
|
+
var Format = class {
|
|
420
|
+
/**
|
|
421
|
+
* date-fns format() with some shortcuts
|
|
422
|
+
* @param formatStr
|
|
423
|
+
* 'iso' to get ISO date, 'ymd' to format as 'yyyy-MM-dd', full options: https://date-fns.org/v4.1.0/docs/format
|
|
424
|
+
*/
|
|
425
|
+
static date(formatStr = "iso", d = /* @__PURE__ */ new Date()) {
|
|
426
|
+
if (formatStr === "iso") return formatISO(d);
|
|
427
|
+
if (formatStr === "ymd") return format(d, "yyyy-MM-dd");
|
|
428
|
+
return format(d, formatStr);
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Round a number to a specific set of places
|
|
432
|
+
*/
|
|
433
|
+
static round(n, places = 0) {
|
|
434
|
+
return new Intl.NumberFormat("en-US", { maximumFractionDigits: places }).format(n);
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Make millisecond durations actually readable (eg "123ms", "3.56s", "1m 34s", "3h 24m", "2d 4h")
|
|
438
|
+
*/
|
|
439
|
+
static ms(ms) {
|
|
440
|
+
if (ms < 1e3) return `${this.round(ms)}ms`;
|
|
441
|
+
const s = ms / 1e3;
|
|
442
|
+
if (s < 60) return `${this.round(s, 2)}s`;
|
|
443
|
+
const m = Math.floor(s / 60);
|
|
444
|
+
if (m < 60) return `${m}m ${Math.floor(s) % 60}s`;
|
|
445
|
+
const h = Math.floor(m / 60);
|
|
446
|
+
if (h < 24) return `${h}h ${m % 60}m`;
|
|
447
|
+
return `${Math.floor(h / 24)}d ${h % 24}h`;
|
|
448
|
+
}
|
|
449
|
+
static bytes(b) {
|
|
450
|
+
const labels = [
|
|
451
|
+
"b",
|
|
452
|
+
"KB",
|
|
453
|
+
"MB",
|
|
454
|
+
"GB",
|
|
455
|
+
"TB"
|
|
456
|
+
];
|
|
457
|
+
let factor = 0;
|
|
458
|
+
while (b >= 1024 && labels[factor + 1]) {
|
|
459
|
+
b = b / 1024;
|
|
460
|
+
factor++;
|
|
461
|
+
}
|
|
462
|
+
return `${this.round(b, 2)} ${labels[factor]}`;
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
|
|
401
466
|
//#endregion
|
|
402
467
|
//#region src/Log.ts
|
|
403
468
|
var Log = class {
|
|
@@ -558,5 +623,5 @@ var TypeWriter = class {
|
|
|
558
623
|
};
|
|
559
624
|
|
|
560
625
|
//#endregion
|
|
561
|
-
export { Cache, Dir, Fetcher, File, FileType, FileTypeCsv, FileTypeJson, FileTypeNdjson, Log, TempDir, TypeWriter, snapshot, temp, timeout };
|
|
626
|
+
export { Cache, Dir, Fetcher, File, FileType, FileTypeCsv, FileTypeJson, FileTypeNdjson, Format, Log, TempDir, TypeWriter, snapshot, temp, timeout };
|
|
562
627
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["output: Record<string, any>","obj: Record<string, any>","parsed: Row[]","#parseVal","params: [string, string][]","timeout","#toGcloud","#toConsole","#log"],"sources":["../src/snapshot.ts","../src/File.ts","../src/Dir.ts","../src/Cache.ts","../src/Fetcher.ts","../src/Log.ts","../src/timeout.ts","../src/TypeWriter.ts"],"sourcesContent":["import { isObjectLike } from 'lodash-es';\n\n/**\n * Allows special objects (Error, Headers, Set) to be included in JSON.stringify output\n * functions are removed\n */\nexport function snapshot(i: unknown, max = 50, depth = 0): any {\n if (Array.isArray(i)) {\n if (depth === max) return [];\n return i.map((c) => snapshot(c, max, depth + 1));\n }\n if (typeof i === 'function') return undefined;\n if (!isObjectLike(i)) return i;\n\n if (depth === max) return {};\n let output: Record<string, any> = {};\n // @ts-ignore If it has an 'entries' function, use that for looping (eg. Set, Map, Headers)\n if (typeof i.entries === 'function') {\n // @ts-ignore\n for (let [k, v] of i.entries()) {\n output[k] = snapshot(v, max, depth + 1);\n }\n return output;\n }\n\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Enumerability_and_ownership_of_properties\n\n // Get Enumerable, inherited properties\n const obj: Record<string, any> = i!;\n for (let key in obj) {\n output[key] = snapshot(obj[key], max, depth + 1);\n }\n\n // Get Non-enumberable, own properties\n Object.getOwnPropertyNames(obj).forEach((key) => {\n output[key] = snapshot(obj[key], max, depth + 1);\n });\n\n return output;\n}\n","import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { Readable } from 'node:stream';\nimport { finished } from 'node:stream/promises';\nimport { writeToStream, parseStream } from 'fast-csv';\nimport { snapshot } from './snapshot.ts';\n\n/**\n * WARNING: API will change!\n */\nexport class File {\n path;\n\n constructor(filepath: string) {\n this.path = filepath;\n }\n\n get exists() {\n return fs.existsSync(this.path);\n }\n\n delete() {\n fs.rmSync(this.path, { force: true });\n }\n\n read() {\n return this.exists ? fs.readFileSync(this.path, 'utf8') : undefined;\n }\n\n /**\n * @returns lines as strings, removes trailing '\\n'\n */\n lines() {\n const contents = (this.read() || '').split('\\n');\n return contents.slice(0, contents.length - 1);\n }\n\n get readStream() {\n return this.exists ? fs.createReadStream(this.path) : Readable.from([]);\n }\n\n get writeStream() {\n fs.mkdirSync(path.parse(this.path).dir, { recursive: true });\n return fs.createWriteStream(this.path);\n }\n\n write(contents: string | ReadableStream) {\n fs.mkdirSync(path.parse(this.path).dir, { recursive: true });\n if (typeof contents === 'string') return fs.writeFileSync(this.path, contents);\n if (contents instanceof ReadableStream) return finished(Readable.from(contents).pipe(this.writeStream));\n throw new Error(`Invalid content type: ${typeof contents}`);\n }\n\n /**\n * creates file if it doesn't exist, appends string or array of strings as new lines.\n * File always ends with '\\n', so contents don't need to be read before appending\n */\n append(lines: string | string[]) {\n if (!this.exists) this.write('');\n const contents = Array.isArray(lines) ? lines.join('\\n') : lines;\n fs.appendFileSync(this.path, contents + '\\n');\n }\n\n static get FileType() {\n return FileType;\n }\n\n json<T>(contents?: T) {\n return new FileTypeJson<T>(this.path, contents);\n }\n\n static get json() {\n return FileTypeJson;\n }\n\n ndjson<T extends object>(lines?: T | T[]) {\n return new FileTypeNdjson<T>(this.path, lines);\n }\n\n static get ndjson() {\n return FileTypeNdjson;\n }\n\n async csv<T extends object>(rows?: T[], keys?: (keyof T)[]) {\n const csvFile = new FileTypeCsv<T>(this.path);\n if (rows) await csvFile.write(rows, keys);\n return csvFile;\n }\n\n static get csv() {\n return FileTypeCsv;\n }\n}\n\n/**\n * A generic file adaptor, extended by specific file type implementations\n */\nexport class FileType {\n file;\n\n constructor(filepath: string, contents?: string) {\n this.file = new File(filepath);\n if (contents) this.file.write(contents);\n }\n\n get exists() {\n return this.file.exists;\n }\n\n get path() {\n return this.file.path;\n }\n\n delete() {\n this.file.delete();\n }\n}\n\n/**\n * A .json file that maintains data type when reading/writing.\n * This is unsafe! Type is not checked at runtime, avoid using on files manipulated outside of your application.\n */\nexport class FileTypeJson<T> extends FileType {\n constructor(filepath: string, contents?: T) {\n super(filepath.endsWith('.json') ? filepath : filepath + '.json');\n if (contents) this.write(contents);\n }\n\n read() {\n const contents = this.file.read();\n return contents ? (JSON.parse(contents) as T) : undefined;\n }\n\n write(contents: T) {\n this.file.write(JSON.stringify(snapshot(contents), null, 2));\n }\n}\n\n/**\n * New-line delimited json file (.ndjson)\n * @see https://jsonltools.com/ndjson-format-specification\n */\nexport class FileTypeNdjson<T extends object> extends FileType {\n constructor(filepath: string, lines?: T | T[]) {\n super(filepath.endsWith('.ndjson') ? filepath : filepath + '.ndjson');\n if (lines) this.append(lines);\n }\n\n append(lines: T | T[]) {\n this.file.append(\n Array.isArray(lines) ? lines.map((l) => JSON.stringify(snapshot(l))) : JSON.stringify(snapshot(lines)),\n );\n }\n\n lines() {\n return this.file.lines().map((l) => JSON.parse(l) as T);\n }\n}\n\ntype Key<T extends object> = keyof T;\n\n/**\n * Comma separated values (.csv).\n * Input rows as objects, keys are used as column headers\n */\nexport class FileTypeCsv<Row extends object> extends FileType {\n constructor(filepath: string) {\n super(filepath.endsWith('.csv') ? filepath : filepath + '.csv');\n }\n\n async write(rows: Row[], keys?: Key<Row>[]) {\n const headerSet = new Set<Key<Row>>();\n if (keys) {\n for (const key of keys) headerSet.add(key);\n } else {\n for (const row of rows) {\n for (const key in row) headerSet.add(key);\n }\n }\n const headers = Array.from(headerSet);\n const outRows = rows.map((row) => headers.map((key) => row[key]));\n return finished(writeToStream(this.file.writeStream, [headers, ...outRows]));\n }\n\n #parseVal(val: string) {\n if (val.toLowerCase() === 'false') return false;\n if (val.toLowerCase() === 'true') return true;\n if (val.length === 0) return null;\n if (/^[\\.0-9]+$/.test(val)) return Number(val);\n return val;\n }\n\n async read() {\n return new Promise<Row[]>((resolve, reject) => {\n const parsed: Row[] = [];\n parseStream(this.file.readStream, { headers: true })\n .on('error', (e) => reject(e))\n .on('data', (raw: Record<Key<Row>, string>) => {\n parsed.push(\n Object.entries(raw).reduce(\n (all, [key, val]) => ({\n ...all,\n [key]: this.#parseVal(val as string),\n }),\n {} as Row,\n ),\n );\n })\n .on('end', () => resolve(parsed));\n });\n }\n}\n","import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport sanitizeFilename from 'sanitize-filename';\nimport { File } from './File.ts';\n\n/**\n * Reference to a specific directory with helpful methods for resolving filepaths,\n * sanitizing filenames, and saving files.\n */\nexport class Dir {\n path;\n\n /**\n * @param path can be relative to workspace or absolute\n */\n constructor(_path: string) {\n this.path = _path;\n }\n\n create() {\n fs.mkdirSync(this.path, { recursive: true });\n }\n\n /**\n * Create a new Dir inside the current Dir\n * @param subPath to create in current Dir\n * @example\n * const folder = new Dir('example');\n * // folder.path = './example'\n * const child = folder.subDir('path/to/dir');\n * // child.path = './example/path/to/dir'\n */\n dir(subPath: string) {\n return new Dir(path.resolve(this.path, subPath));\n }\n\n sanitize(name: string) {\n return sanitizeFilename(name.replace('https://', '').replace('www.', ''), { replacement: '_' }).slice(-200);\n }\n\n /**\n * @param base - The file name with extension\n * @example\n * const folder = new Dir('example');\n * const filepath = folder.resolve('file.json');\n * // 'example/file.json'\n */\n filepath(base: string) {\n return path.resolve(this.path, this.sanitize(base));\n }\n\n file(base: string) {\n return new File(this.filepath(base));\n }\n}\n\n/**\n * Extends Dir class with method to `clear()` contents\n */\nexport class TempDir extends Dir {\n dir(subPath: string) {\n return new TempDir(path.resolve(this.path, subPath));\n }\n\n clear() {\n fs.rmSync(this.path, { recursive: true, force: true });\n this.create();\n }\n}\n\n/**\n * Common temp dir location\n */\nexport const temp = new TempDir('.temp');\n","import { type Duration, isAfter, add } from 'date-fns';\nimport { temp } from './Dir.ts';\n\nconst cacheDir = temp.dir('cache');\n\n/**\n * Save data to a local file with an expiration.\n * Fresh/stale data is returned with a flag for if it's fresh or not,\n * so stale data can still be used if needed.\n */\nexport class Cache<T> {\n file;\n ttl;\n\n constructor(key: string, ttl: number | Duration, initialData?: T) {\n this.file = cacheDir.file(key).json<{ savedAt: string; data: T }>();\n this.ttl = typeof ttl === 'number' ? { minutes: ttl } : ttl;\n if (initialData) this.write(initialData);\n }\n\n write(data: T) {\n this.file.write({ savedAt: new Date().toUTCString(), data });\n }\n\n read(): [T | undefined, boolean] {\n const { savedAt, data } = this.file.read() || {};\n const isFresh = Boolean(savedAt && isAfter(add(savedAt, this.ttl), new Date()));\n return [data, isFresh];\n }\n}\n","import { merge } from 'lodash-es';\nimport extractDomain from 'extract-domain';\n\nexport type Route = string | URL;\n\ntype QueryVal = string | number | boolean | null | undefined;\nexport type Query = Record<string, QueryVal | QueryVal[]>;\n\nexport type FetchOptions = RequestInit & {\n base?: string;\n query?: Query;\n headers?: Record<string, string>;\n data?: any;\n timeout?: number;\n retries?: number;\n retryDelay?: number;\n};\n\n/**\n * Fetcher provides a quick way to set up a basic API connection\n * with options applied to every request.\n * Includes basic methods for requesting and parsing responses\n */\nexport class Fetcher {\n defaultOptions;\n\n constructor(opts: FetchOptions = {}) {\n this.defaultOptions = {\n timeout: 60000,\n retries: 0,\n retryDelay: 3000,\n ...opts,\n };\n }\n\n /**\n * Build URL with URLSearchParams if query is provided.\n * Also returns domain, to help with cookies\n */\n buildUrl(route: Route, opts: FetchOptions = {}): [URL, string] {\n const mergedOptions = merge({}, this.defaultOptions, opts);\n const params: [string, string][] = [];\n Object.entries(mergedOptions.query || {}).forEach(([key, val]) => {\n if (val === undefined) return;\n if (Array.isArray(val)) {\n val.forEach((v) => {\n params.push([key, `${v}`]);\n });\n } else {\n params.push([key, `${val}`]);\n }\n });\n const search = params.length > 0 ? '?' + new URLSearchParams(params).toString() : '';\n const url = new URL(route + search, this.defaultOptions.base);\n const domain = extractDomain(url.href) as string;\n return [url, domain];\n }\n\n /**\n * Merges options to get headers. Useful when extending the Fetcher class to add custom auth.\n */\n buildHeaders(route: Route, opts: FetchOptions = {}) {\n const { headers } = merge({}, this.defaultOptions, opts);\n return headers || {};\n }\n\n /**\n * Builds request, merging defaultOptions and provided options.\n * Includes Abort signal for timeout\n */\n buildRequest(route: Route, opts: FetchOptions = {}): [Request, FetchOptions, string] {\n const mergedOptions = merge({}, this.defaultOptions, opts);\n const { query, data, timeout, retries, ...init } = mergedOptions;\n init.headers = this.buildHeaders(route, mergedOptions);\n if (data) {\n init.headers['content-type'] = init.headers['content-type'] || 'application/json';\n init.method = init.method || 'POST';\n init.body = JSON.stringify(data);\n }\n if (timeout) {\n init.signal = AbortSignal.timeout(timeout);\n }\n const [url, domain] = this.buildUrl(route, mergedOptions);\n const req = new Request(url, init);\n return [req, mergedOptions, domain];\n }\n\n /**\n * Builds and performs the request, merging provided options with defaultOptions.\n * If `opts.data` is provided, method is updated to POST, content-type json, data is stringified in the body.\n * Retries on local or network error, with increasing backoff.\n */\n async fetch(route: Route, opts: FetchOptions = {}): Promise<[Response, Request]> {\n const [_req, options] = this.buildRequest(route, opts);\n const maxAttempts = (options.retries || 0) + 1;\n let attempt = 0;\n while (attempt < maxAttempts) {\n attempt++;\n const [req] = this.buildRequest(route, opts);\n const res = await fetch(req)\n .then((r) => {\n if (!r.ok) throw new Error(r.statusText);\n return r;\n })\n .catch(async (error) => {\n if (attempt < maxAttempts) {\n const wait = attempt * 3000;\n console.warn(`${req.method} ${req.url} (attempt ${attempt} of ${maxAttempts})`, error);\n await new Promise((resolve) => setTimeout(resolve, wait));\n } else {\n throw new Error(error);\n }\n });\n if (res) return [res, req];\n }\n throw new Error(`Failed to fetch ${_req.url}`);\n }\n\n async fetchText(route: Route, opts: FetchOptions = {}): Promise<[string, Response, Request]> {\n return this.fetch(route, opts).then(async ([res, req]) => {\n const text = await res.text();\n return [text, res, req];\n });\n }\n\n async fetchJson<T>(route: Route, opts: FetchOptions = {}): Promise<[T, Response, Request]> {\n return this.fetchText(route, opts).then(([txt, res, req]) => [JSON.parse(txt) as T, res, req]);\n }\n}\n","import { inspect } from 'node:util';\nimport { isObjectLike } from 'lodash-es';\nimport chalk, { type ChalkInstance } from 'chalk';\nimport { snapshot } from './snapshot.ts';\n\ntype Severity = 'DEFAULT' | 'DEBUG' | 'INFO' | 'NOTICE' | 'WARNING' | 'ERROR' | 'CRITICAL' | 'ALERT' | 'EMERGENCY';\n\ntype Options = {\n severity: Severity;\n color: ChalkInstance;\n};\n\ntype Entry = {\n message?: string;\n severity: Severity;\n details?: unknown[];\n};\n\nexport class Log {\n // Only silence logs when THIS package is running its own tests\n static isTest = process.env.npm_package_name === '@brianbuie/node-kit' && process.env.npm_lifecycle_event === 'test';\n\n /**\n * Gcloud parses JSON in stdout\n */\n static #toGcloud(entry: Entry) {\n if (entry.details?.length === 1) {\n console.log(JSON.stringify({ ...entry, details: entry.details[0] }));\n } else {\n console.log(JSON.stringify(entry));\n }\n }\n\n /**\n * Includes colors and better inspection for logging during dev\n */\n static #toConsole(entry: Entry, color: ChalkInstance) {\n if (entry.message) console.log(color(`[${entry.severity}] ${entry.message}`));\n entry.details?.forEach((detail) => {\n console.log(inspect(detail, { depth: 10, breakLength: 100, compact: true, colors: true }));\n });\n }\n\n static #log(options: Options, ...input: unknown[]) {\n const { message, details } = this.prepare(...input);\n // https://cloud.google.com/run/docs/container-contract#env-vars\n const isGcloud = process.env.K_SERVICE !== undefined || process.env.CLOUD_RUN_JOB !== undefined;\n if (isGcloud) {\n this.#toGcloud({ message, severity: options.severity, details });\n return { message, details, options };\n }\n // Hide output while testing this package\n if (!this.isTest) {\n this.#toConsole({ message, severity: options.severity, details }, options.color);\n }\n return { message, details, options };\n }\n\n /**\n * Handle first argument being a string or an object with a 'message' prop\n * Also snapshots special objects (eg Error, Response) to keep props in later JSON.stringify output\n */\n static prepare(...input: unknown[]): { message?: string; details: unknown[] } {\n let [first, ...rest] = input.map((i) => snapshot(i));\n if (typeof first === 'string') return { message: first, details: rest };\n // @ts-ignore\n if (isObjectLike(first) && typeof first['message'] === 'string') {\n const { message, ...firstDetails } = first as { message: string };\n return { message, details: [firstDetails, ...rest] };\n }\n return { details: input };\n }\n\n /**\n * Logs error details before throwing\n */\n static error(...input: unknown[]) {\n const { message } = this.#log({ severity: 'ERROR', color: chalk.red }, ...input);\n throw new Error(message);\n }\n\n static warn(...input: unknown[]) {\n return this.#log({ severity: 'WARNING', color: chalk.yellow }, ...input);\n }\n\n static notice(...input: unknown[]) {\n return this.#log({ severity: 'NOTICE', color: chalk.cyan }, ...input);\n }\n\n static info(...input: unknown[]) {\n return this.#log({ severity: 'INFO', color: chalk.white }, ...input);\n }\n\n static debug(...input: unknown[]) {\n const debugging = process.argv.some((arg) => arg.includes('--debug')) || process.env.DEBUG !== undefined;\n if (debugging || process.env.NODE_ENV !== 'production') {\n return this.#log({ severity: 'DEBUG', color: chalk.gray }, ...input);\n }\n }\n}\n","export async function timeout(ms: number) {\n return new Promise((resolve) => {\n setTimeout(resolve, ms);\n });\n}\n","import * as fs from 'node:fs';\nimport { merge } from 'lodash-es';\nimport * as qt from 'quicktype-core';\n\nexport class TypeWriter {\n moduleName;\n input = qt.jsonInputForTargetLanguage('typescript');\n outDir;\n qtSettings;\n\n constructor(moduleName: string, settings: { outDir?: string } & Partial<qt.Options> = {}) {\n this.moduleName = moduleName;\n const { outDir, ...qtSettings } = settings;\n this.outDir = outDir || './types';\n const defaultSettings = {\n lang: 'typescript',\n rendererOptions: {\n 'just-types': true,\n 'prefer-types': true,\n },\n inferEnums: false,\n inferDateTimes: false,\n };\n this.qtSettings = merge(defaultSettings, qtSettings);\n }\n\n async addMember(name: string, _samples: any[]) {\n const samples = _samples.map((s) => (typeof s === 'string' ? s : JSON.stringify(s)));\n await this.input.addSource({ name, samples });\n }\n\n async toString() {\n const inputData = new qt.InputData();\n inputData.addInput(this.input);\n const result = await qt.quicktype({\n inputData,\n ...this.qtSettings,\n });\n return result.lines.join('\\n');\n }\n\n async toFile() {\n const result = await this.toString();\n fs.mkdirSync(this.outDir, { recursive: true });\n fs.writeFileSync(`${this.outDir}/${this.moduleName}.d.ts`, result);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAMA,SAAgB,SAAS,GAAY,MAAM,IAAI,QAAQ,GAAQ;AAC7D,KAAI,MAAM,QAAQ,EAAE,EAAE;AACpB,MAAI,UAAU,IAAK,QAAO,EAAE;AAC5B,SAAO,EAAE,KAAK,MAAM,SAAS,GAAG,KAAK,QAAQ,EAAE,CAAC;;AAElD,KAAI,OAAO,MAAM,WAAY,QAAO;AACpC,KAAI,CAAC,aAAa,EAAE,CAAE,QAAO;AAE7B,KAAI,UAAU,IAAK,QAAO,EAAE;CAC5B,IAAIA,SAA8B,EAAE;AAEpC,KAAI,OAAO,EAAE,YAAY,YAAY;AAEnC,OAAK,IAAI,CAAC,GAAG,MAAM,EAAE,SAAS,CAC5B,QAAO,KAAK,SAAS,GAAG,KAAK,QAAQ,EAAE;AAEzC,SAAO;;CAMT,MAAMC,MAA2B;AACjC,MAAK,IAAI,OAAO,IACd,QAAO,OAAO,SAAS,IAAI,MAAM,KAAK,QAAQ,EAAE;AAIlD,QAAO,oBAAoB,IAAI,CAAC,SAAS,QAAQ;AAC/C,SAAO,OAAO,SAAS,IAAI,MAAM,KAAK,QAAQ,EAAE;GAChD;AAEF,QAAO;;;;;;;;AC5BT,IAAa,OAAb,MAAkB;CAChB;CAEA,YAAY,UAAkB;AAC5B,OAAK,OAAO;;CAGd,IAAI,SAAS;AACX,SAAO,GAAG,WAAW,KAAK,KAAK;;CAGjC,SAAS;AACP,KAAG,OAAO,K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AAW,IAAI,KAAK,UAAU,EAAE,CAAE;AACpF,QAAM,KAAK,MAAM,UAAU;GAAE;GAAM;GAAS,CAAC;;CAG/C,MAAM,WAAW;EACf,MAAM,YAAY,IAAI,GAAG,WAAW;AACpC,YAAU,SAAS,KAAK,MAAM;AAK9B,UAJe,MAAM,GAAG,UAAU;GAChC;GACA,GAAG,KAAK;GACT,CAAC,EACY,MAAM,KAAK,KAAK;;CAGhC,MAAM,SAAS;EACb,MAAM,SAAS,MAAM,KAAK,UAAU;AACpC,KAAG,UAAU,KAAK,QAAQ,EAAE,WAAW,MAAM,CAAC;AAC9C,KAAG,cAAc,GAAG,KAAK,OAAO,GAAG,KAAK,WAAW,QAAQ,OAAO"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["output: Record<string, any>","obj: Record<string, any>","parsed: Row[]","#parseVal","params: [string, string][]","timeout","#toGcloud","#toConsole","#log"],"sources":["../src/snapshot.ts","../src/File.ts","../src/Dir.ts","../src/Cache.ts","../src/Fetcher.ts","../src/Format.ts","../src/Log.ts","../src/timeout.ts","../src/TypeWriter.ts"],"sourcesContent":["import { isObjectLike } from 'lodash-es';\n\n/**\n * Allows special objects (Error, Headers, Set) to be included in JSON.stringify output\n * functions are removed\n */\nexport function snapshot(i: unknown, max = 50, depth = 0): any {\n if (Array.isArray(i)) {\n if (depth === max) return [];\n return i.map((c) => snapshot(c, max, depth + 1));\n }\n if (typeof i === 'function') return undefined;\n if (!isObjectLike(i)) return i;\n\n if (depth === max) return {};\n let output: Record<string, any> = {};\n // @ts-ignore If it has an 'entries' function, use that for looping (eg. Set, Map, Headers)\n if (typeof i.entries === 'function') {\n // @ts-ignore\n for (let [k, v] of i.entries()) {\n output[k] = snapshot(v, max, depth + 1);\n }\n return output;\n }\n\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Enumerability_and_ownership_of_properties\n\n // Get Enumerable, inherited properties\n const obj: Record<string, any> = i!;\n for (let key in obj) {\n output[key] = snapshot(obj[key], max, depth + 1);\n }\n\n // Get Non-enumberable, own properties\n Object.getOwnPropertyNames(obj).forEach((key) => {\n output[key] = snapshot(obj[key], max, depth + 1);\n });\n\n return output;\n}\n","import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { Readable } from 'node:stream';\nimport { finished } from 'node:stream/promises';\nimport { writeToStream, parseStream } from 'fast-csv';\nimport { snapshot } from './snapshot.ts';\n\n/**\n * WARNING: API will change!\n */\nexport class File {\n path;\n root;\n dir;\n base;\n ext;\n name;\n\n constructor(filepath: string) {\n this.path = filepath;\n const { root, dir, base, ext, name } = path.parse(filepath);\n this.root = root;\n this.dir = dir;\n this.base = base;\n this.ext = ext;\n this.name = name;\n }\n\n get exists() {\n return fs.existsSync(this.path);\n }\n\n delete() {\n fs.rmSync(this.path, { force: true });\n }\n\n read() {\n return this.exists ? fs.readFileSync(this.path, 'utf8') : undefined;\n }\n\n /**\n * @returns lines as strings, removes trailing '\\n'\n */\n lines() {\n const contents = (this.read() || '').split('\\n');\n return contents.slice(0, contents.length - 1);\n }\n\n get readStream() {\n return this.exists ? fs.createReadStream(this.path) : Readable.from([]);\n }\n\n get writeStream() {\n fs.mkdirSync(path.parse(this.path).dir, { recursive: true });\n return fs.createWriteStream(this.path);\n }\n\n write(contents: string | ReadableStream) {\n fs.mkdirSync(path.parse(this.path).dir, { recursive: true });\n if (typeof contents === 'string') return fs.writeFileSync(this.path, contents);\n if (contents instanceof ReadableStream) return finished(Readable.from(contents).pipe(this.writeStream));\n throw new Error(`Invalid content type: ${typeof contents}`);\n }\n\n /**\n * creates file if it doesn't exist, appends string or array of strings as new lines.\n * File always ends with '\\n', so contents don't need to be read before appending\n */\n append(lines: string | string[]) {\n if (!this.exists) this.write('');\n const contents = Array.isArray(lines) ? lines.join('\\n') : lines;\n fs.appendFileSync(this.path, contents + '\\n');\n }\n\n static get FileType() {\n return FileType;\n }\n\n json<T>(contents?: T) {\n return new FileTypeJson<T>(this.path, contents);\n }\n\n static get json() {\n return FileTypeJson;\n }\n\n ndjson<T extends object>(lines?: T | T[]) {\n return new FileTypeNdjson<T>(this.path, lines);\n }\n\n static get ndjson() {\n return FileTypeNdjson;\n }\n\n async csv<T extends object>(rows?: T[], keys?: (keyof T)[]) {\n const csvFile = new FileTypeCsv<T>(this.path);\n if (rows) await csvFile.write(rows, keys);\n return csvFile;\n }\n\n static get csv() {\n return FileTypeCsv;\n }\n}\n\n/**\n * A generic file adaptor, extended by specific file type implementations\n */\nexport class FileType {\n file;\n\n constructor(filepath: string, contents?: string) {\n this.file = new File(filepath);\n if (contents) this.file.write(contents);\n }\n\n get exists() {\n return this.file.exists;\n }\n\n get path() {\n return this.file.path;\n }\n\n delete() {\n this.file.delete();\n }\n}\n\n/**\n * A .json file that maintains data type when reading/writing.\n * This is unsafe! Type is not checked at runtime, avoid using on files manipulated outside of your application.\n */\nexport class FileTypeJson<T> extends FileType {\n constructor(filepath: string, contents?: T) {\n super(filepath.endsWith('.json') ? filepath : filepath + '.json');\n if (contents) this.write(contents);\n }\n\n read() {\n const contents = this.file.read();\n return contents ? (JSON.parse(contents) as T) : undefined;\n }\n\n write(contents: T) {\n this.file.write(JSON.stringify(snapshot(contents), null, 2));\n }\n}\n\n/**\n * New-line delimited json file (.ndjson)\n * @see https://jsonltools.com/ndjson-format-specification\n */\nexport class FileTypeNdjson<T extends object> extends FileType {\n constructor(filepath: string, lines?: T | T[]) {\n super(filepath.endsWith('.ndjson') ? filepath : filepath + '.ndjson');\n if (lines) this.append(lines);\n }\n\n append(lines: T | T[]) {\n this.file.append(\n Array.isArray(lines) ? lines.map((l) => JSON.stringify(snapshot(l))) : JSON.stringify(snapshot(lines)),\n );\n }\n\n lines() {\n return this.file.lines().map((l) => JSON.parse(l) as T);\n }\n}\n\ntype Key<T extends object> = keyof T;\n\n/**\n * Comma separated values (.csv).\n * Input rows as objects, keys are used as column headers\n */\nexport class FileTypeCsv<Row extends object> extends FileType {\n constructor(filepath: string) {\n super(filepath.endsWith('.csv') ? filepath : filepath + '.csv');\n }\n\n async write(rows: Row[], keys?: Key<Row>[]) {\n const headerSet = new Set<Key<Row>>();\n if (keys) {\n for (const key of keys) headerSet.add(key);\n } else {\n for (const row of rows) {\n for (const key in row) headerSet.add(key);\n }\n }\n const headers = Array.from(headerSet);\n const outRows = rows.map((row) => headers.map((key) => row[key]));\n return finished(writeToStream(this.file.writeStream, [headers, ...outRows]));\n }\n\n #parseVal(val: string) {\n if (val.toLowerCase() === 'false') return false;\n if (val.toLowerCase() === 'true') return true;\n if (val.length === 0) return null;\n if (/^[\\.0-9]+$/.test(val)) return Number(val);\n return val;\n }\n\n async read() {\n return new Promise<Row[]>((resolve, reject) => {\n const parsed: Row[] = [];\n parseStream(this.file.readStream, { headers: true })\n .on('error', (e) => reject(e))\n .on('data', (raw: Record<Key<Row>, string>) => {\n parsed.push(\n Object.entries(raw).reduce(\n (all, [key, val]) => ({\n ...all,\n [key]: this.#parseVal(val as string),\n }),\n {} as Row,\n ),\n );\n })\n .on('end', () => resolve(parsed));\n });\n }\n}\n","import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport sanitizeFilename from 'sanitize-filename';\nimport { File } from './File.ts';\n\n/**\n * Reference to a specific directory with methods to create and list files.\n * Created immediately if it doesn't exist\n */\nexport class Dir {\n path;\n\n /**\n * @param path can be relative to workspace or absolute\n */\n constructor(inputPath = './') {\n this.path = path.resolve(inputPath);\n fs.mkdirSync(this.path, { recursive: true });\n }\n\n /**\n * Create a new Dir inside the current Dir\n * @param subPath relative path to create\n * @example\n * const folder = new Dir('example');\n * // folder.path = '/absolute/path/to/example'\n * const child = folder.dir('path/to/dir');\n * // child.path = '/absolute/path/to/example/path/to/dir'\n */\n dir(subPath: string) {\n return new Dir(path.resolve(this.path, subPath));\n }\n\n tempDir(subPath: string) {\n return new TempDir(path.resolve(this.path, subPath));\n }\n\n sanitize(filename: string) {\n return sanitizeFilename(filename.replace('https://', '').replace('www.', ''), { replacement: '_' }).slice(-200);\n }\n\n /**\n * @param base - The file name with extension\n * @example\n * const folder = new Dir('example');\n * const filepath = folder.resolve('file.json');\n * // 'example/file.json'\n */\n filepath(base: string) {\n return path.resolve(this.path, this.sanitize(base));\n }\n\n file(base: string) {\n return new File(this.filepath(base));\n }\n\n get files() {\n return fs.readdirSync(this.path).map((filename) => this.file(filename));\n }\n}\n\n/**\n * Extends Dir class with method to `clear()` contents\n */\nexport class TempDir extends Dir {\n clear() {\n fs.rmSync(this.path, { recursive: true, force: true });\n fs.mkdirSync(this.path, { recursive: true });\n }\n}\n\n/**\n * Creates a '.temp' directory in current working directory\n */\nexport function temp() {\n return new TempDir('.temp');\n}\n","import { type Duration, isAfter, add } from 'date-fns';\nimport { TempDir } from './Dir.ts';\n\n/**\n * Save data to a local file with an expiration.\n * Fresh/stale data is returned with a flag for if it's fresh or not,\n * so stale data can still be used if needed.\n */\nexport class Cache<T> {\n file;\n ttl;\n\n constructor(key: string, ttl: number | Duration, initialData?: T) {\n const dir = new TempDir('.cache');\n this.file = dir.file(key).json<{ savedAt: string; data: T }>();\n this.ttl = typeof ttl === 'number' ? { minutes: ttl } : ttl;\n if (initialData) this.write(initialData);\n }\n\n write(data: T) {\n this.file.write({ savedAt: new Date().toUTCString(), data });\n }\n\n read(): [T | undefined, boolean] {\n const { savedAt, data } = this.file.read() || {};\n const isFresh = Boolean(savedAt && isAfter(add(savedAt, this.ttl), new Date()));\n return [data, isFresh];\n }\n}\n","import { merge } from 'lodash-es';\nimport extractDomain from 'extract-domain';\n\nexport type Route = string | URL;\n\ntype QueryVal = string | number | boolean | null | undefined;\nexport type Query = Record<string, QueryVal | QueryVal[]>;\n\nexport type FetchOptions = RequestInit & {\n base?: string;\n query?: Query;\n headers?: Record<string, string>;\n data?: any;\n timeout?: number;\n retries?: number;\n retryDelay?: number;\n};\n\n/**\n * Fetcher provides a quick way to set up a basic API connection\n * with options applied to every request.\n * Includes basic methods for requesting and parsing responses\n */\nexport class Fetcher {\n defaultOptions;\n\n constructor(opts: FetchOptions = {}) {\n this.defaultOptions = {\n timeout: 60000,\n retries: 0,\n retryDelay: 3000,\n ...opts,\n };\n }\n\n /**\n * Build URL with URLSearchParams if query is provided.\n * Also returns domain, to help with cookies\n */\n buildUrl(route: Route, opts: FetchOptions = {}): [URL, string] {\n const mergedOptions = merge({}, this.defaultOptions, opts);\n const params: [string, string][] = [];\n Object.entries(mergedOptions.query || {}).forEach(([key, val]) => {\n if (val === undefined) return;\n if (Array.isArray(val)) {\n val.forEach((v) => {\n params.push([key, `${v}`]);\n });\n } else {\n params.push([key, `${val}`]);\n }\n });\n const search = params.length > 0 ? '?' + new URLSearchParams(params).toString() : '';\n const url = new URL(route + search, this.defaultOptions.base);\n const domain = extractDomain(url.href) as string;\n return [url, domain];\n }\n\n /**\n * Merges options to get headers. Useful when extending the Fetcher class to add custom auth.\n */\n buildHeaders(route: Route, opts: FetchOptions = {}) {\n const { headers } = merge({}, this.defaultOptions, opts);\n return headers || {};\n }\n\n /**\n * Builds request, merging defaultOptions and provided options.\n * Includes Abort signal for timeout\n */\n buildRequest(route: Route, opts: FetchOptions = {}): [Request, FetchOptions, string] {\n const mergedOptions = merge({}, this.defaultOptions, opts);\n const { query, data, timeout, retries, ...init } = mergedOptions;\n init.headers = this.buildHeaders(route, mergedOptions);\n if (data) {\n init.headers['content-type'] = init.headers['content-type'] || 'application/json';\n init.method = init.method || 'POST';\n init.body = JSON.stringify(data);\n }\n if (timeout) {\n init.signal = AbortSignal.timeout(timeout);\n }\n const [url, domain] = this.buildUrl(route, mergedOptions);\n const req = new Request(url, init);\n return [req, mergedOptions, domain];\n }\n\n /**\n * Builds and performs the request, merging provided options with defaultOptions.\n * If `opts.data` is provided, method is updated to POST, content-type json, data is stringified in the body.\n * Retries on local or network error, with increasing backoff.\n */\n async fetch(route: Route, opts: FetchOptions = {}): Promise<[Response, Request]> {\n const [_req, options] = this.buildRequest(route, opts);\n const maxAttempts = (options.retries || 0) + 1;\n let attempt = 0;\n while (attempt < maxAttempts) {\n attempt++;\n const [req] = this.buildRequest(route, opts);\n const res = await fetch(req)\n .then((r) => {\n if (!r.ok) throw new Error(r.statusText);\n return r;\n })\n .catch(async (error) => {\n if (attempt < maxAttempts) {\n const wait = attempt * 3000;\n console.warn(`${req.method} ${req.url} (attempt ${attempt} of ${maxAttempts})`, error);\n await new Promise((resolve) => setTimeout(resolve, wait));\n } else {\n throw new Error(error);\n }\n });\n if (res) return [res, req];\n }\n throw new Error(`Failed to fetch ${_req.url}`);\n }\n\n async fetchText(route: Route, opts: FetchOptions = {}): Promise<[string, Response, Request]> {\n return this.fetch(route, opts).then(async ([res, req]) => {\n const text = await res.text();\n return [text, res, req];\n });\n }\n\n async fetchJson<T>(route: Route, opts: FetchOptions = {}): Promise<[T, Response, Request]> {\n return this.fetchText(route, opts).then(([txt, res, req]) => [JSON.parse(txt) as T, res, req]);\n }\n}\n","import { format, formatISO, type DateArg } from 'date-fns';\n\n/**\n * Helpers for formatting dates, times, and numbers as strings\n */\nexport class Format {\n /**\n * date-fns format() with some shortcuts\n * @param formatStr\n * 'iso' to get ISO date, 'ymd' to format as 'yyyy-MM-dd', full options: https://date-fns.org/v4.1.0/docs/format\n */\n static date(formatStr: 'iso' | 'ymd' | string = 'iso', d: DateArg<Date> = new Date()) {\n if (formatStr === 'iso') return formatISO(d);\n if (formatStr === 'ymd') return format(d, 'yyyy-MM-dd');\n return format(d, formatStr);\n }\n\n /**\n * Round a number to a specific set of places\n */\n static round(n: number, places = 0) {\n return new Intl.NumberFormat('en-US', { maximumFractionDigits: places }).format(n);\n }\n\n /**\n * Make millisecond durations actually readable (eg \"123ms\", \"3.56s\", \"1m 34s\", \"3h 24m\", \"2d 4h\")\n */\n static ms(ms: number) {\n if (ms < 1000) return `${this.round(ms)}ms`;\n const s = ms / 1000;\n if (s < 60) return `${this.round(s, 2)}s`;\n const m = Math.floor(s / 60);\n if (m < 60) return `${m}m ${Math.floor(s) % 60}s`;\n const h = Math.floor(m / 60);\n if (h < 24) return `${h}h ${m % 60}m`;\n const d = Math.floor(h / 24);\n return `${d}d ${h % 24}h`;\n }\n\n static bytes(b: number) {\n const labels = ['b', 'KB', 'MB', 'GB', 'TB'];\n let factor = 0;\n while (b >= 1024 && labels[factor + 1]) {\n b = b / 1024;\n factor++;\n }\n return `${this.round(b, 2)} ${labels[factor]}`;\n }\n}\n","import { inspect } from 'node:util';\nimport { isObjectLike } from 'lodash-es';\nimport chalk, { type ChalkInstance } from 'chalk';\nimport { snapshot } from './snapshot.ts';\n\ntype Severity = 'DEFAULT' | 'DEBUG' | 'INFO' | 'NOTICE' | 'WARNING' | 'ERROR' | 'CRITICAL' | 'ALERT' | 'EMERGENCY';\n\ntype Options = {\n severity: Severity;\n color: ChalkInstance;\n};\n\ntype Entry = {\n message?: string;\n severity: Severity;\n details?: unknown[];\n};\n\nexport class Log {\n // Only silence logs when THIS package is running its own tests\n static isTest = process.env.npm_package_name === '@brianbuie/node-kit' && process.env.npm_lifecycle_event === 'test';\n\n /**\n * Gcloud parses JSON in stdout\n */\n static #toGcloud(entry: Entry) {\n if (entry.details?.length === 1) {\n console.log(JSON.stringify({ ...entry, details: entry.details[0] }));\n } else {\n console.log(JSON.stringify(entry));\n }\n }\n\n /**\n * Includes colors and better inspection for logging during dev\n */\n static #toConsole(entry: Entry, color: ChalkInstance) {\n if (entry.message) console.log(color(`[${entry.severity}] ${entry.message}`));\n entry.details?.forEach((detail) => {\n console.log(inspect(detail, { depth: 10, breakLength: 100, compact: true, colors: true }));\n });\n }\n\n static #log(options: Options, ...input: unknown[]) {\n const { message, details } = this.prepare(...input);\n // https://cloud.google.com/run/docs/container-contract#env-vars\n const isGcloud = process.env.K_SERVICE !== undefined || process.env.CLOUD_RUN_JOB !== undefined;\n if (isGcloud) {\n this.#toGcloud({ message, severity: options.severity, details });\n return { message, details, options };\n }\n // Hide output while testing this package\n if (!this.isTest) {\n this.#toConsole({ message, severity: options.severity, details }, options.color);\n }\n return { message, details, options };\n }\n\n /**\n * Handle first argument being a string or an object with a 'message' prop\n * Also snapshots special objects (eg Error, Response) to keep props in later JSON.stringify output\n */\n static prepare(...input: unknown[]): { message?: string; details: unknown[] } {\n let [first, ...rest] = input.map((i) => snapshot(i));\n if (typeof first === 'string') return { message: first, details: rest };\n // @ts-ignore\n if (isObjectLike(first) && typeof first['message'] === 'string') {\n const { message, ...firstDetails } = first as { message: string };\n return { message, details: [firstDetails, ...rest] };\n }\n return { details: input };\n }\n\n /**\n * Logs error details before throwing\n */\n static error(...input: unknown[]) {\n const { message } = this.#log({ severity: 'ERROR', color: chalk.red }, ...input);\n throw new Error(message);\n }\n\n static warn(...input: unknown[]) {\n return this.#log({ severity: 'WARNING', color: chalk.yellow }, ...input);\n }\n\n static notice(...input: unknown[]) {\n return this.#log({ severity: 'NOTICE', color: chalk.cyan }, ...input);\n }\n\n static info(...input: unknown[]) {\n return this.#log({ severity: 'INFO', color: chalk.white }, ...input);\n }\n\n static debug(...input: unknown[]) {\n const debugging = process.argv.some((arg) => arg.includes('--debug')) || process.env.DEBUG !== undefined;\n if (debugging || process.env.NODE_ENV !== 'production') {\n return this.#log({ severity: 'DEBUG', color: chalk.gray }, ...input);\n }\n }\n}\n","export async function timeout(ms: number) {\n return new Promise((resolve) => {\n setTimeout(resolve, ms);\n });\n}\n","import * as fs from 'node:fs';\nimport { merge } from 'lodash-es';\nimport * as qt from 'quicktype-core';\n\nexport class TypeWriter {\n moduleName;\n input = qt.jsonInputForTargetLanguage('typescript');\n outDir;\n qtSettings;\n\n constructor(moduleName: string, settings: { outDir?: string } & Partial<qt.Options> = {}) {\n this.moduleName = moduleName;\n const { outDir, ...qtSettings } = settings;\n this.outDir = outDir || './types';\n const defaultSettings = {\n lang: 'typescript',\n rendererOptions: {\n 'just-types': true,\n 'prefer-types': true,\n },\n inferEnums: false,\n inferDateTimes: false,\n };\n this.qtSettings = merge(defaultSettings, qtSettings);\n }\n\n async addMember(name: string, _samples: any[]) {\n const samples = _samples.map((s) => (typeof s === 'string' ? s : JSON.stringify(s)));\n await this.input.addSource({ name, samples });\n }\n\n async toString() {\n const inputData = new qt.InputData();\n inputData.addInput(this.input);\n const result = await qt.quicktype({\n inputData,\n ...this.qtSettings,\n });\n return result.lines.join('\\n');\n }\n\n async toFile() {\n const result = await this.toString();\n fs.mkdirSync(this.outDir, { recursive: true });\n fs.writeFileSync(`${this.outDir}/${this.moduleName}.d.ts`, result);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAMA,SAAgB,SAAS,GAAY,MAAM,IAAI,QAAQ,GAAQ;AAC7D,KAAI,MAAM,QAAQ,EAAE,EAAE;AACpB,MAAI,UAAU,IAAK,QAAO,EAAE;AAC5B,SAAO,EAAE,KAAK,MAAM,SAAS,GAAG,KAAK,QAAQ,EAAE,CAAC;;AAElD,KAAI,OAAO,MAAM,WAAY,QAAO;AACpC,KAAI,CAAC,aAAa,EAAE,CAAE,QAAO;AAE7B,KAAI,UAAU,IAAK,QAAO,EAAE;CAC5B,IAAIA,SAA8B,EAAE;AAEpC,KAAI,OAAO,EAAE,YAAY,YAAY;AAEnC,OAAK,IAAI,CAAC,GAAG,MAAM,EAAE,SAAS,CAC5B,QAAO,KAAK,SAAS,GAAG,KAAK,QAAQ,EAAE;AAEzC,SAAO;;CAMT,MAAMC,MAA2B;AACjC,MAAK,IAAI,OAAO,IACd,QAAO,OAAO,SAAS,IAAI,MAAM,KAAK,QAAQ,EAAE;AAIlD,QAAO,oBAAoB,IAAI,CAAC,SAAS,QAAQ;AAC/C,SAAO,OAAO,SAAS,IAAI,MAAM,KAAK,QAAQ,EAAE;GAChD;AAEF,QAAO;;;;;;;;AC5BT,IAAa,OAAb,MAAkB;CAChB;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,UAAkB;AAC5B,OAAK,OAAO;EACZ,MAAM,EAAE,MAAM,KAAK,MAAM,KAAK,SAAS,KAAK,MAAM,SAAS;AAC3D,OAAK,OAAO;AACZ,OAAK,MAAM;AACX,OAAK,OAAO;AACZ,OAAK,MAAM;AACX,OAAK,OAAO;;CAGd,I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SAAS,KAAK,MAAO,OAAO,MAAM,WAAW,IAAI,KAAK,UAAU,EAAE,CAAE;AACpF,QAAM,KAAK,MAAM,UAAU;GAAE;GAAM;GAAS,CAAC;;CAG/C,MAAM,WAAW;EACf,MAAM,YAAY,IAAI,GAAG,WAAW;AACpC,YAAU,SAAS,KAAK,MAAM;AAK9B,UAJe,MAAM,GAAG,UAAU;GAChC;GACA,GAAG,KAAK;GACT,CAAC,EACY,MAAM,KAAK,KAAK;;CAGhC,MAAM,SAAS;EACb,MAAM,SAAS,MAAM,KAAK,UAAU;AACpC,KAAG,UAAU,KAAK,QAAQ,EAAE,WAAW,MAAM,CAAC;AAC9C,KAAG,cAAc,GAAG,KAAK,OAAO,GAAG,KAAK,WAAW,QAAQ,OAAO"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brianbuie/node-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"license": "ISC",
|
|
5
|
+
"description": "Basic tools for Node.js projects",
|
|
6
|
+
"author": "Brian Buie <brian@buie.dev>",
|
|
5
7
|
"repository": {
|
|
6
8
|
"type": "git",
|
|
7
9
|
"url": "git+https://github.com/brianbuie/node-kit.git"
|
|
@@ -22,12 +24,14 @@
|
|
|
22
24
|
"files": [
|
|
23
25
|
"src",
|
|
24
26
|
"dist",
|
|
25
|
-
"
|
|
27
|
+
"tsconfig.json"
|
|
26
28
|
],
|
|
27
29
|
"engines": {
|
|
28
30
|
"node": ">=24"
|
|
29
31
|
},
|
|
30
32
|
"dependencies": {
|
|
33
|
+
"@types/lodash-es": "^4.17.12",
|
|
34
|
+
"@types/node": "^24.9.1",
|
|
31
35
|
"chalk": "^5.6.2",
|
|
32
36
|
"date-fns": "^4.1.0",
|
|
33
37
|
"extract-domain": "^5.0.2",
|
|
@@ -37,8 +41,6 @@
|
|
|
37
41
|
"sanitize-filename": "^1.6.3"
|
|
38
42
|
},
|
|
39
43
|
"devDependencies": {
|
|
40
|
-
"@types/lodash-es": "^4.17.12",
|
|
41
|
-
"@types/node": "^24.9.1",
|
|
42
44
|
"ts2md": "^0.2.8",
|
|
43
45
|
"tsdown": "^0.16.6",
|
|
44
46
|
"typescript": "^5.9.3"
|
package/src/Cache.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { type Duration, isAfter, add } from 'date-fns';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const cacheDir = temp.dir('cache');
|
|
2
|
+
import { TempDir } from './Dir.ts';
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* Save data to a local file with an expiration.
|
|
@@ -13,7 +11,8 @@ export class Cache<T> {
|
|
|
13
11
|
ttl;
|
|
14
12
|
|
|
15
13
|
constructor(key: string, ttl: number | Duration, initialData?: T) {
|
|
16
|
-
|
|
14
|
+
const dir = new TempDir('.cache');
|
|
15
|
+
this.file = dir.file(key).json<{ savedAt: string; data: T }>();
|
|
17
16
|
this.ttl = typeof ttl === 'number' ? { minutes: ttl } : ttl;
|
|
18
17
|
if (initialData) this.write(initialData);
|
|
19
18
|
}
|
package/src/Dir.test.ts
CHANGED
|
@@ -3,7 +3,7 @@ import assert from 'node:assert';
|
|
|
3
3
|
import { Dir, TempDir, temp } from './Dir.ts';
|
|
4
4
|
|
|
5
5
|
describe('Dir', () => {
|
|
6
|
-
const testDir = temp.dir('dir-test');
|
|
6
|
+
const testDir = temp().dir('dir-test');
|
|
7
7
|
|
|
8
8
|
it('Sanitizes filenames', () => {
|
|
9
9
|
const name = testDir.sanitize(':/something/else.json');
|
|
@@ -18,14 +18,14 @@ describe('Dir', () => {
|
|
|
18
18
|
assert(sub.path.includes(subPath));
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
it('TempDir.
|
|
22
|
-
const sub = temp.
|
|
21
|
+
it('TempDir.tempDir returns instance of TempDir', () => {
|
|
22
|
+
const sub = temp().tempDir('example');
|
|
23
23
|
assert(sub instanceof TempDir);
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
it('Resolves filenames in folder', () => {
|
|
27
|
-
const txt = temp.filepath('test.txt');
|
|
28
|
-
assert(txt.includes(temp.path));
|
|
27
|
+
const txt = temp().filepath('test.txt');
|
|
28
|
+
assert(txt.includes(temp().path));
|
|
29
29
|
assert(txt.includes('test.txt'));
|
|
30
30
|
});
|
|
31
31
|
});
|
package/src/Dir.ts
CHANGED
|
@@ -4,8 +4,8 @@ import sanitizeFilename from 'sanitize-filename';
|
|
|
4
4
|
import { File } from './File.ts';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Reference to a specific directory with
|
|
8
|
-
*
|
|
7
|
+
* Reference to a specific directory with methods to create and list files.
|
|
8
|
+
* Created immediately if it doesn't exist
|
|
9
9
|
*/
|
|
10
10
|
export class Dir {
|
|
11
11
|
path;
|
|
@@ -13,29 +13,30 @@ export class Dir {
|
|
|
13
13
|
/**
|
|
14
14
|
* @param path can be relative to workspace or absolute
|
|
15
15
|
*/
|
|
16
|
-
constructor(
|
|
17
|
-
this.path =
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
create() {
|
|
16
|
+
constructor(inputPath = './') {
|
|
17
|
+
this.path = path.resolve(inputPath);
|
|
21
18
|
fs.mkdirSync(this.path, { recursive: true });
|
|
22
19
|
}
|
|
23
20
|
|
|
24
21
|
/**
|
|
25
22
|
* Create a new Dir inside the current Dir
|
|
26
|
-
* @param subPath to create
|
|
23
|
+
* @param subPath relative path to create
|
|
27
24
|
* @example
|
|
28
25
|
* const folder = new Dir('example');
|
|
29
|
-
* // folder.path = '
|
|
30
|
-
* const child = folder.
|
|
31
|
-
* // child.path = '
|
|
26
|
+
* // folder.path = '/absolute/path/to/example'
|
|
27
|
+
* const child = folder.dir('path/to/dir');
|
|
28
|
+
* // child.path = '/absolute/path/to/example/path/to/dir'
|
|
32
29
|
*/
|
|
33
30
|
dir(subPath: string) {
|
|
34
31
|
return new Dir(path.resolve(this.path, subPath));
|
|
35
32
|
}
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
return
|
|
34
|
+
tempDir(subPath: string) {
|
|
35
|
+
return new TempDir(path.resolve(this.path, subPath));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
sanitize(filename: string) {
|
|
39
|
+
return sanitizeFilename(filename.replace('https://', '').replace('www.', ''), { replacement: '_' }).slice(-200);
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
/**
|
|
@@ -52,23 +53,25 @@ export class Dir {
|
|
|
52
53
|
file(base: string) {
|
|
53
54
|
return new File(this.filepath(base));
|
|
54
55
|
}
|
|
56
|
+
|
|
57
|
+
get files() {
|
|
58
|
+
return fs.readdirSync(this.path).map((filename) => this.file(filename));
|
|
59
|
+
}
|
|
55
60
|
}
|
|
56
61
|
|
|
57
62
|
/**
|
|
58
63
|
* Extends Dir class with method to `clear()` contents
|
|
59
64
|
*/
|
|
60
65
|
export class TempDir extends Dir {
|
|
61
|
-
dir(subPath: string) {
|
|
62
|
-
return new TempDir(path.resolve(this.path, subPath));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
66
|
clear() {
|
|
66
67
|
fs.rmSync(this.path, { recursive: true, force: true });
|
|
67
|
-
this.
|
|
68
|
+
fs.mkdirSync(this.path, { recursive: true });
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
/**
|
|
72
|
-
*
|
|
73
|
+
* Creates a '.temp' directory in current working directory
|
|
73
74
|
*/
|
|
74
|
-
export
|
|
75
|
+
export function temp() {
|
|
76
|
+
return new TempDir('.temp');
|
|
77
|
+
}
|
package/src/File.test.ts
CHANGED
package/src/File.ts
CHANGED
|
@@ -10,9 +10,20 @@ import { snapshot } from './snapshot.ts';
|
|
|
10
10
|
*/
|
|
11
11
|
export class File {
|
|
12
12
|
path;
|
|
13
|
+
root;
|
|
14
|
+
dir;
|
|
15
|
+
base;
|
|
16
|
+
ext;
|
|
17
|
+
name;
|
|
13
18
|
|
|
14
19
|
constructor(filepath: string) {
|
|
15
20
|
this.path = filepath;
|
|
21
|
+
const { root, dir, base, ext, name } = path.parse(filepath);
|
|
22
|
+
this.root = root;
|
|
23
|
+
this.dir = dir;
|
|
24
|
+
this.base = base;
|
|
25
|
+
this.ext = ext;
|
|
26
|
+
this.name = name;
|
|
16
27
|
}
|
|
17
28
|
|
|
18
29
|
get exists() {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { describe } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
import { Format } from './Format.ts';
|
|
4
|
+
|
|
5
|
+
describe('Format.round', () => {
|
|
6
|
+
assert.equal(Format.round(1.22), '1');
|
|
7
|
+
assert.equal(Format.round(1.55), '2');
|
|
8
|
+
assert.equal(Format.round(1.823, 2), '1.82');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
describe('Format.ms', () => {
|
|
12
|
+
const SECOND = 1000;
|
|
13
|
+
const MINUTE = 60 * SECOND;
|
|
14
|
+
const HOUR = 60 * MINUTE;
|
|
15
|
+
const DAY = 24 * HOUR;
|
|
16
|
+
assert.equal(Format.ms(100), '100ms');
|
|
17
|
+
assert.equal(Format.ms(5 * SECOND), '5s');
|
|
18
|
+
assert.equal(Format.ms(75 * SECOND), '1m 15s');
|
|
19
|
+
assert.equal(Format.ms(30 * MINUTE + 30 * SECOND), '30m 30s');
|
|
20
|
+
assert.equal(Format.ms(2 * HOUR + 2 * MINUTE), '2h 2m');
|
|
21
|
+
assert.equal(Format.ms(2 * DAY + 2 * HOUR), '2d 2h');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('Format.bytes', () => {
|
|
25
|
+
const base = 1024;
|
|
26
|
+
assert.equal(Format.bytes(2), '2 b');
|
|
27
|
+
assert.equal(Format.bytes(base), '1 KB');
|
|
28
|
+
assert.equal(Format.bytes(base + 0.1 * base), '1.1 KB');
|
|
29
|
+
assert.equal(Format.bytes(base + 0.25 * base), '1.25 KB');
|
|
30
|
+
assert.equal(Format.bytes(base ** 2), '1 MB');
|
|
31
|
+
assert.equal(Format.bytes(base ** 3), '1 GB');
|
|
32
|
+
assert.equal(Format.bytes(base ** 4), '1 TB');
|
|
33
|
+
assert.equal(Format.bytes(base ** 5), '1,024 TB');
|
|
34
|
+
});
|
package/src/Format.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { format, formatISO, type DateArg } from 'date-fns';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Helpers for formatting dates, times, and numbers as strings
|
|
5
|
+
*/
|
|
6
|
+
export class Format {
|
|
7
|
+
/**
|
|
8
|
+
* date-fns format() with some shortcuts
|
|
9
|
+
* @param formatStr
|
|
10
|
+
* 'iso' to get ISO date, 'ymd' to format as 'yyyy-MM-dd', full options: https://date-fns.org/v4.1.0/docs/format
|
|
11
|
+
*/
|
|
12
|
+
static date(formatStr: 'iso' | 'ymd' | string = 'iso', d: DateArg<Date> = new Date()) {
|
|
13
|
+
if (formatStr === 'iso') return formatISO(d);
|
|
14
|
+
if (formatStr === 'ymd') return format(d, 'yyyy-MM-dd');
|
|
15
|
+
return format(d, formatStr);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Round a number to a specific set of places
|
|
20
|
+
*/
|
|
21
|
+
static round(n: number, places = 0) {
|
|
22
|
+
return new Intl.NumberFormat('en-US', { maximumFractionDigits: places }).format(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Make millisecond durations actually readable (eg "123ms", "3.56s", "1m 34s", "3h 24m", "2d 4h")
|
|
27
|
+
*/
|
|
28
|
+
static ms(ms: number) {
|
|
29
|
+
if (ms < 1000) return `${this.round(ms)}ms`;
|
|
30
|
+
const s = ms / 1000;
|
|
31
|
+
if (s < 60) return `${this.round(s, 2)}s`;
|
|
32
|
+
const m = Math.floor(s / 60);
|
|
33
|
+
if (m < 60) return `${m}m ${Math.floor(s) % 60}s`;
|
|
34
|
+
const h = Math.floor(m / 60);
|
|
35
|
+
if (h < 24) return `${h}h ${m % 60}m`;
|
|
36
|
+
const d = Math.floor(h / 24);
|
|
37
|
+
return `${d}d ${h % 24}h`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static bytes(b: number) {
|
|
41
|
+
const labels = ['b', 'KB', 'MB', 'GB', 'TB'];
|
|
42
|
+
let factor = 0;
|
|
43
|
+
while (b >= 1024 && labels[factor + 1]) {
|
|
44
|
+
b = b / 1024;
|
|
45
|
+
factor++;
|
|
46
|
+
}
|
|
47
|
+
return `${this.round(b, 2)} ${labels[factor]}`;
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { Dir, TempDir, temp } from './Dir.ts';
|
|
|
2
2
|
export { Cache } from './Cache.ts';
|
|
3
3
|
export { Fetcher, type Route, type Query, type FetchOptions } from './Fetcher.ts';
|
|
4
4
|
export { File, FileType, FileTypeJson, FileTypeNdjson, FileTypeCsv } from './File.ts';
|
|
5
|
+
export { Format } from './Format.ts';
|
|
5
6
|
export { Log } from './Log.ts';
|
|
6
7
|
export { snapshot } from './snapshot.ts';
|
|
7
8
|
export { timeout } from './timeout.ts';
|
package/src/snapshot.test.ts
CHANGED
|
@@ -46,9 +46,9 @@ describe('snapshot', () => {
|
|
|
46
46
|
const t1 = createThing(1);
|
|
47
47
|
const t2 = createThing(2, t1);
|
|
48
48
|
const result = snapshot(t1, 20) as Thing;
|
|
49
|
-
const f1 = temp.file('recursive').json(result);
|
|
49
|
+
const f1 = temp().file('recursive').json(result);
|
|
50
50
|
const parsed = f1.read();
|
|
51
|
-
const f2 = temp.file('recursive2').json(parsed);
|
|
51
|
+
const f2 = temp().file('recursive2').json(parsed);
|
|
52
52
|
assert.deepEqual(f1.read(), f2.read());
|
|
53
53
|
});
|
|
54
54
|
});
|