@trenskow/atomic-write-stream 0.1.0 → 0.1.2
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/eslint.config.js +1 -0
- package/index.js +1 -1
- package/lib/index.js +4 -4
- package/package.json +2 -1
package/eslint.config.js
CHANGED
package/index.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//
|
|
2
2
|
// index.js
|
|
3
|
-
// @trenskow/
|
|
3
|
+
// @trenskow/atomic-write-stream
|
|
4
4
|
//
|
|
5
5
|
// Created by Kristian Trenskow on 2025/01/01
|
|
6
6
|
// See license in LICENSE.
|
|
@@ -11,9 +11,9 @@ import { rename, unlink, stat } from 'fs/promises';
|
|
|
11
11
|
import { tmpdir } from 'os';
|
|
12
12
|
import { basename } from 'path';
|
|
13
13
|
import { randomBytes } from 'crypto';
|
|
14
|
-
import {
|
|
14
|
+
import { PassThrough } from 'stream';
|
|
15
15
|
|
|
16
|
-
class AtomicStream extends
|
|
16
|
+
class AtomicStream extends PassThrough {
|
|
17
17
|
|
|
18
18
|
constructor(path, { tmpDirectory = tmpdir() } = {}) {
|
|
19
19
|
|
|
@@ -80,7 +80,7 @@ class AtomicStream extends Transform {
|
|
|
80
80
|
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
-
export default
|
|
83
|
+
export default (path, { tmpDirectory = tmpdir() } = {}) => {
|
|
84
84
|
|
|
85
85
|
const writeStream = createWriteStream(path);
|
|
86
86
|
const atomicStream = new AtomicStream(path, { tmpDirectory });
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trenskow/atomic-write-stream",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "A writeable file stream that writes atomically.",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
9
|
},
|