@alwatr/node-fs 5.5.33 → 6.0.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/dist/main.d.ts CHANGED
@@ -3,7 +3,9 @@ export * from './write-file.js';
3
3
  export * from './read-json.js';
4
4
  export * from './write-json.js';
5
5
  export * from './make-file.js';
6
- export { resolve } from 'node:path';
7
- export { existsSync } from 'node:fs';
8
- export { unlink } from 'node:fs/promises';
6
+ import { existsSync as existsSync_ } from 'node:fs';
7
+ import { unlink as unlink_ } from 'node:fs/promises';
8
+ export declare const resolve: (...paths: string[]) => string;
9
+ export declare const existsSync: typeof existsSync_;
10
+ export declare const unlink: typeof unlink_;
9
11
  //# sourceMappingURL=main.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAE/B,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,UAAU,EAAC,MAAM,SAAS,CAAC;AACnC,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAG/B,OAAO,EAAE,UAAU,IAAI,WAAW,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,MAAM,IAAI,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAErD,eAAO,MAAM,OAAO,gCAAW,CAAC;AAChC,eAAO,MAAM,UAAU,oBAAc,CAAC;AACtC,eAAO,MAAM,MAAM,gBAAU,CAAC"}
package/dist/main.js ADDED
@@ -0,0 +1,5 @@
1
+ /* 📦 @alwatr/node-fs v6.0.0 */
2
+ import{readFileSync as $}from"node:fs";import{readFile as C}from"node:fs/promises";import{flatString as K}from"@alwatr/flat-string";import{AsyncQueue as Y}from"@alwatr/async-queue";import{createLogger as Z}from"@alwatr/logger";var q=Z("@alwatr/node-fs"),B=new Y;function N(v){q.logMethodArgs?.("readFileSync","..."+v.slice(-32));try{return K($(v,{encoding:"utf-8",flag:"r"}))}catch(L){throw q.error("readFileSync","read_file_failed",{path:v},L),Error("read_file_failed",{cause:L.cause})}}function O(v){return q.logMethodArgs?.("readFile","..."+v.slice(-32)),B.push(v,async()=>{try{return K(await C(v,{encoding:"utf-8",flag:"r"}))}catch(L){throw q.error("readFile","read_file_failed",{path:v},L),Error("read_file_failed",{cause:L.cause})}})}import{writeFileSync as H,existsSync as D,mkdirSync as M,renameSync as P}from"node:fs";import{mkdir as W,rename as Q,writeFile as u}from"node:fs/promises";import{dirname as R}from"node:path";function T(v,L){q.logMethodArgs?.("writeFileSync","..."+v.slice(-32));try{let z=D(v);if(!z){let A=R(v);if(!D(A))M(A,{recursive:!0})}if(H(v+".tmp",L,{encoding:"utf-8",flag:"w"}),z)P(v,v+".bak");P(v+".tmp",v),q.logOther?.("writeFileSync success","..."+v.slice(-32))}catch(z){throw q.error("writeFileSync","write_file_failed",{path:v},z),Error("write_file_failed",{cause:z.cause})}}function U(v,L){return q.logMethodArgs?.("writeFile","..."+v.slice(-32)),B.push(v,async()=>{try{q.logOther?.("writeFile start","..."+v.slice(-32));let z=D(v);if(!z){let A=R(v);if(!D(A))await W(A,{recursive:!0})}if(await u(v+".tmp",L,{encoding:"utf-8",flag:"w"}),z)await Q(v,v+".bak");await Q(v+".tmp",v),q.logOther?.("writeFile success","..."+v.slice(-32))}catch(z){throw q.error("writeFile","write_file_failed",{path:v},z),Error("write_file_failed",{cause:z.cause})}})}function G(v){try{return JSON.parse(v)}catch(L){throw q.error("parseJson","invalid_json",L),Error("invalid_json",{cause:L.cause})}}function V(v){try{return JSON.stringify(v)}catch(L){throw q.error("jsonStringify","stringify_failed",L),Error("stringify_failed",{cause:L.cause})}}function e(v,L=!1){if(q.logMethodArgs?.("readJson",{path:v.slice(-32),sync:L}),L===!0)return G(N(v));else return O(v).then((z)=>G(z))}import{flatString as I}from"@alwatr/flat-string";function zv(v,L,z=!1){q.logMethodArgs?.("writeJson","..."+v.slice(-32));let A=I(V(L));return z===!0?T(v,A):U(v,A)}import{existsSync as X}from"node:fs";import{mkdir as _,open as k}from"node:fs/promises";import{dirname as J}from"node:path";async function Nv(v){q.logMethodArgs?.("makeEmptyFile","..."+v.slice(-32));try{if(!X(v)){let z=J(v);if(!X(z))await _(z,{recursive:!0})}await(await k(v,"w")).close()}catch(L){throw q.error("makeEmptyFile","make_file_failed",{path:v},L),Error("make_file_failed",{cause:L.cause})}}import{resolve as x}from"node:path";import{existsSync as E}from"node:fs";import{unlink as b}from"node:fs/promises";var Tv=x,Uv=E,Vv=b;export{zv as writeJson,T as writeFileSync,U as writeFile,Vv as unlink,Tv as resolve,e as readJson,N as readFileSync,O as readFile,Nv as makeEmptyFile,Uv as existsSync};
3
+
4
+ //# debugId=38FEC37F6E415E9364756E2164756E21
5
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1,17 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/read-file.ts", "../src/common.ts", "../src/write-file.ts", "../src/json.ts", "../src/read-json.ts", "../src/write-json.ts", "../src/make-file.ts", "../src/main.ts"],
4
+ "sourcesContent": [
5
+ "import {readFileSync as readFileSync_} from 'node:fs';\nimport {readFile as readFile_} from 'node:fs/promises';\n\nimport {flatString} from '@alwatr/flat-string';\n\nimport {asyncQueue, logger} from './common.js';\n\n/**\n * Enhanced read File (Synchronous).\n *\n * @param path - file path\n * @returns file content\n * @example\n * ```typescript\n * const fileContent = readFileSync('./file.txt', sync);\n * ```\n */\nexport function readFileSync(path: string): string {\n logger.logMethodArgs?.('readFileSync', '...' + path.slice(-32));\n // if (!existsSync(path)) throw new Error('file_not_found');\n try {\n return flatString(readFileSync_(path, {encoding: 'utf-8', flag: 'r'}));\n }\n catch (err) {\n logger.error('readFileSync', 'read_file_failed', {path}, err);\n throw new Error('read_file_failed', {cause: (err as Error).cause});\n }\n}\n\n/**\n * Enhanced read File (Asynchronous).\n *\n * - If writing queue is running for target path, it will wait for it to finish.\n *\n * @param path - file path\n * @returns file content\n * @example\n * ```typescript\n * const fileContent = await readFile('./file.txt', sync);\n * ```\n */\nexport function readFile(path: string): Promise<string> {\n logger.logMethodArgs?.('readFile', '...' + path.slice(-32));\n // if (!existsSync(path)) throw new Error('file_not_found');\n return asyncQueue.push(path, async () => {\n try {\n return flatString(await readFile_(path, {encoding: 'utf-8', flag: 'r'}));\n }\n catch (err) {\n logger.error('readFile', 'read_file_failed', {path}, err);\n throw new Error('read_file_failed', {cause: (err as Error).cause});\n }\n });\n}\n",
6
+ "import {AsyncQueue} from '@alwatr/async-queue';\nimport {createLogger} from '@alwatr/logger';\n\nimport type {} from '@alwatr/type-helper';\n\nexport const logger = createLogger('@alwatr/node-fs');\n\nexport const asyncQueue = new AsyncQueue();\n",
7
+ "import {writeFileSync as writeFileSync_, existsSync, mkdirSync, renameSync} from 'node:fs';\nimport {mkdir, rename, writeFile as writeFile_} from 'node:fs/promises';\nimport {dirname} from 'node:path';\n\nimport {asyncQueue, logger} from './common.js';\n\n/**\n * Enhanced write file (Synchronous).\n *\n * - If directory not exists, create it recursively.\n * - Write file to `path.tmp` before write success.\n * - If file exists, renamed (keep) to `path.bak`.\n * - If write failed, original file will not be changed.\n *\n * @param path - file path\n * @param content - file content\n * @example\n * ```typescript\n * writeFileSync('./file.txt', 'Hello World!');\n * ```\n */\nexport function writeFileSync(path: string, content: Buffer | string): void {\n logger.logMethodArgs?.('writeFileSync', '...' + path.slice(-32));\n try {\n const pathExists = existsSync(path);\n if (!pathExists) {\n const dir = dirname(path);\n if (!existsSync(dir)) {\n mkdirSync(dir, {recursive: true});\n }\n }\n writeFileSync_(path + '.tmp', content, {encoding: 'utf-8', flag: 'w'});\n if (pathExists) {\n renameSync(path, path + '.bak');\n }\n renameSync(path + '.tmp', path);\n logger.logOther?.('writeFileSync success', '...' + path.slice(-32));\n }\n catch (err) {\n logger.error('writeFileSync', 'write_file_failed', {path}, err);\n throw new Error('write_file_failed', {cause: (err as Error).cause});\n }\n}\n\n/**\n * Enhanced write file (Asynchronous).\n *\n * - If directory not exists, create it recursively.\n * - Write file to `path.tmp` before write success.\n * - If file exists, renamed (keep) to `path.bak`.\n * - If write failed, original file will not be changed.\n *\n * @param path - file path\n * @param content - file content\n * @example\n * ```typescript\n * await writeFile('./file.txt', 'Hello World!');\n * ```\n */\nexport function writeFile(path: string, content: Buffer | string): Promise<void> {\n logger.logMethodArgs?.('writeFile', '...' + path.slice(-32));\n return asyncQueue.push(path, async () => {\n try {\n logger.logOther?.('writeFile start', '...' + path.slice(-32));\n const pathExists = existsSync(path);\n if (!pathExists) {\n const dir = dirname(path);\n if (!existsSync(dir)) {\n await mkdir(dir, {recursive: true});\n }\n }\n await writeFile_(path + '.tmp', content, {encoding: 'utf-8', flag: 'w'});\n if (pathExists) {\n await rename(path, path + '.bak');\n }\n await rename(path + '.tmp', path);\n logger.logOther?.('writeFile success', '...' + path.slice(-32));\n }\n catch (err) {\n logger.error('writeFile', 'write_file_failed', {path}, err);\n throw new Error('write_file_failed', {cause: (err as Error).cause});\n }\n });\n}\n",
8
+ "import {logger} from './common.js';\n\n/**\n * Parse json string.\n *\n * @param content - json string\n * @returns json object\n * @example\n * ```typescript\n * const json = parseJson('{\"a\":1,\"b\":2}');\n * console.log(json.a); // 1\n * ```\n */\nexport function parseJson<T extends JsonValue>(content: string): T {\n try {\n return JSON.parse(content);\n }\n catch (err) {\n logger.error('parseJson', 'invalid_json', err);\n throw new Error('invalid_json', {cause: (err as Error).cause});\n }\n}\n\n/**\n * Stringify json object.\n *\n * @param data - json object\n * @returns json string\n * @example\n * ```typescript\n * const json = jsonStringify({a:1, b:2});\n * console.log(json); // '{\"a\":1,\"b\":2}'\n * ```\n */\nexport function jsonStringify<T extends JsonValue>(data: T): string {\n try {\n return JSON.stringify(data);\n }\n catch (err) {\n logger.error('jsonStringify', 'stringify_failed', err);\n throw new Error('stringify_failed', {cause: (err as Error).cause});\n }\n}\n",
9
+ "import {logger} from './common.js';\nimport {parseJson} from './json.js';\nimport {readFile, readFileSync} from './read-file.js';\n\n/**\n * Enhanced read json file (async).\n *\n * @param path - file path\n * @returns json object\n * @example\n * ```typescript\n * const fileContent = await readJson('./file.json');\n * ```\n */\nexport function readJson<T extends JsonValue>(path: string): Promise<T>;\n/**\n * Enhanced read json file (sync).\n *\n * @param path - file path\n * @param sync - sync mode\n * @returns json object\n * @example\n * ```typescript\n * const fileContent = readJson('./file.json', true);\n * ```\n */\nexport function readJson<T extends JsonValue>(path: string, sync: true): T;\n/**\n * Enhanced read json file.\n *\n * @param path - file path\n * @param sync - sync mode\n * @returns json object\n * @example\n * ```typescript\n * const fileContent = await readJson('./file.json', sync);\n * ```\n */\nexport function readJson<T extends JsonValue>(path: string, sync: boolean): Awaitable<T>;\n/**\n * Enhanced read json file.\n *\n * @param path - file path\n * @param sync - sync mode\n * @returns json object\n * @example\n * ```typescript\n * const fileContent = await readJson('./file.json');\n * ```\n */\nexport function readJson<T extends JsonValue>(path: string, sync = false): Awaitable<T> {\n logger.logMethodArgs?.('readJson', {path: path.slice(-32), sync});\n if (sync === true) {\n return parseJson<T>(readFileSync(path));\n }\n else {\n return readFile(path).then((content) => parseJson<T>(content));\n }\n}\n",
10
+ "import {flatString} from '@alwatr/flat-string';\n\nimport {logger} from './common.js';\nimport {jsonStringify} from './json.js';\nimport {writeFile, writeFileSync} from './write-file.js';\n\n/**\n * Enhanced write json file (Asynchronous).\n *\n * @param path - file path\n * @param data - json object\n * @example\n * ```typescript\n * await writeJsonFile('./file.json', { a:1, b:2, c:3 });\n * ```\n */\nexport function writeJson<T extends JsonValue>(path: string, data: T, sync?: false): Promise<void>;\n/**\n * Enhanced write json file (Synchronous).\n *\n * @param path - file path\n * @param data - json object\n * @param sync - sync mode\n * @example\n * ```typescript\n * writeJsonFile('./file.json', { a:1, b:2, c:3 }, true);\n * ```\n */\nexport function writeJson<T extends JsonValue>(path: string, data: T, sync: true): void;\n/**\n * Enhanced write json file.\n *\n * @param path - file path\n * @param data - json object\n * @param sync - sync mode\n * @example\n * ```typescript\n * await writeJsonFile('./file.json', { a:1, b:2, c:3 }, sync);\n * ```\n */\nexport function writeJson<T extends JsonValue>(path: string, data: T, sync: boolean): Awaitable<void>;\n/**\n * Enhanced write json file.\n *\n * @param path - file path\n * @param data - json object\n * @param sync - sync mode\n * @example\n * ```typescript\n * await writeJsonFile('./file.json', { a:1, b:2, c:3 });\n * ```\n */\nexport function writeJson<T extends JsonValue>(path: string, data: T, sync = false): Awaitable<void> {\n logger.logMethodArgs?.('writeJson', '...' + path.slice(-32));\n const content = flatString(jsonStringify(data));\n return sync === true ? writeFileSync(path, content) : writeFile(path, content);\n}\n",
11
+ "import {existsSync} from 'node:fs';\nimport {mkdir, open} from 'node:fs/promises';\nimport {dirname} from 'node:path';\n\nimport {logger} from './common.js';\n\n/**\n * Make empty file.\n *\n * @param path - file path\n *\n * @example\n * ```ts\n * await makeFile('./dir/file.txt');\n * ```\n */\nexport async function makeEmptyFile(path: string): Promise<void> {\n logger.logMethodArgs?.('makeEmptyFile', '...' + path.slice(-32));\n try {\n const pathExists = existsSync(path);\n if (!pathExists) {\n const dir = dirname(path);\n if (!existsSync(dir)) {\n await mkdir(dir, {recursive: true});\n }\n }\n await (await open(path, 'w')).close();\n }\n catch (err) {\n logger.error('makeEmptyFile', 'make_file_failed', {path}, err);\n throw new Error('make_file_failed', {cause: (err as Error).cause});\n }\n}\n",
12
+ "export * from './read-file.js';\nexport * from './write-file.js';\nexport * from './read-json.js';\nexport * from './write-json.js';\nexport * from './make-file.js';\n\nimport { resolve as resolve_ } from 'node:path';\nimport { existsSync as existsSync_ } from 'node:fs';\nimport { unlink as unlink_ } from 'node:fs/promises';\n\nexport const resolve = resolve_;\nexport const existsSync = existsSync_;\nexport const unlink = unlink_;"
13
+ ],
14
+ "mappings": ";AAAA,uBAAQ,gBACR,mBAAQ,yBAER,qBAAQ,4BCHR,qBAAQ,4BACR,uBAAQ,uBAID,IAAM,EAAS,EAAa,iBAAiB,EAEvC,EAAa,IAAI,EDUvB,SAAS,CAAY,CAAC,EAAsB,CACjD,EAAO,gBAAgB,eAAgB,MAAQ,EAAK,MAAM,GAAG,CAAC,EAE9D,GAAI,CACF,OAAO,EAAW,EAAc,EAAM,CAAC,SAAU,QAAS,KAAM,GAAG,CAAC,CAAC,EAEvE,MAAO,EAAK,CAEV,MADA,EAAO,MAAM,eAAgB,mBAAoB,CAAC,MAAI,EAAG,CAAG,EAClD,MAAM,mBAAoB,CAAC,MAAQ,EAAc,KAAK,CAAC,GAgB9D,SAAS,CAAQ,CAAC,EAA+B,CAGtD,OAFA,EAAO,gBAAgB,WAAY,MAAQ,EAAK,MAAM,GAAG,CAAC,EAEnD,EAAW,KAAK,EAAM,SAAY,CACvC,GAAI,CACF,OAAO,EAAW,MAAM,EAAU,EAAM,CAAC,SAAU,QAAS,KAAM,GAAG,CAAC,CAAC,EAEzE,MAAO,EAAK,CAEV,MADA,EAAO,MAAM,WAAY,mBAAoB,CAAC,MAAI,EAAG,CAAG,EAC9C,MAAM,mBAAoB,CAAC,MAAQ,EAAc,KAAK,CAAC,GAEpE,EEpDH,wBAAQ,gBAAiC,eAAY,gBAAW,gBAChE,gBAAQ,YAAO,eAAQ,yBACvB,kBAAQ,kBAmBD,SAAS,CAAa,CAAC,EAAc,EAAgC,CAC1E,EAAO,gBAAgB,gBAAiB,MAAQ,EAAK,MAAM,GAAG,CAAC,EAC/D,GAAI,CACF,IAAM,EAAa,EAAW,CAAI,EAClC,GAAI,CAAC,EAAY,CACf,IAAM,EAAM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Q,EAAc,KAAK,CAAC,GCxBrE,kBAAS,kBACT,qBAAS,gBACT,iBAAS,yBAEF,IAAM,GAAU,EACV,GAAa,EACb,GAAS",
15
+ "debugId": "38FEC37F6E415E9364756E2164756E21",
16
+ "names": []
17
+ }
package/package.json CHANGED
@@ -1,31 +1,31 @@
1
1
  {
2
2
  "name": "@alwatr/node-fs",
3
3
  "description": "Enhanced file system operations in Node.js with asynchronous queue to prevent parallel writes.",
4
- "version": "5.5.33",
4
+ "version": "6.0.0",
5
5
  "author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
6
6
  "bugs": "https://github.com/Alwatr/nanolib/issues",
7
7
  "dependencies": {
8
- "@alwatr/async-queue": "5.5.30",
9
- "@alwatr/flat-string": "5.5.29",
10
- "@alwatr/logger": "6.0.18"
8
+ "@alwatr/async-queue": "6.0.0",
9
+ "@alwatr/flat-string": "6.0.0",
10
+ "@alwatr/logger": "7.0.0"
11
11
  },
12
12
  "devDependencies": {
13
- "@alwatr/nano-build": "6.4.2",
14
- "@alwatr/prettier-config": "6.0.2",
15
- "@alwatr/tsconfig-base": "6.0.4",
16
- "@alwatr/type-helper": "7.0.2",
13
+ "@alwatr/nano-build": "7.0.0",
14
+ "@alwatr/prettier-config": "7.0.0",
15
+ "@alwatr/tsconfig-base": "7.0.0",
16
+ "@alwatr/type-helper": "8.0.0",
17
17
  "@types/node": "^24.12.0",
18
18
  "typescript": "^5.9.3"
19
19
  },
20
20
  "exports": {
21
21
  ".": {
22
22
  "types": "./dist/main.d.ts",
23
- "import": "./dist/main.mjs",
24
- "require": "./dist/main.cjs"
23
+ "default": "./dist/main.js"
25
24
  }
26
25
  },
27
26
  "files": [
28
- "**/*.{js,mjs,cjs,map,d.ts,html,md,LEGAL.txt}",
27
+ "**/*.{js,mjs,cjs,ts,map,d.ts,html,LEGAL.txt}",
28
+ "README.md",
29
29
  "LICENSE",
30
30
  "!demo/**/*",
31
31
  "!**/*.test.js"
@@ -58,8 +58,6 @@
58
58
  "writeJson"
59
59
  ],
60
60
  "license": "MPL-2.0",
61
- "main": "./dist/main.cjs",
62
- "module": "./dist/main.mjs",
63
61
  "prettier": "@alwatr/prettier-config",
64
62
  "publishConfig": {
65
63
  "access": "public"
@@ -72,12 +70,12 @@
72
70
  "scripts": {
73
71
  "b": "bun run build",
74
72
  "build": "bun run build:ts && bun run build:es",
75
- "build:es": "nano-build --preset=module",
73
+ "build:es": "nano-build --preset=module src/main.ts",
76
74
  "build:ts": "tsc --build",
77
75
  "c": "bun run clean",
78
76
  "cb": "bun run clean && bun run build",
79
77
  "clean": "rm -rfv dist *.tsbuildinfo",
80
- "d": "bun run build:es && bun --enable-source-maps --trace-warnings",
78
+ "d": "bun run build:es && bun",
81
79
  "w": "bun run watch",
82
80
  "watch": "bun run watch:ts & bun run watch:es",
83
81
  "watch:es": "bun run build:es --watch",
@@ -86,5 +84,5 @@
86
84
  "sideEffects": false,
87
85
  "type": "module",
88
86
  "types": "./dist/main.d.ts",
89
- "gitHead": "def1decf8f496f4b0d3d3ab952c346c689c30160"
87
+ "gitHead": "056102a1c8a563bbae8a290b6830450f467322a3"
90
88
  }
package/src/common.ts ADDED
@@ -0,0 +1,8 @@
1
+ import {AsyncQueue} from '@alwatr/async-queue';
2
+ import {createLogger} from '@alwatr/logger';
3
+
4
+ import type {} from '@alwatr/type-helper';
5
+
6
+ export const logger = createLogger('@alwatr/node-fs');
7
+
8
+ export const asyncQueue = new AsyncQueue();
package/src/json.ts ADDED
@@ -0,0 +1,43 @@
1
+ import {logger} from './common.js';
2
+
3
+ /**
4
+ * Parse json string.
5
+ *
6
+ * @param content - json string
7
+ * @returns json object
8
+ * @example
9
+ * ```typescript
10
+ * const json = parseJson('{"a":1,"b":2}');
11
+ * console.log(json.a); // 1
12
+ * ```
13
+ */
14
+ export function parseJson<T extends JsonValue>(content: string): T {
15
+ try {
16
+ return JSON.parse(content);
17
+ }
18
+ catch (err) {
19
+ logger.error('parseJson', 'invalid_json', err);
20
+ throw new Error('invalid_json', {cause: (err as Error).cause});
21
+ }
22
+ }
23
+
24
+ /**
25
+ * Stringify json object.
26
+ *
27
+ * @param data - json object
28
+ * @returns json string
29
+ * @example
30
+ * ```typescript
31
+ * const json = jsonStringify({a:1, b:2});
32
+ * console.log(json); // '{"a":1,"b":2}'
33
+ * ```
34
+ */
35
+ export function jsonStringify<T extends JsonValue>(data: T): string {
36
+ try {
37
+ return JSON.stringify(data);
38
+ }
39
+ catch (err) {
40
+ logger.error('jsonStringify', 'stringify_failed', err);
41
+ throw new Error('stringify_failed', {cause: (err as Error).cause});
42
+ }
43
+ }
package/src/main.ts ADDED
@@ -0,0 +1,13 @@
1
+ export * from './read-file.js';
2
+ export * from './write-file.js';
3
+ export * from './read-json.js';
4
+ export * from './write-json.js';
5
+ export * from './make-file.js';
6
+
7
+ import { resolve as resolve_ } from 'node:path';
8
+ import { existsSync as existsSync_ } from 'node:fs';
9
+ import { unlink as unlink_ } from 'node:fs/promises';
10
+
11
+ export const resolve = resolve_;
12
+ export const existsSync = existsSync_;
13
+ export const unlink = unlink_;
@@ -0,0 +1,33 @@
1
+ import {existsSync} from 'node:fs';
2
+ import {mkdir, open} from 'node:fs/promises';
3
+ import {dirname} from 'node:path';
4
+
5
+ import {logger} from './common.js';
6
+
7
+ /**
8
+ * Make empty file.
9
+ *
10
+ * @param path - file path
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * await makeFile('./dir/file.txt');
15
+ * ```
16
+ */
17
+ export async function makeEmptyFile(path: string): Promise<void> {
18
+ logger.logMethodArgs?.('makeEmptyFile', '...' + path.slice(-32));
19
+ try {
20
+ const pathExists = existsSync(path);
21
+ if (!pathExists) {
22
+ const dir = dirname(path);
23
+ if (!existsSync(dir)) {
24
+ await mkdir(dir, {recursive: true});
25
+ }
26
+ }
27
+ await (await open(path, 'w')).close();
28
+ }
29
+ catch (err) {
30
+ logger.error('makeEmptyFile', 'make_file_failed', {path}, err);
31
+ throw new Error('make_file_failed', {cause: (err as Error).cause});
32
+ }
33
+ }
@@ -0,0 +1,54 @@
1
+ import {readFileSync as readFileSync_} from 'node:fs';
2
+ import {readFile as readFile_} from 'node:fs/promises';
3
+
4
+ import {flatString} from '@alwatr/flat-string';
5
+
6
+ import {asyncQueue, logger} from './common.js';
7
+
8
+ /**
9
+ * Enhanced read File (Synchronous).
10
+ *
11
+ * @param path - file path
12
+ * @returns file content
13
+ * @example
14
+ * ```typescript
15
+ * const fileContent = readFileSync('./file.txt', sync);
16
+ * ```
17
+ */
18
+ export function readFileSync(path: string): string {
19
+ logger.logMethodArgs?.('readFileSync', '...' + path.slice(-32));
20
+ // if (!existsSync(path)) throw new Error('file_not_found');
21
+ try {
22
+ return flatString(readFileSync_(path, {encoding: 'utf-8', flag: 'r'}));
23
+ }
24
+ catch (err) {
25
+ logger.error('readFileSync', 'read_file_failed', {path}, err);
26
+ throw new Error('read_file_failed', {cause: (err as Error).cause});
27
+ }
28
+ }
29
+
30
+ /**
31
+ * Enhanced read File (Asynchronous).
32
+ *
33
+ * - If writing queue is running for target path, it will wait for it to finish.
34
+ *
35
+ * @param path - file path
36
+ * @returns file content
37
+ * @example
38
+ * ```typescript
39
+ * const fileContent = await readFile('./file.txt', sync);
40
+ * ```
41
+ */
42
+ export function readFile(path: string): Promise<string> {
43
+ logger.logMethodArgs?.('readFile', '...' + path.slice(-32));
44
+ // if (!existsSync(path)) throw new Error('file_not_found');
45
+ return asyncQueue.push(path, async () => {
46
+ try {
47
+ return flatString(await readFile_(path, {encoding: 'utf-8', flag: 'r'}));
48
+ }
49
+ catch (err) {
50
+ logger.error('readFile', 'read_file_failed', {path}, err);
51
+ throw new Error('read_file_failed', {cause: (err as Error).cause});
52
+ }
53
+ });
54
+ }
@@ -0,0 +1,59 @@
1
+ import {logger} from './common.js';
2
+ import {parseJson} from './json.js';
3
+ import {readFile, readFileSync} from './read-file.js';
4
+
5
+ /**
6
+ * Enhanced read json file (async).
7
+ *
8
+ * @param path - file path
9
+ * @returns json object
10
+ * @example
11
+ * ```typescript
12
+ * const fileContent = await readJson('./file.json');
13
+ * ```
14
+ */
15
+ export function readJson<T extends JsonValue>(path: string): Promise<T>;
16
+ /**
17
+ * Enhanced read json file (sync).
18
+ *
19
+ * @param path - file path
20
+ * @param sync - sync mode
21
+ * @returns json object
22
+ * @example
23
+ * ```typescript
24
+ * const fileContent = readJson('./file.json', true);
25
+ * ```
26
+ */
27
+ export function readJson<T extends JsonValue>(path: string, sync: true): T;
28
+ /**
29
+ * Enhanced read json file.
30
+ *
31
+ * @param path - file path
32
+ * @param sync - sync mode
33
+ * @returns json object
34
+ * @example
35
+ * ```typescript
36
+ * const fileContent = await readJson('./file.json', sync);
37
+ * ```
38
+ */
39
+ export function readJson<T extends JsonValue>(path: string, sync: boolean): Awaitable<T>;
40
+ /**
41
+ * Enhanced read json file.
42
+ *
43
+ * @param path - file path
44
+ * @param sync - sync mode
45
+ * @returns json object
46
+ * @example
47
+ * ```typescript
48
+ * const fileContent = await readJson('./file.json');
49
+ * ```
50
+ */
51
+ export function readJson<T extends JsonValue>(path: string, sync = false): Awaitable<T> {
52
+ logger.logMethodArgs?.('readJson', {path: path.slice(-32), sync});
53
+ if (sync === true) {
54
+ return parseJson<T>(readFileSync(path));
55
+ }
56
+ else {
57
+ return readFile(path).then((content) => parseJson<T>(content));
58
+ }
59
+ }
@@ -0,0 +1,84 @@
1
+ import {writeFileSync as writeFileSync_, existsSync, mkdirSync, renameSync} from 'node:fs';
2
+ import {mkdir, rename, writeFile as writeFile_} from 'node:fs/promises';
3
+ import {dirname} from 'node:path';
4
+
5
+ import {asyncQueue, logger} from './common.js';
6
+
7
+ /**
8
+ * Enhanced write file (Synchronous).
9
+ *
10
+ * - If directory not exists, create it recursively.
11
+ * - Write file to `path.tmp` before write success.
12
+ * - If file exists, renamed (keep) to `path.bak`.
13
+ * - If write failed, original file will not be changed.
14
+ *
15
+ * @param path - file path
16
+ * @param content - file content
17
+ * @example
18
+ * ```typescript
19
+ * writeFileSync('./file.txt', 'Hello World!');
20
+ * ```
21
+ */
22
+ export function writeFileSync(path: string, content: Buffer | string): void {
23
+ logger.logMethodArgs?.('writeFileSync', '...' + path.slice(-32));
24
+ try {
25
+ const pathExists = existsSync(path);
26
+ if (!pathExists) {
27
+ const dir = dirname(path);
28
+ if (!existsSync(dir)) {
29
+ mkdirSync(dir, {recursive: true});
30
+ }
31
+ }
32
+ writeFileSync_(path + '.tmp', content, {encoding: 'utf-8', flag: 'w'});
33
+ if (pathExists) {
34
+ renameSync(path, path + '.bak');
35
+ }
36
+ renameSync(path + '.tmp', path);
37
+ logger.logOther?.('writeFileSync success', '...' + path.slice(-32));
38
+ }
39
+ catch (err) {
40
+ logger.error('writeFileSync', 'write_file_failed', {path}, err);
41
+ throw new Error('write_file_failed', {cause: (err as Error).cause});
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Enhanced write file (Asynchronous).
47
+ *
48
+ * - If directory not exists, create it recursively.
49
+ * - Write file to `path.tmp` before write success.
50
+ * - If file exists, renamed (keep) to `path.bak`.
51
+ * - If write failed, original file will not be changed.
52
+ *
53
+ * @param path - file path
54
+ * @param content - file content
55
+ * @example
56
+ * ```typescript
57
+ * await writeFile('./file.txt', 'Hello World!');
58
+ * ```
59
+ */
60
+ export function writeFile(path: string, content: Buffer | string): Promise<void> {
61
+ logger.logMethodArgs?.('writeFile', '...' + path.slice(-32));
62
+ return asyncQueue.push(path, async () => {
63
+ try {
64
+ logger.logOther?.('writeFile start', '...' + path.slice(-32));
65
+ const pathExists = existsSync(path);
66
+ if (!pathExists) {
67
+ const dir = dirname(path);
68
+ if (!existsSync(dir)) {
69
+ await mkdir(dir, {recursive: true});
70
+ }
71
+ }
72
+ await writeFile_(path + '.tmp', content, {encoding: 'utf-8', flag: 'w'});
73
+ if (pathExists) {
74
+ await rename(path, path + '.bak');
75
+ }
76
+ await rename(path + '.tmp', path);
77
+ logger.logOther?.('writeFile success', '...' + path.slice(-32));
78
+ }
79
+ catch (err) {
80
+ logger.error('writeFile', 'write_file_failed', {path}, err);
81
+ throw new Error('write_file_failed', {cause: (err as Error).cause});
82
+ }
83
+ });
84
+ }
@@ -0,0 +1,57 @@
1
+ import {flatString} from '@alwatr/flat-string';
2
+
3
+ import {logger} from './common.js';
4
+ import {jsonStringify} from './json.js';
5
+ import {writeFile, writeFileSync} from './write-file.js';
6
+
7
+ /**
8
+ * Enhanced write json file (Asynchronous).
9
+ *
10
+ * @param path - file path
11
+ * @param data - json object
12
+ * @example
13
+ * ```typescript
14
+ * await writeJsonFile('./file.json', { a:1, b:2, c:3 });
15
+ * ```
16
+ */
17
+ export function writeJson<T extends JsonValue>(path: string, data: T, sync?: false): Promise<void>;
18
+ /**
19
+ * Enhanced write json file (Synchronous).
20
+ *
21
+ * @param path - file path
22
+ * @param data - json object
23
+ * @param sync - sync mode
24
+ * @example
25
+ * ```typescript
26
+ * writeJsonFile('./file.json', { a:1, b:2, c:3 }, true);
27
+ * ```
28
+ */
29
+ export function writeJson<T extends JsonValue>(path: string, data: T, sync: true): void;
30
+ /**
31
+ * Enhanced write json file.
32
+ *
33
+ * @param path - file path
34
+ * @param data - json object
35
+ * @param sync - sync mode
36
+ * @example
37
+ * ```typescript
38
+ * await writeJsonFile('./file.json', { a:1, b:2, c:3 }, sync);
39
+ * ```
40
+ */
41
+ export function writeJson<T extends JsonValue>(path: string, data: T, sync: boolean): Awaitable<void>;
42
+ /**
43
+ * Enhanced write json file.
44
+ *
45
+ * @param path - file path
46
+ * @param data - json object
47
+ * @param sync - sync mode
48
+ * @example
49
+ * ```typescript
50
+ * await writeJsonFile('./file.json', { a:1, b:2, c:3 });
51
+ * ```
52
+ */
53
+ export function writeJson<T extends JsonValue>(path: string, data: T, sync = false): Awaitable<void> {
54
+ logger.logMethodArgs?.('writeJson', '...' + path.slice(-32));
55
+ const content = flatString(jsonStringify(data));
56
+ return sync === true ? writeFileSync(path, content) : writeFile(path, content);
57
+ }
package/CHANGELOG.md DELETED
@@ -1,504 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [5.5.33](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.32...@alwatr/node-fs@5.5.33) (2026-03-18)
7
-
8
- **Note:** Version bump only for package @alwatr/node-fs
9
-
10
- ## [5.5.32](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.31...@alwatr/node-fs@5.5.32) (2026-03-16)
11
-
12
- ### 🔨 Code Refactoring
13
-
14
- * migrate build scripts from yarn to bun across multiple packages ([d90e962](https://github.com/Alwatr/nanolib/commit/d90e962f15e5c951e191d5f02341279b6472abc3))
15
-
16
- ### 🔗 Dependencies update
17
-
18
- * bump the npm-dependencies group with 10 updates ([c48d9ba](https://github.com/Alwatr/nanolib/commit/c48d9baa1cd7c2dc144b3e01e0fda60bf87c074c))
19
-
20
- ## [5.5.31](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.30...@alwatr/node-fs@5.5.31) (2026-02-18)
21
-
22
- ### 🔗 Dependencies update
23
-
24
- * update @types/node to version 24.10.13 across multiple packages ([4c6d2a3](https://github.com/Alwatr/nanolib/commit/4c6d2a37ab26b1c86812b2aa38b2eca4ee097cb6))
25
-
26
- ## [5.5.30](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.29...@alwatr/node-fs@5.5.30) (2025-12-23)
27
-
28
- ### 🔗 Dependencies update
29
-
30
- * upgrade @types/node to version 24.10.4 and update related dependencies ([acf04df](https://github.com/Alwatr/nanolib/commit/acf04df71647f5a401ef5e6bbfffcc478e4326d2))
31
-
32
- ## [5.5.29](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.28...@alwatr/node-fs@5.5.29) (2025-12-13)
33
-
34
- ### 🔗 Dependencies update
35
-
36
- * update `@types/node` and `[@lerna-lite](https://github.com/lerna-lite)` dependencies. ([8daa8fd](https://github.com/Alwatr/nanolib/commit/8daa8fd023d5414c9f95feb4319353c6ea34be31))
37
-
38
- ## [5.5.28](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.27...@alwatr/node-fs@5.5.28) (2025-12-10)
39
-
40
- ### 🔗 Dependencies update
41
-
42
- * Upgrade lerna-lite, prettier, types/node, and yarn dependencies. ([42a7fca](https://github.com/Alwatr/nanolib/commit/42a7fca15430aca2ac1eaa19496c2a2ebfc8c470))
43
-
44
- ## [5.5.27](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.26...@alwatr/node-fs@5.5.27) (2025-11-18)
45
-
46
- ### 🐛 Bug Fixes
47
-
48
- * add type imports from @alwatr/nano-build and @alwatr/type-helper across multiple packages ([5ab7f15](https://github.com/Alwatr/nanolib/commit/5ab7f159ba57788bf8df40fa96a3027f589d5a77))
49
-
50
- ### 🔨 Code Refactoring
51
-
52
- * remove unnecessary type declarations from tsconfig.json files ([89bcc7d](https://github.com/Alwatr/nanolib/commit/89bcc7db839807110b80f8ba34414ea9734d9c75))
53
-
54
- ## [5.5.26](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.25...@alwatr/node-fs@5.5.26) (2025-11-15)
55
-
56
- ### 🔗 Dependencies update
57
-
58
- * bump the npm-dependencies group with 2 updates ([a80b84d](https://github.com/Alwatr/nanolib/commit/a80b84dada6c09b5e5621e7487c8ec13fff3c23a))
59
-
60
- ## [5.5.25](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.24...@alwatr/node-fs@5.5.25) (2025-11-15)
61
-
62
- **Note:** Version bump only for package @alwatr/node-fs
63
-
64
- ## [5.5.24](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.23...@alwatr/node-fs@5.5.24) (2025-11-04)
65
-
66
- ### 🔗 Dependencies update
67
-
68
- * bump the npm-dependencies group across 1 directory with 9 updates ([fdf29d5](https://github.com/Alwatr/nanolib/commit/fdf29d5aa89983cb06f79d42650a364521f5c4b9))
69
- * update @types/node from ^22.18.12 to ^24.10.0 across multiple packages ([1169a86](https://github.com/Alwatr/nanolib/commit/1169a86001da2abfbe99a7da33c8e92183f553f6))
70
-
71
- ## [5.5.23](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.22...@alwatr/node-fs@5.5.23) (2025-10-06)
72
-
73
- ### 🔗 Dependencies update
74
-
75
- * bump the npm-dependencies group with 4 updates ([9825815](https://github.com/Alwatr/nanolib/commit/982581552bbb4b97dca52af5e93a80937f0c3109))
76
-
77
- ## [5.5.22](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.21...@alwatr/node-fs@5.5.22) (2025-09-27)
78
-
79
- ### 🧹 Miscellaneous Chores
80
-
81
- * exclude test files from package distribution ([86f4f2f](https://github.com/Alwatr/nanolib/commit/86f4f2f5985845c5cf3a3a9398de7b2f98ce53e7))
82
-
83
- ## [5.5.21](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.20...@alwatr/node-fs@5.5.21) (2025-09-22)
84
-
85
- **Note:** Version bump only for package @alwatr/node-fs
86
-
87
- ## [5.5.20](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.19...@alwatr/node-fs@5.5.20) (2025-09-22)
88
-
89
- **Note:** Version bump only for package @alwatr/node-fs
90
-
91
- ## [5.5.19](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.18...@alwatr/node-fs@5.5.19) (2025-09-21)
92
-
93
- **Note:** Version bump only for package @alwatr/node-fs
94
-
95
- ## [5.5.18](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.17...@alwatr/node-fs@5.5.18) (2025-09-20)
96
-
97
- ### 🐛 Bug Fixes
98
-
99
- * add sideEffects property to package.json files for better tree-shaking ([c7b9e74](https://github.com/Alwatr/nanolib/commit/c7b9e74e1920c8e35b438742de61883ca62da58c))
100
- * add sideEffects property to package.json files for better tree-shaking ([e8402c4](https://github.com/Alwatr/nanolib/commit/e8402c481a14a1f807a37aaa862a936713d26176))
101
- * remove unnecessary pure annotations ([adeb916](https://github.com/Alwatr/nanolib/commit/adeb9166f8e911f59269032b76c36cb1888332cf))
102
-
103
- ### 🧹 Miscellaneous Chores
104
-
105
- * remove duplicate sideEffects property from multiple package.json files ([b123f86](https://github.com/Alwatr/nanolib/commit/b123f86be81481de2314aae9bb2eeb629743d24c))
106
-
107
- ## [5.5.17](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.16...@alwatr/node-fs@5.5.17) (2025-09-19)
108
-
109
- **Note:** Version bump only for package @alwatr/node-fs
110
-
111
- ## [5.5.16](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.15...@alwatr/node-fs@5.5.16) (2025-09-19)
112
-
113
- **Note:** Version bump only for package @alwatr/node-fs
114
-
115
- ## [5.5.15](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.14...@alwatr/node-fs@5.5.15) (2025-09-15)
116
-
117
- **Note:** Version bump only for package @alwatr/node-fs
118
-
119
- ## [5.5.14](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.13...@alwatr/node-fs@5.5.14) (2025-09-14)
120
-
121
- **Note:** Version bump only for package @alwatr/node-fs
122
-
123
- ## [5.5.13](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.12...@alwatr/node-fs@5.5.13) (2025-09-13)
124
-
125
- ### 🔗 Dependencies update
126
-
127
- * update @types/node version to ^22.18.3 in multiple package.json files ([13db6fc](https://github.com/Alwatr/nanolib/commit/13db6fc176bc6cdcefedc50d77ac550bd5052c9a))
128
-
129
- ## [5.5.12](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.11...@alwatr/node-fs@5.5.12) (2025-09-13)
130
-
131
- ### 🧹 Miscellaneous Chores
132
-
133
- * remove package-tracer dependency and related code from fetch package ([96fe4e9](https://github.com/Alwatr/nanolib/commit/96fe4e9552a205f218ceed187c55e4e904a07089))
134
-
135
- ## [5.5.11](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.10...@alwatr/node-fs@5.5.11) (2025-09-13)
136
-
137
- **Note:** Version bump only for package @alwatr/node-fs
138
-
139
- ## [5.5.10](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.9...@alwatr/node-fs@5.5.10) (2025-09-09)
140
-
141
- ### 🧹 Miscellaneous Chores
142
-
143
- * remove trailing newlines from contributing sections in README files ([e8ab1bc](https://github.com/Alwatr/nanolib/commit/e8ab1bc43e0addea5ccd4c897c2cec597cb9e15f))
144
-
145
- ## [5.5.9](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.8...@alwatr/node-fs@5.5.9) (2025-09-06)
146
-
147
- ### 🔨 Code Refactoring
148
-
149
- * update return types for readJson and writeJson functions to use Awaitable for consistency ([3215d65](https://github.com/Alwatr/nanolib/commit/3215d6509f4b4d1985726f1a2ca67997a0cbee8b))
150
-
151
- ## [5.5.8](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.7...@alwatr/node-fs@5.5.8) (2025-09-05)
152
-
153
- ### 🔗 Dependencies update
154
-
155
- * update jest to version 30.1.3 and @types/node to version 22.18.1 ([754212b](https://github.com/Alwatr/nanolib/commit/754212b1523cfc4cfe26c9e9f6d634aa8311e0b7))
156
-
157
- ## [5.5.7](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.6...@alwatr/node-fs@5.5.7) (2025-09-01)
158
-
159
- ### 🔗 Dependencies update
160
-
161
- * update lerna-lite dependencies to version 4.7.3 and jest to 30.1.2 ([95d7870](https://github.com/Alwatr/nanolib/commit/95d7870ec7ad1e6ed2688bafddcabf46857f6981))
162
-
163
- ## [5.5.6](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.5...@alwatr/node-fs@5.5.6) (2025-08-23)
164
-
165
- **Note:** Version bump only for package @alwatr/node-fs
166
-
167
- ## [5.5.5](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.3...@alwatr/node-fs@5.5.5) (2025-08-23)
168
-
169
- ### 🐛 Bug Fixes
170
-
171
- * update license from AGPL-3.0-only to MPL-2.0 ([d20968e](https://github.com/Alwatr/nanolib/commit/d20968e60cc89b1dcdf9b96507178da6ed562f55))
172
- * update package versions in multiple package.json files ([7638b1c](https://github.com/Alwatr/nanolib/commit/7638b1cafee2b4e0f97db7a89ac9fba6384b9b10))
173
-
174
- ### 🔨 Code Refactoring
175
-
176
- * Updated all package.json files in the project to change dependency version specifiers from "workspace:^" to "workspace:*" for consistency and to allow for more flexible version resolution. ([db6a4f7](https://github.com/Alwatr/nanolib/commit/db6a4f76deec2d1d8039978144e4bc51b6f1a0e3))
177
-
178
- ### 🧹 Miscellaneous Chores
179
-
180
- * reformat all package.json files ([ceda45d](https://github.com/Alwatr/nanolib/commit/ceda45de186667790474f729cb4b161a5148ce19))
181
-
182
- ### 🔗 Dependencies update
183
-
184
- * revert @types/node version to ^22.17.2 (LTS) ([49f8101](https://github.com/Alwatr/nanolib/commit/49f8101eac5c41aa7684112f4308254dbfab9787))
185
- * update TypeScript and Jest versions across all packages to improve compatibility and performance ([31baf36](https://github.com/Alwatr/nanolib/commit/31baf366101e92e27db66a21c849fb101f19be47))
186
-
187
- ## [5.5.4](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.3...@alwatr/node-fs@5.5.4) (2025-08-23)
188
-
189
- ### Code Refactoring
190
-
191
- * Updated all package.json files in the project to change dependency version specifiers from "workspace:^" to "workspace:*" for consistency and to allow for more flexible version resolution. ([db6a4f7](https://github.com/Alwatr/nanolib/commit/db6a4f76deec2d1d8039978144e4bc51b6f1a0e3)) by @alimd
192
-
193
- ## <small>5.5.3 (2025-04-15)</small>
194
-
195
- **Note:** Version bump only for package @alwatr/node-fs
196
-
197
- ## [5.5.2](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.1...@alwatr/node-fs@5.5.2) (2025-04-01)
198
-
199
- ### Dependencies update
200
-
201
- * bump the development-dependencies group across 1 directory with 2 updates ([c1320b4](https://github.com/Alwatr/nanolib/commit/c1320b447a492c5e720e25ad71e9df81eeea3670)) by @dependabot[bot]
202
-
203
- ## [5.5.1](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.5.0...@alwatr/node-fs@5.5.1) (2025-03-18)
204
-
205
- ### Dependencies update
206
-
207
- * bump the development-dependencies group with 9 updates ([7290aa3](https://github.com/Alwatr/nanolib/commit/7290aa3b52ce66ca237d2a12d28a7687b113f83d)) by @dependabot[bot]
208
-
209
- ## [5.5.0](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@5.4.0...@alwatr/node-fs@5.5.0) (2025-03-06)
210
-
211
- ### Miscellaneous Chores
212
-
213
- * update username casing in changelog entries ([9722ac9](https://github.com/Alwatr/nanolib/commit/9722ac9a078438a4e8ebfa5826ea70e0e3a52ca6)) by @
214
-
215
- ### Dependencies update
216
-
217
- * bump the development-dependencies group across 1 directory with 11 updates ([720c395](https://github.com/Alwatr/nanolib/commit/720c3954da55c929fe8fb16957121f4c51fb7f0c)) by @dependabot[bot]
218
-
219
- ## [5.4.0](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.1.8...@alwatr/node-fs@5.4.0) (2025-02-18)
220
-
221
- ### Dependencies update
222
-
223
- * bump @types/node from ^22.13.0 to ^22.13.4 and prettier from 3.4.2 to 3.5.1; update eslint-import-resolver-typescript to 3.8.2 ([b9a8399](https://github.com/Alwatr/nanolib/commit/b9a8399add39509e90bfdc589fb5e2321718029d)) by @
224
-
225
- ## 5.3.0 (2025-02-03)
226
-
227
- ### Miscellaneous Chores
228
-
229
- * edit README ([3860b3d](https://github.com/Alwatr/nanolib/commit/3860b3df48ab82dc479d5236c2e8579df614aabf)) by @
230
-
231
- ### Dependencies update
232
-
233
- * bump the development-dependencies group across 1 directory with 11 updates ([cb79d07](https://github.com/Alwatr/nanolib/commit/cb79d072a57c79e1c01abff1a293d6757bb65350)) by @
234
- * update typescript and @types/node to version 5.7.3 and 22.13.0 respectively across multiple packages ([ddab05b](https://github.com/Alwatr/nanolib/commit/ddab05b5d767c30191f36a065e4bc88744e8e3fe)) by @
235
-
236
- ## 5.1.0 (2024-11-04)
237
-
238
- ### Features
239
-
240
- * **node-fs:** enhance makeEmptyFile to create directories recursively if they don't exist ([723a770](https://github.com/Alwatr/nanolib/commit/723a7701c60c3872fc41cb041c1044793145280f)) by @
241
-
242
- ## 5.0.0 (2024-11-02)
243
-
244
- ### ⚠ BREAKING CHANGES
245
-
246
- * To simplify version management and ensure consistency, all nanolib packages now use the same version as @alwatr/nanolib. This may require updates to your project's dependencies.
247
-
248
- ### Code Refactoring
249
-
250
- * use the same version as @alwatr/nanolib ([60eb860](https://github.com/Alwatr/nanolib/commit/60eb860a0e33dfffe2d1d95e63ce54c60876be06)) by @
251
-
252
- ## [5.3.0](https://github.com/Alwatr/nanolib/compare/v5.2.1...v5.3.0) (2025-02-03)
253
-
254
- ### Miscellaneous Chores
255
-
256
- * edit README ([3860b3d](https://github.com/Alwatr/nanolib/commit/3860b3df48ab82dc479d5236c2e8579df614aabf)) by @ArmanAsadian
257
-
258
- ### Dependencies update
259
-
260
- * bump the development-dependencies group across 1 directory with 11 updates ([cb79d07](https://github.com/Alwatr/nanolib/commit/cb79d072a57c79e1c01abff1a293d6757bb65350)) by @dependabot[bot]
261
- * update typescript and @types/node to version 5.7.3 and 22.13.0 respectively across multiple packages ([ddab05b](https://github.com/Alwatr/nanolib/commit/ddab05b5d767c30191f36a065e4bc88744e8e3fe)) by @alimd
262
-
263
- ## [5.1.0](https://github.com/Alwatr/nanolib/compare/v5.0.0...v5.1.0) (2024-11-04)
264
-
265
- ### Features
266
-
267
- * **node-fs:** enhance makeEmptyFile to create directories recursively if they don't exist ([723a770](https://github.com/Alwatr/nanolib/commit/723a7701c60c3872fc41cb041c1044793145280f)) by @alimd
268
-
269
- ## 5.0.0 (2024-11-02)
270
-
271
- ### ⚠ BREAKING CHANGES
272
-
273
- * To simplify version management and ensure consistency, all nanolib packages now use the same version as @alwatr/nanolib. This may require updates to your project's dependencies.
274
-
275
- ### Features
276
-
277
- * **node-fs/write-file:** support buffer as content ([3cce9e9](https://github.com/Alwatr/nanolib/commit/3cce9e937209bfb39aee1b981370ca4a76114e62)) by @
278
- * **node-fs:** Add make-file-bench demo script ([ca3a57a](https://github.com/Alwatr/nanolib/commit/ca3a57a31de5a8b9c76c9d33cb9755809f09a335)) by @
279
- * **node-fs:** base package ([74cbe48](https://github.com/Alwatr/nanolib/commit/74cbe4821c991d1f6c3d5805b29602b922c3f505)) by @
280
- * **node-fs:** copy from store ([5c23e01](https://github.com/Alwatr/nanolib/commit/5c23e01e42d438c15dcd272d2cc351527865c86c)) by @
281
- * **node-fs:** definePackage and logger ([3880703](https://github.com/Alwatr/nanolib/commit/38807039895c784be6168111506b0721980cbb29)) by @
282
- * **node-fs:** demo ([31f3740](https://github.com/Alwatr/nanolib/commit/31f37405a7bb2b4b02440de7f96f5cc8a474aba9)) by @
283
- * **node-fs:** enhance json types ([e85d927](https://github.com/Alwatr/nanolib/commit/e85d9276374a8c5171901791a3a43acad64843a6)) by @
284
- * **node-fs:** enhance type of JSON-related functions ([69751ed](https://github.com/Alwatr/nanolib/commit/69751ed658f76eb439a9834f861c01c06542352b)) by @
285
- * **node-fs:** enhance writeJson type ([9010c72](https://github.com/Alwatr/nanolib/commit/9010c723b1f34cd647f157466554b312fc84a1d3)) by @
286
- * **node-fs:** makeFile ([186ba09](https://github.com/Alwatr/nanolib/commit/186ba09822bddfe200a0ac4725063785cadd0999)) by @
287
- * **node-fs:** readFile under asyncQueue ([ab12153](https://github.com/Alwatr/nanolib/commit/ab12153281600a4ac90ef627811b430a95140ddd)) by @
288
- * **node-fs:** rewrite new writeFile method ([7534ed1](https://github.com/Alwatr/nanolib/commit/7534ed158cdfe1ee593050255c17449960b13001)) by @
289
- * **node-fs:** writeFile under asyncQueue ([6d8b3d7](https://github.com/Alwatr/nanolib/commit/6d8b3d7953938fc954e8ce350206555030560978)) by @
290
- * **node-fs:** writeJson method ([581d4f9](https://github.com/Alwatr/nanolib/commit/581d4f958ccb262c13f23881151616b7ec5e93ee)) by @
291
- * use `package-tracer` ([cc3c5f9](https://github.com/Alwatr/nanolib/commit/cc3c5f9c1a3d03f0d81b46835665f16a0426fd0d)) by @
292
-
293
- ### Bug Fixes
294
-
295
- * all dependeny topology ([1c17f34](https://github.com/Alwatr/nanolib/commit/1c17f349adf3e98e2a80ab2da4f0f81028dc9c5f)) by @
296
- * exported types by add .js extensions to all imports ([fc3d83e](https://github.com/Alwatr/nanolib/commit/fc3d83e8f375da97ba276314b2e6966aa82c9b3f)) by @
297
- * **node-fs:** Update import statement for make-file module ([7bddaa0](https://github.com/Alwatr/nanolib/commit/7bddaa0d629c304fedd07c4022d7503aa9b974b6)) by @
298
-
299
- ### Code Refactoring
300
-
301
- * **node-fs:** readJson function ([e9cf12d](https://github.com/Alwatr/nanolib/commit/e9cf12d36924d683f6c4922934c5cb480688de03)) by @
302
- * **node-fs:** remove unused import from common module ([496a338](https://github.com/Alwatr/nanolib/commit/496a338a6366aa12dc32bbed07a3e14bd5315bd2)) by @
303
- * **node-fs:** rewrite makeEmptyFile ([a39590b](https://github.com/Alwatr/nanolib/commit/a39590b41f1936ec7a4abad92b7c0fdc95a99e8d)) by @
304
- * **node-fs:** separate files ([a2b15a4](https://github.com/Alwatr/nanolib/commit/a2b15a4e8077759bc647ca5356aebc48a49e8fd4)) by @
305
- * **node-fs:** separate read file functions ([de2cf5d](https://github.com/Alwatr/nanolib/commit/de2cf5d7110646230019c53a458092617be71922)) by @
306
- * **node-fs:** separate readJson ([5616b53](https://github.com/Alwatr/nanolib/commit/5616b5303a9a4d5e35c8e75c09c59a8fbd145030)) by @
307
- * **node-fs:** Update logger import and initialization ([0f89c0f](https://github.com/Alwatr/nanolib/commit/0f89c0f7bc24e79c20d3d5d3fc3f906f12cf7161)) by @
308
- * prevent side-effects ([01e00e1](https://github.com/Alwatr/nanolib/commit/01e00e191385cc92b28677df0c01a085916ae677)) by @
309
- * use new type-helper global types and remove all import types ([08b5d08](https://github.com/Alwatr/nanolib/commit/08b5d08c03c7c315382337239de0426462f384b8)) by @
310
- * use the same version as @alwatr/nanolib ([60eb860](https://github.com/Alwatr/nanolib/commit/60eb860a0e33dfffe2d1d95e63ce54c60876be06)) by @
311
-
312
- ### Miscellaneous Chores
313
-
314
- * **deps-dev:** bump the development-dependencies group with 3 updates ([0e0ec0f](https://github.com/Alwatr/nanolib/commit/0e0ec0f7c66c849727563cabe0e88606aee49035)) by @
315
- * **deps:** update ([1a45030](https://github.com/Alwatr/nanolib/commit/1a450305440b710a300787d4ca24b1ed8c6a39d7)) by @
316
- * **deps:** update ([8e70dff](https://github.com/Alwatr/nanolib/commit/8e70dffb1e751496ef2e72d6cffd685f1fea44e3)) by @
317
- * include LICENSE and LEGAL files to publish ([09f366f](https://github.com/Alwatr/nanolib/commit/09f366f680bfa9fb26acb2cd1ccbc68c5a9e9ad8)) by @
318
- * **node-fs:** beta version ([1b43445](https://github.com/Alwatr/nanolib/commit/1b4344573ad878fefde904958c8366ff5d6166c3)) by @
319
- * **node-fs:** change the license to AGPL-3.0 ([9728276](https://github.com/Alwatr/nanolib/commit/97282764bfdb15ef1de25704012f1628a5d0c112)) by @
320
- * **node-fs:** enhance demo test ([b7370d6](https://github.com/Alwatr/nanolib/commit/b7370d6805133df163c281be22b3289bdf3dfb90)) by @
321
- * **node-fs:** review and test ([69da5b7](https://github.com/Alwatr/nanolib/commit/69da5b7f81cfeee1678d92e97ac3e73009c5fe1f)) by @
322
- * Update build and lint scripts ([392d0b7](https://github.com/Alwatr/nanolib/commit/392d0b71f446bce336b0256119a80f07aff794ba)) by @
323
- * Update package.json exports for [@alwatr](https://github.com/alwatr) packages ([dacb362](https://github.com/Alwatr/nanolib/commit/dacb362b145e3c51b4aba00ff643687a3fac11d2)) by @
324
-
325
- ### Dependencies update
326
-
327
- * bump @types/node ([3d80fed](https://github.com/Alwatr/nanolib/commit/3d80fedaf720af792feb060c2f81c737ebb84e11)) by @
328
- * bump the development-dependencies group across 1 directory with 10 updates ([9ed98ff](https://github.com/Alwatr/nanolib/commit/9ed98ffd0668d5a36e255c82edab3af53bffda8f)) by @
329
- * bump the development-dependencies group across 1 directory with 2 updates ([2dfda9e](https://github.com/Alwatr/nanolib/commit/2dfda9ec38a595f1fd961490d1a2fbf060f20a66)) by @
330
- * bump the development-dependencies group with 10 updates ([fa4aaf0](https://github.com/Alwatr/nanolib/commit/fa4aaf04c907ecae06aa14000ce35216170c15ad)) by @
331
- * bump the development-dependencies group with 2 updates ([be5d6c2](https://github.com/Alwatr/nanolib/commit/be5d6c2d86b937f32cebc6848aaff85af07055dd)) by @
332
- * bump the development-dependencies group with 8 updates ([16847ac](https://github.com/Alwatr/nanolib/commit/16847acba91da027c422e3910d0f2dcc1f084e93)) by @
333
- * upd ([451d025](https://github.com/Alwatr/nanolib/commit/451d0255ba96ed55f897a6f44f62cf4e6d2b12be)) by @
334
- * update ([4434ba6](https://github.com/Alwatr/nanolib/commit/4434ba67c3f576bb1a0c307fbdb263c43cd9733a)) by @
335
- * update ([c36ed50](https://github.com/Alwatr/nanolib/commit/c36ed50f68da2f5608ccd96119963a16cfacb4ce)) by @
336
- * update all ([53342f6](https://github.com/Alwatr/nanolib/commit/53342f67a8a013127f073540bc11929f1813c05c)) by @
337
- * update all dependencies ([1e0c30e](https://github.com/Alwatr/nanolib/commit/1e0c30e6a3a8e19deb5185814e24ab6c08dca573)) by @
338
- * update all dependencies ([0e908b4](https://github.com/Alwatr/nanolib/commit/0e908b476a6b976ec2447f864c8cafcbb8a0f099)) by @
339
- * upgrade ([6dbd300](https://github.com/Alwatr/nanolib/commit/6dbd300642c9bcc9e7d0b281e244bf1b06eb1c38)) by @
340
-
341
- ## [1.1.8](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.1.7...@alwatr/node-fs@1.1.8) (2024-11-02)
342
-
343
- ### Dependencies update
344
-
345
- * update ([4434ba6](https://github.com/Alwatr/nanolib/commit/4434ba67c3f576bb1a0c307fbdb263c43cd9733a)) by @alimd
346
-
347
- ## [1.1.7](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.1.6...@alwatr/node-fs@1.1.7) (2024-10-25)
348
-
349
- ### Dependencies update
350
-
351
- * bump the development-dependencies group across 1 directory with 2 updates ([2dfda9e](https://github.com/Alwatr/nanolib/commit/2dfda9ec38a595f1fd961490d1a2fbf060f20a66)) by @dependabot[bot]
352
- * bump the development-dependencies group with 8 updates ([16847ac](https://github.com/Alwatr/nanolib/commit/16847acba91da027c422e3910d0f2dcc1f084e93)) by @dependabot[bot]
353
-
354
- ## [1.1.6](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.1.5...@alwatr/node-fs@1.1.6) (2024-10-12)
355
-
356
- **Note:** Version bump only for package @alwatr/node-fs
357
-
358
- ## [1.1.5](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.1.4...@alwatr/node-fs@1.1.5) (2024-10-11)
359
-
360
- ### Code Refactoring
361
-
362
- - prevent side-effects ([01e00e1](https://github.com/Alwatr/nanolib/commit/01e00e191385cc92b28677df0c01a085916ae677)) by @mohammadhonarvar
363
-
364
- ## [1.1.4](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.1.3...@alwatr/node-fs@1.1.4) (2024-10-11)
365
-
366
- ### Miscellaneous Chores
367
-
368
- - include LICENSE and LEGAL files to publish ([09f366f](https://github.com/Alwatr/nanolib/commit/09f366f680bfa9fb26acb2cd1ccbc68c5a9e9ad8)) by @alimd
369
-
370
- ## [1.1.3](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.1.2...@alwatr/node-fs@1.1.3) (2024-10-11)
371
-
372
- **Note:** Version bump only for package @alwatr/node-fs
373
-
374
- ## [1.1.2](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.1.1...@alwatr/node-fs@1.1.2) (2024-10-10)
375
-
376
- ### Dependencies update
377
-
378
- - bump the development-dependencies group with 10 updates ([fa4aaf0](https://github.com/Alwatr/nanolib/commit/fa4aaf04c907ecae06aa14000ce35216170c15ad)) by @dependabot[bot]
379
-
380
- ## [1.1.1](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.1.0...@alwatr/node-fs@1.1.1) (2024-10-08)
381
-
382
- **Note:** Version bump only for package @alwatr/node-fs
383
-
384
- ## [1.1.0](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.0.13...@alwatr/node-fs@1.1.0) (2024-09-29)
385
-
386
- ### Features
387
-
388
- - **node-fs/write-file:** support buffer as content ([3cce9e9](https://github.com/Alwatr/nanolib/commit/3cce9e937209bfb39aee1b981370ca4a76114e62)) by @njfamirm
389
- - use `package-tracer` ([cc3c5f9](https://github.com/Alwatr/nanolib/commit/cc3c5f9c1a3d03f0d81b46835665f16a0426fd0d)) by @mohammadhonarvar
390
-
391
- ### Bug Fixes
392
-
393
- - all dependeny topology ([1c17f34](https://github.com/Alwatr/nanolib/commit/1c17f349adf3e98e2a80ab2da4f0f81028dc9c5f)) by @mohammadhonarvar
394
-
395
- ### Code Refactoring
396
-
397
- - **node-fs:** remove unused import from common module ([496a338](https://github.com/Alwatr/nanolib/commit/496a338a6366aa12dc32bbed07a3e14bd5315bd2)) by @alimd
398
- - **node-fs:** Update logger import and initialization ([0f89c0f](https://github.com/Alwatr/nanolib/commit/0f89c0f7bc24e79c20d3d5d3fc3f906f12cf7161)) by @alimd
399
- - use new type-helper global types and remove all import types ([08b5d08](https://github.com/Alwatr/nanolib/commit/08b5d08c03c7c315382337239de0426462f384b8)) by @alimd
400
-
401
- ### Miscellaneous Chores
402
-
403
- - **node-fs:** change the license to AGPL-3.0 ([9728276](https://github.com/Alwatr/nanolib/commit/97282764bfdb15ef1de25704012f1628a5d0c112)) by @ArmanAsadian
404
- - Update build and lint scripts ([392d0b7](https://github.com/Alwatr/nanolib/commit/392d0b71f446bce336b0256119a80f07aff794ba)) by @alimd
405
-
406
- ### Dependencies update
407
-
408
- - bump @types/node ([3d80fed](https://github.com/Alwatr/nanolib/commit/3d80fedaf720af792feb060c2f81c737ebb84e11)) by @dependabot[bot]
409
-
410
- ## [1.0.13](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.0.12...@alwatr/node-fs@1.0.13) (2024-09-21)
411
-
412
- **Note:** Version bump only for package @alwatr/node-fs
413
-
414
- ## [1.0.12](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.0.11...@alwatr/node-fs@1.0.12) (2024-09-15)
415
-
416
- ### Dependencies update
417
-
418
- - bump the development-dependencies group across 1 directory with 10 updates ([9ed98ff](https://github.com/Alwatr/nanolib/commit/9ed98ffd0668d5a36e255c82edab3af53bffda8f)) by @dependabot[bot]
419
- - update ([c36ed50](https://github.com/Alwatr/nanolib/commit/c36ed50f68da2f5608ccd96119963a16cfacb4ce)) by @alimd
420
-
421
- ## [1.0.11](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.0.10...@alwatr/node-fs@1.0.11) (2024-08-31)
422
-
423
- ### Miscellaneous Chores
424
-
425
- - Update package.json exports for [@alwatr](https://github.com/alwatr) packages ([dacb362](https://github.com/Alwatr/nanolib/commit/dacb362b145e3c51b4aba00ff643687a3fac11d2)) by @
426
-
427
- ## [1.0.10](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.0.9...@alwatr/node-fs@1.0.10) (2024-08-31)
428
-
429
- **Note:** Version bump only for package @alwatr/node-fs
430
-
431
- ## [1.0.9](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.0.8...@alwatr/node-fs@1.0.9) (2024-08-31)
432
-
433
- ### Dependencies update
434
-
435
- - update all dependencies ([1e0c30e](https://github.com/Alwatr/nanolib/commit/1e0c30e6a3a8e19deb5185814e24ab6c08dca573)) by @alimd
436
-
437
- ## [1.0.8](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.0.7...@alwatr/node-fs@1.0.8) (2024-07-04)
438
-
439
- ### Dependencies update
440
-
441
- - update all dependencies ([0e908b4](https://github.com/Alwatr/nanolib/commit/0e908b476a6b976ec2447f864c8cafcbb8a0f099)) by @
442
-
443
- ## [1.0.7](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.0.6...@alwatr/node-fs@1.0.7) (2024-05-12)
444
-
445
- ### Dependencies update
446
-
447
- - upgrade ([6dbd300](https://github.com/Alwatr/nanolib/commit/6dbd300642c9bcc9e7d0b281e244bf1b06eb1c38)) by @alimd
448
-
449
- ## [1.0.6](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.0.5...@alwatr/node-fs@1.0.6) (2024-04-25)
450
-
451
- **Note:** Version bump only for package @alwatr/node-fs
452
-
453
- ## [1.0.5](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.0.4...@alwatr/node-fs@1.0.5) (2024-03-28)
454
-
455
- **Note:** Version bump only for package @alwatr/node-fs
456
-
457
- ## [1.0.4](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.0.3...@alwatr/node-fs@1.0.4) (2024-01-31)
458
-
459
- ### Bug Fixes
460
-
461
- - exported types by add .js extensions to all imports ([fc3d83e](https://github.com/Alwatr/nanolib/commit/fc3d83e8f375da97ba276314b2e6966aa82c9b3f)) by @alimd
462
-
463
- ### Miscellaneous Chores
464
-
465
- - **deps:** update ([1a45030](https://github.com/Alwatr/nanolib/commit/1a450305440b710a300787d4ca24b1ed8c6a39d7)) by @alimd
466
-
467
- ## [1.0.3](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.0.2...@alwatr/node-fs@1.0.3) (2024-01-24)
468
-
469
- **Note:** Version bump only for package @alwatr/node-fs
470
-
471
- ## [1.0.2](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.0.1...@alwatr/node-fs@1.0.2) (2024-01-20)
472
-
473
- **Note:** Version bump only for package @alwatr/node-fs
474
-
475
- ## [1.0.1](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.0.0...@alwatr/node-fs@1.0.1) (2024-01-16)
476
-
477
- **Note:** Version bump only for package @alwatr/node-fs
478
-
479
- # [1.0.0](https://github.com/Alwatr/nanolib/compare/@alwatr/node-fs@1.0.0-beta.0...@alwatr/node-fs@1.0.0) (2024-01-16)
480
-
481
- ### Features
482
-
483
- - **node-fs:** enhance type of JSON-related functions ([69751ed](https://github.com/Alwatr/nanolib/commit/69751ed658f76eb439a9834f861c01c06542352b)) by @alimd
484
-
485
- # 1.0.0-beta.0 (2024-01-08)
486
-
487
- ### Bug Fixes
488
-
489
- - **node-fs:** Update import statement for make-file module ([7bddaa0](https://github.com/Alwatr/nanolib/commit/7bddaa0d629c304fedd07c4022d7503aa9b974b6)) by @alimd
490
-
491
- ### Features
492
-
493
- - **node-fs:** Add make-file-bench demo script ([ca3a57a](https://github.com/Alwatr/nanolib/commit/ca3a57a31de5a8b9c76c9d33cb9755809f09a335)) by @alimd
494
- - **node-fs:** base package ([74cbe48](https://github.com/Alwatr/nanolib/commit/74cbe4821c991d1f6c3d5805b29602b922c3f505)) by @njfamirm
495
- - **node-fs:** copy from store ([5c23e01](https://github.com/Alwatr/nanolib/commit/5c23e01e42d438c15dcd272d2cc351527865c86c)) by @njfamirm
496
- - **node-fs:** definePackage and logger ([3880703](https://github.com/Alwatr/nanolib/commit/38807039895c784be6168111506b0721980cbb29)) by @njfamirm
497
- - **node-fs:** demo ([31f3740](https://github.com/Alwatr/nanolib/commit/31f37405a7bb2b4b02440de7f96f5cc8a474aba9)) by @njfamirm
498
- - **node-fs:** enhance json types ([e85d927](https://github.com/Alwatr/nanolib/commit/e85d9276374a8c5171901791a3a43acad64843a6)) by @alimd
499
- - **node-fs:** enhance writeJson type ([9010c72](https://github.com/Alwatr/nanolib/commit/9010c723b1f34cd647f157466554b312fc84a1d3)) by @alimd
500
- - **node-fs:** makeFile ([186ba09](https://github.com/Alwatr/nanolib/commit/186ba09822bddfe200a0ac4725063785cadd0999)) by @njfamirm
501
- - **node-fs:** readFile under asyncQueue ([ab12153](https://github.com/Alwatr/nanolib/commit/ab12153281600a4ac90ef627811b430a95140ddd)) by @alimd
502
- - **node-fs:** rewrite new writeFile method ([7534ed1](https://github.com/Alwatr/nanolib/commit/7534ed158cdfe1ee593050255c17449960b13001)) by @alimd
503
- - **node-fs:** writeFile under asyncQueue ([6d8b3d7](https://github.com/Alwatr/nanolib/commit/6d8b3d7953938fc954e8ce350206555030560978)) by @alimd
504
- - **node-fs:** writeJson method ([581d4f9](https://github.com/Alwatr/nanolib/commit/581d4f958ccb262c13f23881151616b7ec5e93ee)) by @alimd
package/dist/main.cjs DELETED
@@ -1,3 +0,0 @@
1
- /** 📦 @alwatr/node-fs v5.5.33 */
2
- "use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from==="object"||typeof from==="function"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:true}),mod);var main_exports={};__export(main_exports,{existsSync:()=>import_node_fs4.existsSync,makeEmptyFile:()=>makeEmptyFile,readFile:()=>readFile,readFileSync:()=>readFileSync,readJson:()=>readJson,resolve:()=>import_node_path3.resolve,unlink:()=>import_promises4.unlink,writeFile:()=>writeFile,writeFileSync:()=>writeFileSync,writeJson:()=>writeJson});module.exports=__toCommonJS(main_exports);var import_node_fs=require("node:fs");var import_promises=require("node:fs/promises");var import_flat_string=require("@alwatr/flat-string");var import_async_queue=require("@alwatr/async-queue");var import_logger=require("@alwatr/logger");var logger=(0,import_logger.createLogger)("@alwatr/node-fs");var asyncQueue=new import_async_queue.AsyncQueue;function readFileSync(path){logger.logMethodArgs?.("readFileSync","..."+path.slice(-32));try{return(0,import_flat_string.flatString)((0,import_node_fs.readFileSync)(path,{encoding:"utf-8",flag:"r"}))}catch(err){logger.error("readFileSync","read_file_failed",{path},err);throw new Error("read_file_failed",{cause:err.cause})}}function readFile(path){logger.logMethodArgs?.("readFile","..."+path.slice(-32));return asyncQueue.push(path,async()=>{try{return(0,import_flat_string.flatString)(await(0,import_promises.readFile)(path,{encoding:"utf-8",flag:"r"}))}catch(err){logger.error("readFile","read_file_failed",{path},err);throw new Error("read_file_failed",{cause:err.cause})}})}var import_node_fs2=require("node:fs");var import_promises2=require("node:fs/promises");var import_node_path=require("node:path");function writeFileSync(path,content){logger.logMethodArgs?.("writeFileSync","..."+path.slice(-32));try{const pathExists=(0,import_node_fs2.existsSync)(path);if(!pathExists){const dir=(0,import_node_path.dirname)(path);if(!(0,import_node_fs2.existsSync)(dir)){(0,import_node_fs2.mkdirSync)(dir,{recursive:true})}}(0,import_node_fs2.writeFileSync)(path+".tmp",content,{encoding:"utf-8",flag:"w"});if(pathExists){(0,import_node_fs2.renameSync)(path,path+".bak")}(0,import_node_fs2.renameSync)(path+".tmp",path);logger.logOther?.("writeFileSync success","..."+path.slice(-32))}catch(err){logger.error("writeFileSync","write_file_failed",{path},err);throw new Error("write_file_failed",{cause:err.cause})}}function writeFile(path,content){logger.logMethodArgs?.("writeFile","..."+path.slice(-32));return asyncQueue.push(path,async()=>{try{logger.logOther?.("writeFile start","..."+path.slice(-32));const pathExists=(0,import_node_fs2.existsSync)(path);if(!pathExists){const dir=(0,import_node_path.dirname)(path);if(!(0,import_node_fs2.existsSync)(dir)){await(0,import_promises2.mkdir)(dir,{recursive:true})}}await(0,import_promises2.writeFile)(path+".tmp",content,{encoding:"utf-8",flag:"w"});if(pathExists){await(0,import_promises2.rename)(path,path+".bak")}await(0,import_promises2.rename)(path+".tmp",path);logger.logOther?.("writeFile success","..."+path.slice(-32))}catch(err){logger.error("writeFile","write_file_failed",{path},err);throw new Error("write_file_failed",{cause:err.cause})}})}function parseJson(content){try{return JSON.parse(content)}catch(err){logger.error("parseJson","invalid_json",err);throw new Error("invalid_json",{cause:err.cause})}}function jsonStringify(data){try{return JSON.stringify(data)}catch(err){logger.error("jsonStringify","stringify_failed",err);throw new Error("stringify_failed",{cause:err.cause})}}function readJson(path,sync=false){logger.logMethodArgs?.("readJson",{path:path.slice(-32),sync});if(sync===true){return parseJson(readFileSync(path))}else{return readFile(path).then(content=>parseJson(content))}}var import_flat_string2=require("@alwatr/flat-string");function writeJson(path,data,sync=false){logger.logMethodArgs?.("writeJson","..."+path.slice(-32));const content=(0,import_flat_string2.flatString)(jsonStringify(data));return sync===true?writeFileSync(path,content):writeFile(path,content)}var import_node_fs3=require("node:fs");var import_promises3=require("node:fs/promises");var import_node_path2=require("node:path");async function makeEmptyFile(path){logger.logMethodArgs?.("makeEmptyFile","..."+path.slice(-32));try{const pathExists=(0,import_node_fs3.existsSync)(path);if(!pathExists){const dir=(0,import_node_path2.dirname)(path);if(!(0,import_node_fs3.existsSync)(dir)){await(0,import_promises3.mkdir)(dir,{recursive:true})}}await(await(0,import_promises3.open)(path,"w")).close()}catch(err){logger.error("makeEmptyFile","make_file_failed",{path},err);throw new Error("make_file_failed",{cause:err.cause})}}var import_node_path3=require("node:path");var import_node_fs4=require("node:fs");var import_promises4=require("node:fs/promises");0&&(module.exports={existsSync,makeEmptyFile,readFile,readFileSync,readJson,resolve,unlink,writeFile,writeFileSync,writeJson});
3
- //# sourceMappingURL=main.cjs.map
package/dist/main.cjs.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/main.ts", "../src/read-file.ts", "../src/common.ts", "../src/write-file.ts", "../src/json.ts", "../src/read-json.ts", "../src/write-json.ts", "../src/make-file.ts"],
4
- "sourcesContent": ["export * from './read-file.js';\nexport * from './write-file.js';\nexport * from './read-json.js';\nexport * from './write-json.js';\nexport * from './make-file.js';\n\nexport {resolve} from 'node:path';\nexport {existsSync} from 'node:fs';\nexport {unlink} from 'node:fs/promises';\n", "import {readFileSync as readFileSync_} from 'node:fs';\nimport {readFile as readFile_} from 'node:fs/promises';\n\nimport {flatString} from '@alwatr/flat-string';\n\nimport {asyncQueue, logger} from './common.js';\n\n/**\n * Enhanced read File (Synchronous).\n *\n * @param path - file path\n * @returns file content\n * @example\n * ```typescript\n * const fileContent = readFileSync('./file.txt', sync);\n * ```\n */\nexport function readFileSync(path: string): string {\n logger.logMethodArgs?.('readFileSync', '...' + path.slice(-32));\n // if (!existsSync(path)) throw new Error('file_not_found');\n try {\n return flatString(readFileSync_(path, {encoding: 'utf-8', flag: 'r'}));\n }\n catch (err) {\n logger.error('readFileSync', 'read_file_failed', {path}, err);\n throw new Error('read_file_failed', {cause: (err as Error).cause});\n }\n}\n\n/**\n * Enhanced read File (Asynchronous).\n *\n * - If writing queue is running for target path, it will wait for it to finish.\n *\n * @param path - file path\n * @returns file content\n * @example\n * ```typescript\n * const fileContent = await readFile('./file.txt', sync);\n * ```\n */\nexport function readFile(path: string): Promise<string> {\n logger.logMethodArgs?.('readFile', '...' + path.slice(-32));\n // if (!existsSync(path)) throw new Error('file_not_found');\n return asyncQueue.push(path, async () => {\n try {\n return flatString(await readFile_(path, {encoding: 'utf-8', flag: 'r'}));\n }\n catch (err) {\n logger.error('readFile', 'read_file_failed', {path}, err);\n throw new Error('read_file_failed', {cause: (err as Error).cause});\n }\n });\n}\n", "import {AsyncQueue} from '@alwatr/async-queue';\nimport {createLogger} from '@alwatr/logger';\n\nimport type {} from '@alwatr/type-helper';\n\nexport const logger = createLogger('@alwatr/node-fs');\n\nexport const asyncQueue = new AsyncQueue();\n", "import {writeFileSync as writeFileSync_, existsSync, mkdirSync, renameSync} from 'node:fs';\nimport {mkdir, rename, writeFile as writeFile_} from 'node:fs/promises';\nimport {dirname} from 'node:path';\n\nimport {asyncQueue, logger} from './common.js';\n\n/**\n * Enhanced write file (Synchronous).\n *\n * - If directory not exists, create it recursively.\n * - Write file to `path.tmp` before write success.\n * - If file exists, renamed (keep) to `path.bak`.\n * - If write failed, original file will not be changed.\n *\n * @param path - file path\n * @param content - file content\n * @example\n * ```typescript\n * writeFileSync('./file.txt', 'Hello World!');\n * ```\n */\nexport function writeFileSync(path: string, content: Buffer | string): void {\n logger.logMethodArgs?.('writeFileSync', '...' + path.slice(-32));\n try {\n const pathExists = existsSync(path);\n if (!pathExists) {\n const dir = dirname(path);\n if (!existsSync(dir)) {\n mkdirSync(dir, {recursive: true});\n }\n }\n writeFileSync_(path + '.tmp', content, {encoding: 'utf-8', flag: 'w'});\n if (pathExists) {\n renameSync(path, path + '.bak');\n }\n renameSync(path + '.tmp', path);\n logger.logOther?.('writeFileSync success', '...' + path.slice(-32));\n }\n catch (err) {\n logger.error('writeFileSync', 'write_file_failed', {path}, err);\n throw new Error('write_file_failed', {cause: (err as Error).cause});\n }\n}\n\n/**\n * Enhanced write file (Asynchronous).\n *\n * - If directory not exists, create it recursively.\n * - Write file to `path.tmp` before write success.\n * - If file exists, renamed (keep) to `path.bak`.\n * - If write failed, original file will not be changed.\n *\n * @param path - file path\n * @param content - file content\n * @example\n * ```typescript\n * await writeFile('./file.txt', 'Hello World!');\n * ```\n */\nexport function writeFile(path: string, content: Buffer | string): Promise<void> {\n logger.logMethodArgs?.('writeFile', '...' + path.slice(-32));\n return asyncQueue.push(path, async () => {\n try {\n logger.logOther?.('writeFile start', '...' + path.slice(-32));\n const pathExists = existsSync(path);\n if (!pathExists) {\n const dir = dirname(path);\n if (!existsSync(dir)) {\n await mkdir(dir, {recursive: true});\n }\n }\n await writeFile_(path + '.tmp', content, {encoding: 'utf-8', flag: 'w'});\n if (pathExists) {\n await rename(path, path + '.bak');\n }\n await rename(path + '.tmp', path);\n logger.logOther?.('writeFile success', '...' + path.slice(-32));\n }\n catch (err) {\n logger.error('writeFile', 'write_file_failed', {path}, err);\n throw new Error('write_file_failed', {cause: (err as Error).cause});\n }\n });\n}\n", "import {logger} from './common.js';\n\n/**\n * Parse json string.\n *\n * @param content - json string\n * @returns json object\n * @example\n * ```typescript\n * const json = parseJson('{\"a\":1,\"b\":2}');\n * console.log(json.a); // 1\n * ```\n */\nexport function parseJson<T extends JsonValue>(content: string): T {\n try {\n return JSON.parse(content);\n }\n catch (err) {\n logger.error('parseJson', 'invalid_json', err);\n throw new Error('invalid_json', {cause: (err as Error).cause});\n }\n}\n\n/**\n * Stringify json object.\n *\n * @param data - json object\n * @returns json string\n * @example\n * ```typescript\n * const json = jsonStringify({a:1, b:2});\n * console.log(json); // '{\"a\":1,\"b\":2}'\n * ```\n */\nexport function jsonStringify<T extends JsonValue>(data: T): string {\n try {\n return JSON.stringify(data);\n }\n catch (err) {\n logger.error('jsonStringify', 'stringify_failed', err);\n throw new Error('stringify_failed', {cause: (err as Error).cause});\n }\n}\n", "import {logger} from './common.js';\nimport {parseJson} from './json.js';\nimport {readFile, readFileSync} from './read-file.js';\n\n/**\n * Enhanced read json file (async).\n *\n * @param path - file path\n * @returns json object\n * @example\n * ```typescript\n * const fileContent = await readJson('./file.json');\n * ```\n */\nexport function readJson<T extends JsonValue>(path: string): Promise<T>;\n/**\n * Enhanced read json file (sync).\n *\n * @param path - file path\n * @param sync - sync mode\n * @returns json object\n * @example\n * ```typescript\n * const fileContent = readJson('./file.json', true);\n * ```\n */\nexport function readJson<T extends JsonValue>(path: string, sync: true): T;\n/**\n * Enhanced read json file.\n *\n * @param path - file path\n * @param sync - sync mode\n * @returns json object\n * @example\n * ```typescript\n * const fileContent = await readJson('./file.json', sync);\n * ```\n */\nexport function readJson<T extends JsonValue>(path: string, sync: boolean): Awaitable<T>;\n/**\n * Enhanced read json file.\n *\n * @param path - file path\n * @param sync - sync mode\n * @returns json object\n * @example\n * ```typescript\n * const fileContent = await readJson('./file.json');\n * ```\n */\nexport function readJson<T extends JsonValue>(path: string, sync = false): Awaitable<T> {\n logger.logMethodArgs?.('readJson', {path: path.slice(-32), sync});\n if (sync === true) {\n return parseJson<T>(readFileSync(path));\n }\n else {\n return readFile(path).then((content) => parseJson<T>(content));\n }\n}\n", "import {flatString} from '@alwatr/flat-string';\n\nimport {logger} from './common.js';\nimport {jsonStringify} from './json.js';\nimport {writeFile, writeFileSync} from './write-file.js';\n\n/**\n * Enhanced write json file (Asynchronous).\n *\n * @param path - file path\n * @param data - json object\n * @example\n * ```typescript\n * await writeJsonFile('./file.json', { a:1, b:2, c:3 });\n * ```\n */\nexport function writeJson<T extends JsonValue>(path: string, data: T, sync?: false): Promise<void>;\n/**\n * Enhanced write json file (Synchronous).\n *\n * @param path - file path\n * @param data - json object\n * @param sync - sync mode\n * @example\n * ```typescript\n * writeJsonFile('./file.json', { a:1, b:2, c:3 }, true);\n * ```\n */\nexport function writeJson<T extends JsonValue>(path: string, data: T, sync: true): void;\n/**\n * Enhanced write json file.\n *\n * @param path - file path\n * @param data - json object\n * @param sync - sync mode\n * @example\n * ```typescript\n * await writeJsonFile('./file.json', { a:1, b:2, c:3 }, sync);\n * ```\n */\nexport function writeJson<T extends JsonValue>(path: string, data: T, sync: boolean): Awaitable<void>;\n/**\n * Enhanced write json file.\n *\n * @param path - file path\n * @param data - json object\n * @param sync - sync mode\n * @example\n * ```typescript\n * await writeJsonFile('./file.json', { a:1, b:2, c:3 });\n * ```\n */\nexport function writeJson<T extends JsonValue>(path: string, data: T, sync = false): Awaitable<void> {\n logger.logMethodArgs?.('writeJson', '...' + path.slice(-32));\n const content = flatString(jsonStringify(data));\n return sync === true ? writeFileSync(path, content) : writeFile(path, content);\n}\n", "import {existsSync} from 'node:fs';\nimport {mkdir, open} from 'node:fs/promises';\nimport {dirname} from 'node:path';\n\nimport {logger} from './common.js';\n\n/**\n * Make empty file.\n *\n * @param path - file path\n *\n * @example\n * ```ts\n * await makeFile('./dir/file.txt');\n * ```\n */\nexport async function makeEmptyFile(path: string): Promise<void> {\n logger.logMethodArgs?.('makeEmptyFile', '...' + path.slice(-32));\n try {\n const pathExists = existsSync(path);\n if (!pathExists) {\n const dir = dirname(path);\n if (!existsSync(dir)) {\n await mkdir(dir, {recursive: true});\n }\n }\n await (await open(path, 'w')).close();\n }\n catch (err) {\n logger.error('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MAAO,QAAM,uBAAK,KAAM,GAAG,GAAG,MAAM,CACtC,OACO,IAAK,CACV,OAAO,MAAM,gBAAiB,mBAAoB,CAAC,IAAI,EAAG,GAAG,EAC7D,MAAM,IAAI,MAAM,mBAAoB,CAAC,MAAQ,IAAc,KAAK,CAAC,CACnE,CACF,CP1BA,IAAAC,kBAAsB,qBACtB,IAAAC,gBAAyB,mBACzB,IAAAC,iBAAqB",
6
- "names": ["readFileSync_", "readFile_", "import_node_fs", "import_promises", "writeFileSync_", "writeFile_", "import_flat_string", "import_node_fs", "import_promises", "import_node_path", "import_node_path", "import_node_fs", "import_promises"]
7
- }
package/dist/main.mjs DELETED
@@ -1,3 +0,0 @@
1
- /** 📦 @alwatr/node-fs v5.5.33 */
2
- import{readFileSync as readFileSync_}from"node:fs";import{readFile as readFile_}from"node:fs/promises";import{flatString}from"@alwatr/flat-string";import{AsyncQueue}from"@alwatr/async-queue";import{createLogger}from"@alwatr/logger";var logger=createLogger("@alwatr/node-fs");var asyncQueue=new AsyncQueue;function readFileSync(path){logger.logMethodArgs?.("readFileSync","..."+path.slice(-32));try{return flatString(readFileSync_(path,{encoding:"utf-8",flag:"r"}))}catch(err){logger.error("readFileSync","read_file_failed",{path},err);throw new Error("read_file_failed",{cause:err.cause})}}function readFile(path){logger.logMethodArgs?.("readFile","..."+path.slice(-32));return asyncQueue.push(path,async()=>{try{return flatString(await readFile_(path,{encoding:"utf-8",flag:"r"}))}catch(err){logger.error("readFile","read_file_failed",{path},err);throw new Error("read_file_failed",{cause:err.cause})}})}import{writeFileSync as writeFileSync_,existsSync,mkdirSync,renameSync}from"node:fs";import{mkdir,rename,writeFile as writeFile_}from"node:fs/promises";import{dirname}from"node:path";function writeFileSync(path,content){logger.logMethodArgs?.("writeFileSync","..."+path.slice(-32));try{const pathExists=existsSync(path);if(!pathExists){const dir=dirname(path);if(!existsSync(dir)){mkdirSync(dir,{recursive:true})}}writeFileSync_(path+".tmp",content,{encoding:"utf-8",flag:"w"});if(pathExists){renameSync(path,path+".bak")}renameSync(path+".tmp",path);logger.logOther?.("writeFileSync success","..."+path.slice(-32))}catch(err){logger.error("writeFileSync","write_file_failed",{path},err);throw new Error("write_file_failed",{cause:err.cause})}}function writeFile(path,content){logger.logMethodArgs?.("writeFile","..."+path.slice(-32));return asyncQueue.push(path,async()=>{try{logger.logOther?.("writeFile start","..."+path.slice(-32));const pathExists=existsSync(path);if(!pathExists){const dir=dirname(path);if(!existsSync(dir)){await mkdir(dir,{recursive:true})}}await writeFile_(path+".tmp",content,{encoding:"utf-8",flag:"w"});if(pathExists){await rename(path,path+".bak")}await rename(path+".tmp",path);logger.logOther?.("writeFile success","..."+path.slice(-32))}catch(err){logger.error("writeFile","write_file_failed",{path},err);throw new Error("write_file_failed",{cause:err.cause})}})}function parseJson(content){try{return JSON.parse(content)}catch(err){logger.error("parseJson","invalid_json",err);throw new Error("invalid_json",{cause:err.cause})}}function jsonStringify(data){try{return JSON.stringify(data)}catch(err){logger.error("jsonStringify","stringify_failed",err);throw new Error("stringify_failed",{cause:err.cause})}}function readJson(path,sync=false){logger.logMethodArgs?.("readJson",{path:path.slice(-32),sync});if(sync===true){return parseJson(readFileSync(path))}else{return readFile(path).then(content=>parseJson(content))}}import{flatString as flatString2}from"@alwatr/flat-string";function writeJson(path,data,sync=false){logger.logMethodArgs?.("writeJson","..."+path.slice(-32));const content=flatString2(jsonStringify(data));return sync===true?writeFileSync(path,content):writeFile(path,content)}import{existsSync as existsSync2}from"node:fs";import{mkdir as mkdir2,open}from"node:fs/promises";import{dirname as dirname2}from"node:path";async function makeEmptyFile(path){logger.logMethodArgs?.("makeEmptyFile","..."+path.slice(-32));try{const pathExists=existsSync2(path);if(!pathExists){const dir=dirname2(path);if(!existsSync2(dir)){await mkdir2(dir,{recursive:true})}}await(await open(path,"w")).close()}catch(err){logger.error("makeEmptyFile","make_file_failed",{path},err);throw new Error("make_file_failed",{cause:err.cause})}}import{resolve}from"node:path";import{existsSync as existsSync3}from"node:fs";import{unlink}from"node:fs/promises";export{existsSync3 as existsSync,makeEmptyFile,readFile,readFileSync,readJson,resolve,unlink,writeFile,writeFileSync,writeJson};
3
- //# sourceMappingURL=main.mjs.map
package/dist/main.mjs.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/read-file.ts", "../src/common.ts", "../src/write-file.ts", "../src/json.ts", "../src/read-json.ts", "../src/write-json.ts", "../src/make-file.ts", "../src/main.ts"],
4
- "sourcesContent": ["import {readFileSync as readFileSync_} from 'node:fs';\nimport {readFile as readFile_} from 'node:fs/promises';\n\nimport {flatString} from '@alwatr/flat-string';\n\nimport {asyncQueue, logger} from './common.js';\n\n/**\n * Enhanced read File (Synchronous).\n *\n * @param path - file path\n * @returns file content\n * @example\n * ```typescript\n * const fileContent = readFileSync('./file.txt', sync);\n * ```\n */\nexport function readFileSync(path: string): string {\n logger.logMethodArgs?.('readFileSync', '...' + path.slice(-32));\n // if (!existsSync(path)) throw new Error('file_not_found');\n try {\n return flatString(readFileSync_(path, {encoding: 'utf-8', flag: 'r'}));\n }\n catch (err) {\n logger.error('readFileSync', 'read_file_failed', {path}, err);\n throw new Error('read_file_failed', {cause: (err as Error).cause});\n }\n}\n\n/**\n * Enhanced read File (Asynchronous).\n *\n * - If writing queue is running for target path, it will wait for it to finish.\n *\n * @param path - file path\n * @returns file content\n * @example\n * ```typescript\n * const fileContent = await readFile('./file.txt', sync);\n * ```\n */\nexport function readFile(path: string): Promise<string> {\n logger.logMethodArgs?.('readFile', '...' + path.slice(-32));\n // if (!existsSync(path)) throw new Error('file_not_found');\n return asyncQueue.push(path, async () => {\n try {\n return flatString(await readFile_(path, {encoding: 'utf-8', flag: 'r'}));\n }\n catch (err) {\n logger.error('readFile', 'read_file_failed', {path}, err);\n throw new Error('read_file_failed', {cause: (err as Error).cause});\n }\n });\n}\n", "import {AsyncQueue} from '@alwatr/async-queue';\nimport {createLogger} from '@alwatr/logger';\n\nimport type {} from '@alwatr/type-helper';\n\nexport const logger = createLogger('@alwatr/node-fs');\n\nexport const asyncQueue = new AsyncQueue();\n", "import {writeFileSync as writeFileSync_, existsSync, mkdirSync, renameSync} from 'node:fs';\nimport {mkdir, rename, writeFile as writeFile_} from 'node:fs/promises';\nimport {dirname} from 'node:path';\n\nimport {asyncQueue, logger} from './common.js';\n\n/**\n * Enhanced write file (Synchronous).\n *\n * - If directory not exists, create it recursively.\n * - Write file to `path.tmp` before write success.\n * - If file exists, renamed (keep) to `path.bak`.\n * - If write failed, original file will not be changed.\n *\n * @param path - file path\n * @param content - file content\n * @example\n * ```typescript\n * writeFileSync('./file.txt', 'Hello World!');\n * ```\n */\nexport function writeFileSync(path: string, content: Buffer | string): void {\n logger.logMethodArgs?.('writeFileSync', '...' + path.slice(-32));\n try {\n const pathExists = existsSync(path);\n if (!pathExists) {\n const dir = dirname(path);\n if (!existsSync(dir)) {\n mkdirSync(dir, {recursive: true});\n }\n }\n writeFileSync_(path + '.tmp', content, {encoding: 'utf-8', flag: 'w'});\n if (pathExists) {\n renameSync(path, path + '.bak');\n }\n renameSync(path + '.tmp', path);\n logger.logOther?.('writeFileSync success', '...' + path.slice(-32));\n }\n catch (err) {\n logger.error('writeFileSync', 'write_file_failed', {path}, err);\n throw new Error('write_file_failed', {cause: (err as Error).cause});\n }\n}\n\n/**\n * Enhanced write file (Asynchronous).\n *\n * - If directory not exists, create it recursively.\n * - Write file to `path.tmp` before write success.\n * - If file exists, renamed (keep) to `path.bak`.\n * - If write failed, original file will not be changed.\n *\n * @param path - file path\n * @param content - file content\n * @example\n * ```typescript\n * await writeFile('./file.txt', 'Hello World!');\n * ```\n */\nexport function writeFile(path: string, content: Buffer | string): Promise<void> {\n logger.logMethodArgs?.('writeFile', '...' + path.slice(-32));\n return asyncQueue.push(path, async () => {\n try {\n logger.logOther?.('writeFile start', '...' + path.slice(-32));\n const pathExists = existsSync(path);\n if (!pathExists) {\n const dir = dirname(path);\n if (!existsSync(dir)) {\n await mkdir(dir, {recursive: true});\n }\n }\n await writeFile_(path + '.tmp', content, {encoding: 'utf-8', flag: 'w'});\n if (pathExists) {\n await rename(path, path + '.bak');\n }\n await rename(path + '.tmp', path);\n logger.logOther?.('writeFile success', '...' + path.slice(-32));\n }\n catch (err) {\n logger.error('writeFile', 'write_file_failed', {path}, err);\n throw new Error('write_file_failed', {cause: (err as Error).cause});\n }\n });\n}\n", "import {logger} from './common.js';\n\n/**\n * Parse json string.\n *\n * @param content - json string\n * @returns json object\n * @example\n * ```typescript\n * const json = parseJson('{\"a\":1,\"b\":2}');\n * console.log(json.a); // 1\n * ```\n */\nexport function parseJson<T extends JsonValue>(content: string): T {\n try {\n return JSON.parse(content);\n }\n catch (err) {\n logger.error('parseJson', 'invalid_json', err);\n throw new Error('invalid_json', {cause: (err as Error).cause});\n }\n}\n\n/**\n * Stringify json object.\n *\n * @param data - json object\n * @returns json string\n * @example\n * ```typescript\n * const json = jsonStringify({a:1, b:2});\n * console.log(json); // '{\"a\":1,\"b\":2}'\n * ```\n */\nexport function jsonStringify<T extends JsonValue>(data: T): string {\n try {\n return JSON.stringify(data);\n }\n catch (err) {\n logger.error('jsonStringify', 'stringify_failed', err);\n throw new Error('stringify_failed', {cause: (err as Error).cause});\n }\n}\n", "import {logger} from './common.js';\nimport {parseJson} from './json.js';\nimport {readFile, readFileSync} from './read-file.js';\n\n/**\n * Enhanced read json file (async).\n *\n * @param path - file path\n * @returns json object\n * @example\n * ```typescript\n * const fileContent = await readJson('./file.json');\n * ```\n */\nexport function readJson<T extends JsonValue>(path: string): Promise<T>;\n/**\n * Enhanced read json file (sync).\n *\n * @param path - file path\n * @param sync - sync mode\n * @returns json object\n * @example\n * ```typescript\n * const fileContent = readJson('./file.json', true);\n * ```\n */\nexport function readJson<T extends JsonValue>(path: string, sync: true): T;\n/**\n * Enhanced read json file.\n *\n * @param path - file path\n * @param sync - sync mode\n * @returns json object\n * @example\n * ```typescript\n * const fileContent = await readJson('./file.json', sync);\n * ```\n */\nexport function readJson<T extends JsonValue>(path: string, sync: boolean): Awaitable<T>;\n/**\n * Enhanced read json file.\n *\n * @param path - file path\n * @param sync - sync mode\n * @returns json object\n * @example\n * ```typescript\n * const fileContent = await readJson('./file.json');\n * ```\n */\nexport function readJson<T extends JsonValue>(path: string, sync = false): Awaitable<T> {\n logger.logMethodArgs?.('readJson', {path: path.slice(-32), sync});\n if (sync === true) {\n return parseJson<T>(readFileSync(path));\n }\n else {\n return readFile(path).then((content) => parseJson<T>(content));\n }\n}\n", "import {flatString} from '@alwatr/flat-string';\n\nimport {logger} from './common.js';\nimport {jsonStringify} from './json.js';\nimport {writeFile, writeFileSync} from './write-file.js';\n\n/**\n * Enhanced write json file (Asynchronous).\n *\n * @param path - file path\n * @param data - json object\n * @example\n * ```typescript\n * await writeJsonFile('./file.json', { a:1, b:2, c:3 });\n * ```\n */\nexport function writeJson<T extends JsonValue>(path: string, data: T, sync?: false): Promise<void>;\n/**\n * Enhanced write json file (Synchronous).\n *\n * @param path - file path\n * @param data - json object\n * @param sync - sync mode\n * @example\n * ```typescript\n * writeJsonFile('./file.json', { a:1, b:2, c:3 }, true);\n * ```\n */\nexport function writeJson<T extends JsonValue>(path: string, data: T, sync: true): void;\n/**\n * Enhanced write json file.\n *\n * @param path - file path\n * @param data - json object\n * @param sync - sync mode\n * @example\n * ```typescript\n * await writeJsonFile('./file.json', { a:1, b:2, c:3 }, sync);\n * ```\n */\nexport function writeJson<T extends JsonValue>(path: string, data: T, sync: boolean): Awaitable<void>;\n/**\n * Enhanced write json file.\n *\n * @param path - file path\n * @param data - json object\n * @param sync - sync mode\n * @example\n * ```typescript\n * await writeJsonFile('./file.json', { a:1, b:2, c:3 });\n * ```\n */\nexport function writeJson<T extends JsonValue>(path: string, data: T, sync = false): Awaitable<void> {\n logger.logMethodArgs?.('writeJson', '...' + path.slice(-32));\n const content = flatString(jsonStringify(data));\n return sync === true ? writeFileSync(path, content) : writeFile(path, content);\n}\n", "import {existsSync} from 'node:fs';\nimport {mkdir, open} from 'node:fs/promises';\nimport {dirname} from 'node:path';\n\nimport {logger} from './common.js';\n\n/**\n * Make empty file.\n *\n * @param path - file path\n *\n * @example\n * ```ts\n * await makeFile('./dir/file.txt');\n * ```\n */\nexport async function makeEmptyFile(path: string): Promise<void> {\n logger.logMethodArgs?.('makeEmptyFile', '...' + path.slice(-32));\n try {\n const pathExists = existsSync(path);\n if (!pathExists) {\n const dir = dirname(path);\n if (!existsSync(dir)) {\n await mkdir(dir, {recursive: true});\n }\n }\n await (await open(path, 'w')).close();\n }\n catch (err) {\n logger.error('makeEmptyFile', 'make_file_failed', {path}, err);\n throw new Error('make_file_failed', {cause: (err as Error).cause});\n }\n}\n", "export * from './read-file.js';\nexport * from './write-file.js';\nexport * from './read-json.js';\nexport * from './write-json.js';\nexport * from './make-file.js';\n\nexport {resolve} from 'node:path';\nexport {existsSync} from 'node:fs';\nexport {unlink} from 'node:fs/promises';\n"],
5
- "mappings": ";AAAA,OAAQ,gBAAgB,kBAAoB,UAC5C,OAAQ,YAAY,cAAgB,mBAEpC,OAAQ,eAAiB,sBCHzB,OAAQ,eAAiB,sBACzB,OAAQ,iBAAmB,iBAIpB,IAAM,OAAS,aAAa,iBAAiB,EAE7C,IAAM,WAAa,IAAI,WDUvB,SAAS,aAAa,KAAsB,CACjD,OAAO,gBAAgB,eAAgB,MAAQ,KAAK,MAAM,GAAG,CAAC,EAE9D,GAAI,CACF,OAAO,WAAW,cAAc,KAAM,CAAC,SAAU,QAAS,KAAM,GAAG,CAAC,CAAC,CACvE,OACO,IAAK,CACV,OAAO,MAAM,eAAgB,mBAAoB,CAAC,IAAI,EAAG,GAAG,EAC5D,MAAM,IAAI,MAAM,mBAAoB,CAAC,MAAQ,IAAc,KAAK,CAAC,CACnE,CACF,CAcO,SAAS,SAAS,KAA+B,CACtD,OAAO,gBAAgB,WAAY,MAAQ,KAAK,MAAM,GAAG,CAAC,EAE1D,OAAO,WAAW,KAAK,KAAM,SAAY,CACvC,GAAI,CACF,OAAO,WAAW,MAAM,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