atomically 2.0.0 → 2.0.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/constants.js CHANGED
@@ -1,5 +1,6 @@
1
1
  /* IMPORT */
2
2
  import os from 'node:os';
3
+ import process from 'node:process';
3
4
  /* MAIN */
4
5
  const DEFAULT_ENCODING = 'utf8';
5
6
  const DEFAULT_FILE_MODE = 0o666;
@@ -12,8 +13,8 @@ const DEFAULT_TIMEOUT_ASYNC = 7500;
12
13
  const DEFAULT_TIMEOUT_SYNC = 1000;
13
14
  const IS_POSIX = !!process.getuid;
14
15
  const IS_USER_ROOT = process.getuid ? !process.getuid() : false;
15
- const LIMIT_BASENAME_LENGTH = 128; //TODO: fetch the real limit from the filesystem //TODO: fetch the whole-path length limit too
16
- const LIMIT_FILES_DESCRIPTORS = 10000; //TODO: fetch the real limit from the filesystem
16
+ const LIMIT_BASENAME_LENGTH = 128; //TODO: Fetch the real limit from the filesystem //TODO: Fetch the whole-path length limit too
17
+ const LIMIT_FILES_DESCRIPTORS = 10000; //TODO: Fetch the real limit from the filesystem
17
18
  const NOOP = () => { };
18
19
  /* EXPORT */
19
20
  export { DEFAULT_ENCODING, DEFAULT_FILE_MODE, DEFAULT_FOLDER_MODE, DEFAULT_READ_OPTIONS, DEFAULT_WRITE_OPTIONS, DEFAULT_USER_UID, DEFAULT_USER_GID, DEFAULT_TIMEOUT_ASYNC, DEFAULT_TIMEOUT_SYNC, IS_POSIX, IS_USER_ROOT, LIMIT_BASENAME_LENGTH, LIMIT_FILES_DESCRIPTORS, NOOP };
package/dist/index.d.ts CHANGED
@@ -10,5 +10,5 @@ declare function readFileSync(filePath: Path, options: Encoding | ReadOptions &
10
10
  declare function readFileSync(filePath: Path, options?: ReadOptions): Buffer;
11
11
  declare function writeFile(filePath: Path, data: Data, callback?: Callback): Promise<void>;
12
12
  declare function writeFile(filePath: Path, data: Data, options?: Encoding | WriteOptions, callback?: Callback): Promise<void>;
13
- declare const writeFileSync: (filePath: Path, data: Data, options?: Encoding | WriteOptions) => void;
13
+ declare function writeFileSync(filePath: Path, data: Data, options?: Encoding | WriteOptions): void;
14
14
  export { readFile, readFileSync, writeFile, writeFileSync };
package/dist/index.js CHANGED
@@ -113,7 +113,7 @@ async function writeFileAsync(filePath, data, options = DEFAULT_WRITE_OPTIONS) {
113
113
  schedulerDisposer();
114
114
  }
115
115
  }
116
- const writeFileSync = (filePath, data, options = DEFAULT_WRITE_OPTIONS) => {
116
+ function writeFileSync(filePath, data, options = DEFAULT_WRITE_OPTIONS) {
117
117
  if (isString(options))
118
118
  return writeFileSync(filePath, data, { encoding: options });
119
119
  const timeout = Date.now() + ((options.timeout ?? DEFAULT_TIMEOUT_SYNC) || -1);
@@ -191,6 +191,6 @@ const writeFileSync = (filePath, data, options = DEFAULT_WRITE_OPTIONS) => {
191
191
  if (tempPath)
192
192
  Temp.purge(tempPath);
193
193
  }
194
- };
194
+ }
195
195
  /* EXPORT */
196
196
  export { readFile, readFileSync, writeFile, writeFileSync };
package/dist/types.d.ts CHANGED
@@ -1,16 +1,16 @@
1
1
  /// <reference types="node" />
