@procedures/fs 0.27.4 → 0.27.5

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.
@@ -1,11 +1,11 @@
1
1
  /**
2
- * The atomic write of a file (roadmap O51).
2
+ * The atomic write of a file (roadmap O51 and O52).
3
3
  *
4
4
  * `writeFileAtomic()` writes the data to a new temporary file in the folder of the target. Then it
5
5
  * renames the temporary file over the target. Thus a reader sees the old file or the whole new
6
- * file, also after a crash.
6
+ * file, also after a crash. `writeFileAtomicSync()` does the same steps without a promise.
7
7
  */
8
- /** The options of `writeFileAtomic()`. */
8
+ /** The options of `writeFileAtomic()` and `writeFileAtomicSync()`. */
9
9
  export interface WriteFileAtomicOptions {
10
10
  /** The encoding of a string `data`. The default is `utf8`. */
11
11
  encoding?: BufferEncoding | undefined;
@@ -21,6 +21,15 @@ export interface WriteFileAtomicOptions {
21
21
  * is 2000 on Windows and 0 on the other platforms.
22
22
  */
23
23
  renameRetryMs?: number | undefined;
24
+ /**
25
+ * The function that gives the name of the temporary file. It gets the absolute path of the target,
26
+ * after the function follows a symlink.
27
+ *
28
+ * The temporary file is in the folder of the target, so a name with `/` or `\` is an error. The
29
+ * default name is `.<name>.<16 hex digits>.tmp`, where `<name>` is the first 32 characters of the
30
+ * name of the target.
31
+ */
32
+ tempName?: ((target: string) => string) | undefined;
24
33
  }
25
34
  /**
26
35
  * This function writes `data` to `path` in one step for each reader. A reader sees the old file or
@@ -31,9 +40,19 @@ export interface WriteFileAtomicOptions {
31
40
  * - On Windows, an open handle of the target blocks the rename. Then the function tries the rename again for `renameRetryMs`.
32
41
  * - After a failure, the function removes the temporary file and throws the error.
33
42
  * - The file keeps the permissions of the target, unless `options.mode` is set. It does not keep the owner.
43
+ * - When the group and the others cannot read the final file, the temporary file gets `0o600` before the write of the data.
34
44
  * - When `path` is a symlink, the function replaces the target of the link.
35
45
  *
36
46
  * Two writes at the same time do not mix: the file gets the data of one of them. The folder must exist.
47
+ * The name of the temporary file is `.<name>.<16 hex digits>.tmp`, unless `options.tempName` gives a name.
37
48
  */
38
49
  export declare function writeFileAtomic(path: string, data: string | Uint8Array, options?: WriteFileAtomicOptions): Promise<void>;
50
+ /**
51
+ * This function is the sync form of `writeFileAtomic()`. It does the same steps, with the same
52
+ * options and the same errors.
53
+ *
54
+ * - It blocks the thread until the file is in place.
55
+ * - On Windows, a locked target can block the thread for `renameRetryMs` (2000 by default) while the function tries the rename again.
56
+ */
57
+ export declare function writeFileAtomicSync(path: string, data: string | Uint8Array, options?: WriteFileAtomicOptions): void;
39
58
  //# sourceMappingURL=atomic.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"atomic.d.ts","sourceRoot":"","sources":["../../src/files/atomic.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,0CAA0C;AAC1C,MAAM,WAAW,sBAAsB;IACrC,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;IACtC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,4GAA4G;IAC5G,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAuGD;;;;;;;;;;;;GAYG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,UAAU,EACzB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,IAAI,CAAC,CA6Bf"}
1
+ {"version":3,"file":"atomic.d.ts","sourceRoot":"","sources":["../../src/files/atomic.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAoBH,sEAAsE;AACtE,MAAM,WAAW,sBAAsB;IACrC,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;IACtC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,4GAA4G;IAC5G,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,SAAS,CAAC;CACrD;AAoPD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,OAAO,GAAE,sBAA2B,GAAG,OAAO,CAAC,IAAI,CAAC,CAE5H;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,OAAO,GAAE,sBAA2B,GAAG,IAAI,CAEvH"}
@@ -1,18 +1,22 @@
1
1
  /**
2
- * The atomic write of a file (roadmap O51).
2
+ * The atomic write of a file (roadmap O51 and O52).
3
3
  *
4
4
  * `writeFileAtomic()` writes the data to a new temporary file in the folder of the target. Then it
5
5
  * renames the temporary file over the target. Thus a reader sees the old file or the whole new
6
- * file, also after a crash.
6
+ * file, also after a crash. `writeFileAtomicSync()` does the same steps without a promise.
7
7
  */
8
8
  import { randomBytes } from "node:crypto";
9
+ import { chmodSync, closeSync, fchmodSync, fsyncSync, openSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync, } from "node:fs";
9
10
  import { chmod, open, realpath, rename, stat, unlink } from "node:fs/promises";
10
11
  import { basename, dirname, join, resolve } from "node:path";
11
12
  import { setTimeout as sleep } from "node:timers/promises";
13
+ import { perform, runAsync, runSync } from "./steps.js";
12
14
  /** On Windows, an antivirus or an indexer that holds the target open gives these errors for a short time. */
13
15
  const LOCKED = new Set(["EPERM", "EACCES", "EBUSY"]);
14
16
  /** A file system that cannot flush a folder gives these errors. The write is complete without the flush. */
15
17
  const NO_FOLDER_SYNC = new Set(["EINVAL", "ENOTSUP", "EISDIR", "EBADF", "EPERM", "EACCES"]);
18
+ /** The permission bits that let the group and the others read a file. */
19
+ const OTHERS_READ = 0o044;
16
20
  /** True on Windows. The function reads the platform at each call, so a test can change it. */
17
21
  function isWindows() {
18
22
  return process.platform === "win32";
@@ -27,10 +31,10 @@ function isMissing(error) {
27
31
  return code === "ENOENT" || code === "ENOTDIR";
28
32
  }
29
33
  /** The absolute path of the file to replace. The function follows a symlink, so the link stays a link. */
30
- async function targetOf(path) {
34
+ function* targetOf(path) {
31
35
  const absolute = resolve(path);
32
36
  try {
33
- return await realpath(absolute);
37
+ return yield* perform({ op: "realpath", path: absolute });
34
38
  }
35
39
  catch (error) {
36
40
  if (isMissing(error))
@@ -39,9 +43,9 @@ async function targetOf(path) {
39
43
  }
40
44
  }
41
45
  /** The permission bits of the target, or undefined when the target does not exist. */
42
- async function modeOf(target) {
46
+ function* modeOf(target) {
43
47
  try {
44
- return (await stat(target)).mode & 0o7777;
48
+ return yield* perform({ op: "mode", path: target });
45
49
  }
46
50
  catch (error) {
47
51
  if (isMissing(error))
@@ -49,46 +53,66 @@ async function modeOf(target) {
49
53
  throw error;
50
54
  }
51
55
  }
56
+ /** The `ERR_INVALID_ARG_VALUE` error of a name of a temporary file that is not in the folder of the target. */
57
+ function badTempName(name) {
58
+ const error = new TypeError(`The option tempName gave ${JSON.stringify(name)}. Give the name of a new file in the folder of the target, without "/" or "\\".`);
59
+ return Object.assign(error, { code: "ERR_INVALID_ARG_VALUE" });
60
+ }
61
+ /**
62
+ * A new path next to the target. The default name starts with a dot and ends in `.tmp`. Thus a
63
+ * reader that looks for the extension of the target does not see it. The name keeps 32 characters
64
+ * of the target, so it does not become too long.
65
+ */
66
+ function tempPathOf(target, tempName) {
67
+ const own = basename(target);
68
+ if (!tempName)
69
+ return join(dirname(target), `.${[...own].slice(0, 32).join("")}.${randomBytes(8).toString("hex")}.tmp`);
70
+ const name = tempName(target);
71
+ if (typeof name !== "string" || name === "" || name === "." || name === ".." || name === own || /[\\/]/.test(name)) {
72
+ throw badTempName(name);
73
+ }
74
+ return join(dirname(target), name);
75
+ }
52
76
  /**
53
- * A new path next to the target. The name starts with a dot and ends in `.tmp`, so a reader that
54
- * looks for the extension of the target does not see it. The name keeps 32 characters of the
55
- * target, so it does not become too long.
77
+ * The permissions of the new temporary file. When the final file hides its data from the group and
78
+ * the others, the temporary file gets `0o600` from the start. Then no other user can read it.
56
79
  */
57
- function tempPathOf(target) {
58
- const name = [...basename(target)].slice(0, 32).join("");
59
- return join(dirname(target), `.${name}.${randomBytes(8).toString("hex")}.tmp`);
80
+ function createModeOf(mode) {
81
+ if (mode === undefined)
82
+ return 0o666;
83
+ return (mode & OTHERS_READ) === 0 ? 0o600 : mode;
60
84
  }
61
85
  /**
62
86
  * The rename, tried again with a longer wait each time until `retryMs` is over. A random part of
63
87
  * each wait keeps two writers of one target out of step.
64
88
  */
65
- async function renameWithRetry(from, to, retryMs) {
89
+ function* renameWithRetry(from, to, retryMs) {
66
90
  const deadline = Date.now() + retryMs;
67
91
  for (let step = 10;; step = Math.min(step * 2, 100)) {
68
92
  try {
69
- await rename(from, to);
93
+ yield { op: "rename", from, to };
70
94
  return;
71
95
  }
72
96
  catch (error) {
73
97
  const delay = Math.round(step * (0.5 + Math.random()));
74
98
  if (!LOCKED.has(codeOf(error)) || Date.now() + delay > deadline)
75
99
  throw error;
76
- await sleep(delay);
100
+ yield { op: "sleep", ms: delay };
77
101
  }
78
102
  }
79
103
  }
80
104
  /** The removal of the temporary file after a failure. The original error is more important than an error here. */
81
- async function removeTemp(temp) {
105
+ function* removeTemp(temp) {
82
106
  try {
83
- await unlink(temp);
107
+ yield { op: "unlink", path: temp };
84
108
  }
85
109
  catch (error) {
86
110
  if (codeOf(error) !== "EPERM")
87
111
  return;
88
112
  // Windows does not remove a read-only file, so the function clears the flag and tries again
89
113
  try {
90
- await chmod(temp, 0o666);
91
- await unlink(temp);
114
+ yield { op: "chmod", path: temp, mode: 0o666 };
115
+ yield { op: "unlink", path: temp };
92
116
  }
93
117
  catch {
94
118
  // The temporary file stays. The error of the write is the error that the caller gets.
@@ -96,69 +120,146 @@ async function removeTemp(temp) {
96
120
  }
97
121
  }
98
122
  /** The flush of the folder, so that the rename is on the disk. Windows cannot open a folder for it. */
99
- async function syncFolder(folder) {
123
+ function* syncFolder(folder) {
100
124
  if (isWindows())
101
125
  return;
102
126
  let handle;
103
127
  try {
104
- handle = await open(folder, "r");
105
- await handle.sync();
128
+ handle = yield* perform({ op: "openFolder", path: folder });
129
+ yield { op: "fsync", handle };
106
130
  }
107
131
  catch (error) {
108
132
  if (!NO_FOLDER_SYNC.has(codeOf(error)))
109
133
  throw error;
110
134
  }
111
135
  finally {
112
- await handle?.close();
136
+ if (handle !== undefined)
137
+ yield { op: "close", handle };
113
138
  }
114
139
  }
115
- /**
116
- * This function writes `data` to `path` in one step for each reader. A reader sees the old file or
117
- * the whole new file. It does not see a part of a file at any time.
118
- *
119
- * - The function writes a new temporary file in the folder of the target and flushes it to the disk.
120
- * - Then it renames the temporary file over the target and flushes the folder. Windows gets no flush of the folder.
121
- * - On Windows, an open handle of the target blocks the rename. Then the function tries the rename again for `renameRetryMs`.
122
- * - After a failure, the function removes the temporary file and throws the error.
123
- * - The file keeps the permissions of the target, unless `options.mode` is set. It does not keep the owner.
124
- * - When `path` is a symlink, the function replaces the target of the link.
125
- *
126
- * Two writes at the same time do not mix: the file gets the data of one of them. The folder must exist.
127
- */
128
- export async function writeFileAtomic(path, data, options = {}) {
129
- const target = await targetOf(path);
130
- const mode = options.mode ?? (await modeOf(target));
140
+ /** The steps of `writeFileAtomic()` and `writeFileAtomicSync()`. */
141
+ function* writeSteps(path, data, options) {
142
+ const target = yield* targetOf(path);
143
+ const mode = options.mode ?? (yield* modeOf(target));
131
144
  const flush = options.fsync ?? true;
132
- const temp = tempPathOf(target);
145
+ const temp = tempPathOf(target, options.tempName);
133
146
  let created = false;
134
147
  let handle;
135
148
  try {
136
- handle = await open(temp, "wx", mode ?? 0o666);
149
+ handle = yield* perform({ op: "create", path: temp, mode: createModeOf(mode) });
137
150
  created = true;
138
- await handle.writeFile(data, { encoding: options.encoding ?? "utf8" });
139
- // The umask changes the mode of open(), so the function sets the mode again
151
+ yield { op: "write", handle, data, encoding: options.encoding ?? "utf8" };
152
+ // The umask changes the mode of the open, and a secret file starts at 0o600, so the function sets the final mode
140
153
  if (mode !== undefined)
141
- await handle.chmod(mode);
154
+ yield { op: "fchmod", handle, mode };
142
155
  if (flush)
143
- await handle.sync();
144
- await handle.close();
156
+ yield { op: "fsync", handle };
157
+ yield { op: "close", handle };
145
158
  handle = undefined;
146
- await renameWithRetry(temp, target, options.renameRetryMs ?? (isWindows() ? 2000 : 0));
159
+ yield* renameWithRetry(temp, target, options.renameRetryMs ?? (isWindows() ? 2000 : 0));
147
160
  }
148
161
  catch (error) {
149
- if (handle) {
162
+ if (handle !== undefined) {
150
163
  try {
151
- await handle.close();
164
+ yield { op: "close", handle };
152
165
  }
153
166
  catch {
154
167
  // The error of the write is the error that the caller gets
155
168
  }
156
169
  }
157
170
  if (created)
158
- await removeTemp(temp);
171
+ yield* removeTemp(temp);
159
172
  throw error;
160
173
  }
161
174
  if (flush)
162
- await syncFolder(dirname(target));
175
+ yield* syncFolder(dirname(target));
176
+ }
177
+ /** The async operations of the file system, with `node:fs/promises`. */
178
+ async function doAsync(op) {
179
+ switch (op.op) {
180
+ case "realpath":
181
+ return realpath(op.path);
182
+ case "mode":
183
+ return (await stat(op.path)).mode & 0o7777;
184
+ case "create":
185
+ return open(op.path, "wx", op.mode);
186
+ case "openFolder":
187
+ return open(op.path, "r");
188
+ case "write":
189
+ return op.handle.writeFile(op.data, { encoding: op.encoding });
190
+ case "fchmod":
191
+ return op.handle.chmod(op.mode);
192
+ case "fsync":
193
+ return op.handle.sync();
194
+ case "close":
195
+ return op.handle.close();
196
+ case "rename":
197
+ return rename(op.from, op.to);
198
+ case "unlink":
199
+ return unlink(op.path);
200
+ case "chmod":
201
+ return chmod(op.path, op.mode);
202
+ case "sleep":
203
+ return sleep(op.ms);
204
+ }
205
+ }
206
+ let sleeper;
207
+ /** The sync operations of the file system, with `node:fs`. A wait blocks the thread with `Atomics.wait()`. */
208
+ function doSync(op) {
209
+ switch (op.op) {
210
+ case "realpath":
211
+ return realpathSync.native(op.path);
212
+ case "mode":
213
+ return statSync(op.path).mode & 0o7777;
214
+ case "create":
215
+ return openSync(op.path, "wx", op.mode);
216
+ case "openFolder":
217
+ return openSync(op.path, "r");
218
+ case "write":
219
+ return writeFileSync(op.handle, op.data, { encoding: op.encoding });
220
+ case "fchmod":
221
+ return fchmodSync(op.handle, op.mode);
222
+ case "fsync":
223
+ return fsyncSync(op.handle);
224
+ case "close":
225
+ return closeSync(op.handle);
226
+ case "rename":
227
+ return renameSync(op.from, op.to);
228
+ case "unlink":
229
+ return unlinkSync(op.path);
230
+ case "chmod":
231
+ return chmodSync(op.path, op.mode);
232
+ case "sleep":
233
+ sleeper ??= new Int32Array(new SharedArrayBuffer(4));
234
+ return Atomics.wait(sleeper, 0, 0, op.ms);
235
+ }
236
+ }
237
+ /**
238
+ * This function writes `data` to `path` in one step for each reader. A reader sees the old file or
239
+ * the whole new file. It does not see a part of a file at any time.
240
+ *
241
+ * - The function writes a new temporary file in the folder of the target and flushes it to the disk.
242
+ * - Then it renames the temporary file over the target and flushes the folder. Windows gets no flush of the folder.
243
+ * - On Windows, an open handle of the target blocks the rename. Then the function tries the rename again for `renameRetryMs`.
244
+ * - After a failure, the function removes the temporary file and throws the error.
245
+ * - The file keeps the permissions of the target, unless `options.mode` is set. It does not keep the owner.
246
+ * - When the group and the others cannot read the final file, the temporary file gets `0o600` before the write of the data.
247
+ * - When `path` is a symlink, the function replaces the target of the link.
248
+ *
249
+ * Two writes at the same time do not mix: the file gets the data of one of them. The folder must exist.
250
+ * The name of the temporary file is `.<name>.<16 hex digits>.tmp`, unless `options.tempName` gives a name.
251
+ */
252
+ export function writeFileAtomic(path, data, options = {}) {
253
+ return runAsync(writeSteps(path, data, options), doAsync);
254
+ }
255
+ /**
256
+ * This function is the sync form of `writeFileAtomic()`. It does the same steps, with the same
257
+ * options and the same errors.
258
+ *
259
+ * - It blocks the thread until the file is in place.
260
+ * - On Windows, a locked target can block the thread for `renameRetryMs` (2000 by default) while the function tries the rename again.
261
+ */
262
+ export function writeFileAtomicSync(path, data, options = {}) {
263
+ runSync(writeSteps(path, data, options), doSync);
163
264
  }
164
265
  //# sourceMappingURL=atomic.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"atomic.js","sourceRoot":"","sources":["../../src/files/atomic.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAmB,MAAM,kBAAkB,CAAC;AAChG,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,UAAU,IAAI,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAoB3D,6GAA6G;AAC7G,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AAErD,4GAA4G;AAC5G,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE5F,8FAA8F;AAC9F,SAAS,SAAS;IAChB,OAAO,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC;AACtC,CAAC;AAED,uDAAuD;AACvD,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAQ,KAA2C,EAAE,IAAI,IAAI,EAAE,CAAC;AAClE,CAAC;AAED,wDAAwD;AACxD,SAAS,SAAS,CAAC,K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C,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;IAC9C,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,IAAyB,EAAE,OAAO,GAA2B,EAAE;IAC3G,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;AAC5D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAY,EAAE,IAAyB,EAAE,OAAO,GAA2B,EAAE;IAC/G,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC;AACnD,CAAC"}
@@ -27,7 +27,8 @@ export type EditTransform<Current> = (current: Current) => string | undefined |
27
27
  * - A transform that gives the same text, or `undefined`, writes nothing.
28
28
  * - Two paths of the same file share the lock, also when the case of the letters is not the same on Windows.
29
29
  *
30
- * The lock is in the process. It does not stop another process. The options of `writeFileAtomic()` apply to the write.
30
+ * The lock is in the process. It does not stop another process. The options of `writeFileAtomic()` apply to the write,
31
+ * also `tempName` and the `0o600` temporary file of a secret file.
31
32
  */
32
33
  export declare function editFile(path: string, transform: EditTransform<string>, options: EditFileOptions & {
33
34
  initial: string;
@@ -1 +1 @@
1
- {"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../src/files/edit.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAmB,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAG3E,mCAAmC;AACnC,MAAM,WAAW,eAAgB,SAAQ,sBAAsB;IAC7D,iHAAiH;IACjH,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,wEAAwE;IACxE,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;CAClC;AAED,kCAAkC;AAClC,MAA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this entry registers nothing.
2
+ * The file helpers of the package (roadmap O51 and O52): the `./files` entry. They are functions,
3
+ * not procedures, and an import of this entry registers nothing.
4
4
  *
5
- * - `writeFileAtomic()` writes a file in one step for each reader.
6
- * - `healNdjsonTail()` repairs the end of an append-only NDJSON file after a crash.
5
+ * - `writeFileAtomic()` and `writeFileAtomicSync()` write a file in one step for each reader.
6
+ * - `healNdjsonTail()` and `healNdjsonTailSync()` repair the end of an append-only NDJSON file after a crash.
7
7
  * - `KeyedLock` and `withLock()` let one caller at a time hold a key.
8
8
  * - `editFile()` changes a file, one edit at a time for each path.
9
9
  */
10
- export { writeFileAtomic, type WriteFileAtomicOptions } from "./atomic.js";
11
- export { healNdjsonTail, type HealNdjsonTailOptions, type NdjsonTailAction, type NdjsonTailResult } from "./ndjson-tail.js";
10
+ export { writeFileAtomic, writeFileAtomicSync, type WriteFileAtomicOptions } from "./atomic.js";
11
+ export { healNdjsonTail, healNdjsonTailSync, NDJSON_LINE_TOO_LONG, type HealNdjsonTailOptions, type NdjsonTailAction, type NdjsonTailResult, } from "./ndjson-tail.js";
12
12
  export { KeyedLock, withLock, type LockOutcome, type LockRelease, type LockSkipOptions, type LockWaitOptions, } from "./lock.js";
13
13
  export { editFile, type EditFileOptions, type EditFileResult, type EditTransform } from "./edit.js";
14
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/files/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,KAAK,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC5H,OAAO,EACL,SAAS,EACT,QAAQ,EACR,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/files/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAChG,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,SAAS,EACT,QAAQ,EACR,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC"}
@@ -1,14 +1,14 @@
1
1
  /**
2
- * The file helpers of the package (roadmap O51): the `./files` entry. They are functions, not
3
- * procedures, and an import of this entry registers nothing.
2
+ * The file helpers of the package (roadmap O51 and O52): the `./files` entry. They are functions,
3
+ * not procedures, and an import of this entry registers nothing.
4
4
  *
5
- * - `writeFileAtomic()` writes a file in one step for each reader.
6
- * - `healNdjsonTail()` repairs the end of an append-only NDJSON file after a crash.
5
+ * - `writeFileAtomic()` and `writeFileAtomicSync()` write a file in one step for each reader.
6
+ * - `healNdjsonTail()` and `healNdjsonTailSync()` repair the end of an append-only NDJSON file after a crash.
7
7
  * - `KeyedLock` and `withLock()` let one caller at a time hold a key.
8
8
  * - `editFile()` changes a file, one edit at a time for each path.
9
9
  */
10
- export { writeFileAtomic } from "./atomic.js";
11
- export { healNdjsonTail } from "./ndjson-tail.js";
10
+ export { writeFileAtomic, writeFileAtomicSync } from "./atomic.js";
11
+ export { healNdjsonTail, healNdjsonTailSync, NDJSON_LINE_TOO_LONG, } from "./ndjson-tail.js";
12
12
  export { KeyedLock, withLock, } from "./lock.js";
13
13
  export { editFile } from "./edit.js";
14
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/files/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,eAAe,EAA+B,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,cAAc,EAA4E,MAAM,kBAAkB,CAAC;AAC5H,OAAO,EACL,SAAS,EACT,QAAQ,GAKT,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,QAAQ,EAAiE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/files/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAA+B,MAAM,aAAa,CAAC;AAChG,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,oBAAoB,GAIrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,SAAS,EACT,QAAQ,GAKT,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,QAAQ,EAAiE,MAAM,WAAW,CAAC"}
@@ -1,13 +1,13 @@
1
1
  /**
2
- * The repair of the end of an append-only NDJSON file after a crash (roadmap O51).
2
+ * The repair of the end of an append-only NDJSON file after a crash (roadmap O51 and O52).
3
3
  *
4
4
  * A crash during an append can leave a part of a line at the end of the file. The next append
5
5
  * then puts its line after that part, and the file has a bad line in its middle.
6
- * `healNdjsonTail()` repairs the end before the next append.
6
+ * `healNdjsonTail()` and `healNdjsonTailSync()` repair the end before the next append.
7
7
  */
8
8
  /** What `healNdjsonTail()` did: nothing, a cut of a partial last line, or a newline after a complete last record. */
9
9
  export type NdjsonTailAction = "none" | "truncated" | "newline";
10
- /** The result of `healNdjsonTail()`. */
10
+ /** The result of `healNdjsonTail()` and `healNdjsonTailSync()`. */
11
11
  export interface NdjsonTailResult {
12
12
  /** The change to the file. */
13
13
  readonly action: NdjsonTailAction;
@@ -15,17 +15,34 @@ export interface NdjsonTailResult {
15
15
  readonly bytes: number;
16
16
  /** The size of the file after the repair. It is 0 for a file that does not exist. */
17
17
  readonly size: number;
18
+ /**
19
+ * The last complete line after the repair, without its `\n` or `\r\n`, and without a byte order
20
+ * mark. It is `undefined` when the file has no complete line.
21
+ *
22
+ * The result has this field only with the option `lastLine: true`.
23
+ */
24
+ readonly lastLine?: string | undefined;
18
25
  }
19
- /** The options of `healNdjsonTail()`. */
26
+ /** The options of `healNdjsonTail()` and `healNdjsonTailSync()`. */
20
27
  export interface HealNdjsonTailOptions {
21
28
  /**
22
- * The maximum length in bytes of the last line. The function reads no more than this number of
23
- * bytes from the end. A longer last line is an error. The default is 16 MiB.
29
+ * The maximum length in bytes of the last line. The default is 16 MiB. `Infinity` turns the limit off.
30
+ *
31
+ * A longer last line is a `RangeError` with the code `ERR_NDJSON_LINE_TOO_LONG`, and the file
32
+ * does not change. The function keeps no more than this number of bytes in memory.
24
33
  */
25
34
  maxLineBytes?: number | undefined;
26
35
  /** With `false`, the function does not flush a change to the disk. The default is `true`. */
27
36
  fsync?: boolean | undefined;
37
+ /**
38
+ * With `true`, the result has `lastLine`, the last complete line after the repair. The default is `false`.
39
+ *
40
+ * The function then also reads the last line of a file that ends in a newline, up to `maxLineBytes`.
41
+ */
42
+ lastLine?: boolean | undefined;
28
43
  }
44
+ /** The code of the error of a last line that is longer than `maxLineBytes`. */
45
+ export declare const NDJSON_LINE_TOO_LONG = "ERR_NDJSON_LINE_TOO_LONG";
29
46
  /**
30
47
  * This function repairs the end of an append-only NDJSON file after a crash. Then the file ends in a newline, or it is empty.
31
48
  *
@@ -33,9 +50,18 @@ export interface HealNdjsonTailOptions {
33
50
  * - A last line that is not valid JSON is a part of a record. The function cuts it off with `ftruncate`.
34
51
  * - A last line that is valid JSON is a complete record without its newline. The function adds the newline.
35
52
  * - The function reads only the last line, from the end of the file. It does not read the whole file.
53
+ * - With `options.lastLine`, the result also gives the last complete line after the repair.
54
+ *
55
+ * A last line that is longer than `maxLineBytes` (16 MiB by default) is a `RangeError` with the code
56
+ * `ERR_NDJSON_LINE_TOO_LONG`. The file then does not change. Set `maxLineBytes: Infinity` for files with very long records.
36
57
  *
37
58
  * The records must be objects or arrays. A part of a number or of a literal can be valid JSON too.
38
59
  * The function does not lock the file. Start it before an append, in the same lock as the append.
39
60
  */
40
61
  export declare function healNdjsonTail(path: string, options?: HealNdjsonTailOptions): Promise<NdjsonTailResult>;
62
+ /**
63
+ * This function is the sync form of `healNdjsonTail()`. It makes the same repairs, with the same
64
+ * options, the same result and the same errors. It blocks the thread until the repair is complete.
65
+ */
66
+ export declare function healNdjsonTailSync(path: string, options?: HealNdjsonTailOptions): NdjsonTailResult;
41
67
  //# sourceMappingURL=ndjson-tail.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ndjson-tail.d.ts","sourceRoot":"","sources":["../../src/files/ndjson-tail.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,qHAAqH;AACrH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,WAAW,GAAG,SAAS,CAAC;AAEhE,wCAAwC;AACxC,MAAM,WAAW,gBAAgB;IAC/B,8BAA8B;IAC9B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,kFAAkF;IAClF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,qFAAqF;IACrF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,yCAAyC;AACzC,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,6FAA6F;IAC7F,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC7B;AAgCD;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAA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