@naturalcycles/nodejs-lib 15.134.0 → 15.135.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.
- package/dist/fs/fs2.d.ts +4 -7
- package/dist/fs/fs2.js +19 -16
- package/dist/stream/writable/writableChunk.js +3 -3
- package/package.json +1 -1
- package/src/fs/fs2.ts +19 -21
- package/src/stream/writable/writableChunk.ts +3 -3
package/dist/fs/fs2.d.ts
CHANGED
|
@@ -25,15 +25,15 @@ declare class FS2 {
|
|
|
25
25
|
writeFile(filePath: string, data: string | Uint8Array, opt?: WriteFileOptions): void;
|
|
26
26
|
writeFileAsync(filePath: string, data: string | Uint8Array, opt?: WriteFileOptions): Promise<void>;
|
|
27
27
|
writePrettyJson(filePath: string, data: any): void;
|
|
28
|
-
writeJson(filePath: string, data: any
|
|
28
|
+
writeJson(filePath: string, data: any): void;
|
|
29
29
|
writePrettyJsonAsync(filePath: string, data: any): Promise<void>;
|
|
30
|
-
writeJsonAsync(filePath: string, data: any
|
|
30
|
+
writeJsonAsync(filePath: string, data: any): Promise<void>;
|
|
31
31
|
appendFile(filePath: string, data: string | Uint8Array): void;
|
|
32
32
|
appendFileAsync(filePath: string, data: string | Uint8Array): Promise<void>;
|
|
33
33
|
outputPrettyJson(filePath: string, data: any): void;
|
|
34
|
-
outputJson(filePath: string, data: any
|
|
34
|
+
outputJson(filePath: string, data: any): void;
|
|
35
35
|
outputPrettyJsonAsync(filePath: string, data: any): Promise<void>;
|
|
36
|
-
outputJsonAsync(filePath: string, data: any
|
|
36
|
+
outputJsonAsync(filePath: string, data: any): Promise<void>;
|
|
37
37
|
outputFile(filePath: string, data: string | Uint8Array): void;
|
|
38
38
|
outputFileAsync(filePath: string, data: string | Uint8Array): Promise<void>;
|
|
39
39
|
pathExists(filePath: string): boolean;
|
|
@@ -79,7 +79,4 @@ declare class FS2 {
|
|
|
79
79
|
createReadStream: typeof fs.createReadStream;
|
|
80
80
|
}
|
|
81
81
|
export declare const fs2: FS2;
|
|
82
|
-
export interface JsonOptions {
|
|
83
|
-
spaces?: number;
|
|
84
|
-
}
|
|
85
82
|
export {};
|
package/dist/fs/fs2.js
CHANGED
|
@@ -62,17 +62,19 @@ class FS2 {
|
|
|
62
62
|
await fsp.writeFile(filePath, data, opt);
|
|
63
63
|
}
|
|
64
64
|
writePrettyJson(filePath, data) {
|
|
65
|
-
|
|
65
|
+
const str = stringifyPretty(data);
|
|
66
|
+
fs.writeFileSync(filePath, str);
|
|
66
67
|
}
|
|
67
|
-
writeJson(filePath, data
|
|
68
|
-
const str = stringify(data
|
|
68
|
+
writeJson(filePath, data) {
|
|
69
|
+
const str = JSON.stringify(data);
|
|
69
70
|
fs.writeFileSync(filePath, str);
|
|
70
71
|
}
|
|
71
72
|
async writePrettyJsonAsync(filePath, data) {
|
|
72
|
-
|
|
73
|
+
const str = stringifyPretty(data);
|
|
74
|
+
await fsp.writeFile(filePath, str);
|
|
73
75
|
}
|
|
74
|
-
async writeJsonAsync(filePath, data
|
|
75
|
-
const str = stringify(data
|
|
76
|
+
async writeJsonAsync(filePath, data) {
|
|
77
|
+
const str = JSON.stringify(data);
|
|
76
78
|
await fsp.writeFile(filePath, str);
|
|
77
79
|
}
|
|
78
80
|
appendFile(filePath, data) {
|
|
@@ -82,17 +84,19 @@ class FS2 {
|
|
|
82
84
|
await fsp.appendFile(filePath, data);
|
|
83
85
|
}
|
|
84
86
|
outputPrettyJson(filePath, data) {
|
|
85
|
-
|
|
87
|
+
const str = stringifyPretty(data);
|
|
88
|
+
this.outputFile(filePath, str);
|
|
86
89
|
}
|
|
87
|
-
outputJson(filePath, data
|
|
88
|
-
const str = stringify(data
|
|
90
|
+
outputJson(filePath, data) {
|
|
91
|
+
const str = JSON.stringify(data);
|
|
89
92
|
this.outputFile(filePath, str);
|
|
90
93
|
}
|
|
91
94
|
async outputPrettyJsonAsync(filePath, data) {
|
|
92
|
-
|
|
95
|
+
const str = stringifyPretty(data);
|
|
96
|
+
await this.outputFileAsync(filePath, str);
|
|
93
97
|
}
|
|
94
|
-
async outputJsonAsync(filePath, data
|
|
95
|
-
const str = stringify(data
|
|
98
|
+
async outputJsonAsync(filePath, data) {
|
|
99
|
+
const str = JSON.stringify(data);
|
|
96
100
|
await this.outputFileAsync(filePath, str);
|
|
97
101
|
}
|
|
98
102
|
outputFile(filePath, data) {
|
|
@@ -276,8 +280,7 @@ class FS2 {
|
|
|
276
280
|
createReadStream = fs.createReadStream;
|
|
277
281
|
}
|
|
278
282
|
export const fs2 = new FS2();
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
return JSON.stringify(data, null, opt?.spaces) + (opt?.spaces ? '\n' : '');
|
|
283
|
+
function stringifyPretty(data) {
|
|
284
|
+
// Add a newline at the end (to match our prettier config)
|
|
285
|
+
return JSON.stringify(data, null, 2) + '\n';
|
|
283
286
|
}
|
|
@@ -36,7 +36,7 @@ export function writableChunk(splitPredicate, fn, opt = {}) {
|
|
|
36
36
|
logger.debug(`WritableChunk(${splitIndex}): pause`);
|
|
37
37
|
}
|
|
38
38
|
if (splitPredicate(chunk, ++indexWritten)) {
|
|
39
|
-
logger.
|
|
39
|
+
logger.debug(`WritableChunk(${splitIndex}): splitting to ${splitIndex + 1}`);
|
|
40
40
|
splitIndex++;
|
|
41
41
|
fork.push(null);
|
|
42
42
|
lock?.resolve();
|
|
@@ -47,7 +47,7 @@ export function writableChunk(splitPredicate, fn, opt = {}) {
|
|
|
47
47
|
cb();
|
|
48
48
|
},
|
|
49
49
|
async final(cb) {
|
|
50
|
-
logger.
|
|
50
|
+
logger.debug(`WritableChunk: final`);
|
|
51
51
|
// Pushing null "closes"/ends the secondary pipeline correctly
|
|
52
52
|
fork.push(null);
|
|
53
53
|
// Acknowledge that we've received `null` and passed it through to the fork
|
|
@@ -67,7 +67,7 @@ export function writableChunk(splitPredicate, fn, opt = {}) {
|
|
|
67
67
|
lockCopy.resolve();
|
|
68
68
|
});
|
|
69
69
|
void fn(Pipeline.from(readable), currentSplitIndex).then(() => {
|
|
70
|
-
logger.
|
|
70
|
+
logger.debug(`WritableChunk(${currentSplitIndex}): done`);
|
|
71
71
|
});
|
|
72
72
|
return readable;
|
|
73
73
|
}
|
package/package.json
CHANGED
package/src/fs/fs2.ts
CHANGED
|
@@ -78,20 +78,22 @@ class FS2 {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
writePrettyJson(filePath: string, data: any): void {
|
|
81
|
-
|
|
81
|
+
const str = stringifyPretty(data)
|
|
82
|
+
fs.writeFileSync(filePath, str)
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
writeJson(filePath: string, data: any
|
|
85
|
-
const str = stringify(data
|
|
85
|
+
writeJson(filePath: string, data: any): void {
|
|
86
|
+
const str = JSON.stringify(data)
|
|
86
87
|
fs.writeFileSync(filePath, str)
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
async writePrettyJsonAsync(filePath: string, data: any): Promise<void> {
|
|
90
|
-
|
|
91
|
+
const str = stringifyPretty(data)
|
|
92
|
+
await fsp.writeFile(filePath, str)
|
|
91
93
|
}
|
|
92
94
|
|
|
93
|
-
async writeJsonAsync(filePath: string, data: any
|
|
94
|
-
const str = stringify(data
|
|
95
|
+
async writeJsonAsync(filePath: string, data: any): Promise<void> {
|
|
96
|
+
const str = JSON.stringify(data)
|
|
95
97
|
await fsp.writeFile(filePath, str)
|
|
96
98
|
}
|
|
97
99
|
|
|
@@ -104,20 +106,22 @@ class FS2 {
|
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
outputPrettyJson(filePath: string, data: any): void {
|
|
107
|
-
|
|
109
|
+
const str = stringifyPretty(data)
|
|
110
|
+
this.outputFile(filePath, str)
|
|
108
111
|
}
|
|
109
112
|
|
|
110
|
-
outputJson(filePath: string, data: any
|
|
111
|
-
const str = stringify(data
|
|
113
|
+
outputJson(filePath: string, data: any): void {
|
|
114
|
+
const str = JSON.stringify(data)
|
|
112
115
|
this.outputFile(filePath, str)
|
|
113
116
|
}
|
|
114
117
|
|
|
115
118
|
async outputPrettyJsonAsync(filePath: string, data: any): Promise<void> {
|
|
116
|
-
|
|
119
|
+
const str = stringifyPretty(data)
|
|
120
|
+
await this.outputFileAsync(filePath, str)
|
|
117
121
|
}
|
|
118
122
|
|
|
119
|
-
async outputJsonAsync(filePath: string, data: any
|
|
120
|
-
const str = stringify(data
|
|
123
|
+
async outputJsonAsync(filePath: string, data: any): Promise<void> {
|
|
124
|
+
const str = JSON.stringify(data)
|
|
121
125
|
await this.outputFileAsync(filePath, str)
|
|
122
126
|
}
|
|
123
127
|
|
|
@@ -324,13 +328,7 @@ class FS2 {
|
|
|
324
328
|
|
|
325
329
|
export const fs2 = new FS2()
|
|
326
330
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
spaces?: number
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
function stringify(data: any, opt?: JsonOptions): string {
|
|
334
|
-
// If pretty-printing is enabled (spaces) - also add a newline at the end (to match our prettier config)
|
|
335
|
-
return JSON.stringify(data, null, opt?.spaces) + (opt?.spaces ? '\n' : '')
|
|
331
|
+
function stringifyPretty(data: any): string {
|
|
332
|
+
// Add a newline at the end (to match our prettier config)
|
|
333
|
+
return JSON.stringify(data, null, 2) + '\n'
|
|
336
334
|
}
|
|
@@ -48,7 +48,7 @@ export function writableChunk<T>(
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
if (splitPredicate(chunk, ++indexWritten)) {
|
|
51
|
-
logger.
|
|
51
|
+
logger.debug(`WritableChunk(${splitIndex}): splitting to ${splitIndex + 1}`)
|
|
52
52
|
splitIndex++
|
|
53
53
|
fork.push(null)
|
|
54
54
|
lock?.resolve()
|
|
@@ -60,7 +60,7 @@ export function writableChunk<T>(
|
|
|
60
60
|
cb()
|
|
61
61
|
},
|
|
62
62
|
async final(cb) {
|
|
63
|
-
logger.
|
|
63
|
+
logger.debug(`WritableChunk: final`)
|
|
64
64
|
|
|
65
65
|
// Pushing null "closes"/ends the secondary pipeline correctly
|
|
66
66
|
fork.push(null)
|
|
@@ -84,7 +84,7 @@ export function writableChunk<T>(
|
|
|
84
84
|
})
|
|
85
85
|
|
|
86
86
|
void fn(Pipeline.from<T>(readable), currentSplitIndex).then(() => {
|
|
87
|
-
logger.
|
|
87
|
+
logger.debug(`WritableChunk(${currentSplitIndex}): done`)
|
|
88
88
|
})
|
|
89
89
|
|
|
90
90
|
return readable
|