2
- declare type Callback = (error: Exception | void) => void;
3
- declare type Data = Uint8Array | string | undefined;
4
- declare type Disposer = () => void;
5
- declare type Encoding = 'ascii' | 'base64' | 'binary' | 'hex' | 'latin1' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2';
6
- declare type Exception = NodeJS.ErrnoException;
7
- declare type Path = string;
8
- declare type ReadOptions = {
2
+ type Callback = (error: Exception | void) => void;
3
+ type Data = Uint8Array | string | undefined;
4
+ type Disposer = () => void;
5
+ type Encoding = 'ascii' | 'base64' | 'binary' | 'hex' | 'latin1' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2';
6
+ type Exception = NodeJS.ErrnoException;
7
+ type Path = string;
8
+ type ReadOptions = {
9
9
  encoding?: Encoding | null;
10
10
  mode?: string | number | false;
11
11
  timeout?: number;
12
12
  };
13
- declare type WriteOptions = {
13
+ type WriteOptions = {
14
14
  chown?: {
15
15
  gid: number;
16
16
  uid: number;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "atomically",
3
3
  "repository": "github:fabiospampinato/atomically",
4
4
  "description": "Read and write files atomically and reliably.",
5
- "version": "2.0.0",
5
+ "version": "2.0.1",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
8
8
  "exports": "./dist/index.js",
@@ -26,16 +26,16 @@
26
26
  "reliable"
27
27
  ],
28
28
  "dependencies": {
29
- "stubborn-fs": "^1.2.1",
29
+ "stubborn-fs": "^1.2.4",
30
30
  "when-exit": "^2.0.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@types/node": "^18.11.9",
34
- "esbuild": "^0.15.13",
33
+ "@types/node": "^18.13.0",
34
+ "esbuild": "^0.17.7",
35
35
  "require-inject": "^1.4.4",
36
- "tap": "^16.3.0",
37
- "tsex": "^1.1.2",
38
- "typescript": "^4.8.4",
36
+ "tap": "^16.3.4",
37
+ "tsex": "^2.1.0",
38
+ "typescript": "^4.9.5",
39
39
  "write-file-atomic": "^5.0.0"
40
40
  }
41
41
  }
File without changes
package/src/constants.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  /* IMPORT */
3
3
 
4
4
  import os from 'node:os';
5
+ import process from 'node:process';
5
6
 
6
7
  /* MAIN */
7
8
 
@@ -27,9 +28,9 @@ const IS_POSIX = !!process.getuid;
27
28
 
28
29
  const IS_USER_ROOT = process.getuid ? !process.getuid () : false;
29
30
 
30
- const LIMIT_BASENAME_LENGTH = 128; //TODO: fetch the real limit from the filesystem //TODO: fetch the whole-path length limit too
31
+ const LIMIT_BASENAME_LENGTH = 128; //TODO: Fetch the real limit from the filesystem //TODO: Fetch the whole-path length limit too
31
32
 
32
- const LIMIT_FILES_DESCRIPTORS = 10000; //TODO: fetch the real limit from the filesystem
33
+ const LIMIT_FILES_DESCRIPTORS = 10_000; //TODO: Fetch the real limit from the filesystem
33
34
 
34
35
  const NOOP = () => {};
35
36
 
package/src/index.ts CHANGED
@@ -192,7 +192,7 @@ async function writeFileAsync ( filePath: Path, data: Data, options: Encoding |
192
192
 
193
193
  }
194
194
 
195
- const writeFileSync = ( filePath: Path, data: Data, options: Encoding | WriteOptions = DEFAULT_WRITE_OPTIONS ): void => {
195
+ function writeFileSync ( filePath: Path, data: Data, options: Encoding | WriteOptions = DEFAULT_WRITE_OPTIONS ): void {
196
196
 
197
197
  if ( isString ( options ) ) return writeFileSync ( filePath, data, { encoding: options } );
198
198