fs-target-file 1.0.21 → 1.0.24

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/CHANGELOG.md CHANGED
@@ -3,6 +3,44 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.0.24](https://github.com/bluelovers/ws-iconv/compare/fs-target-file@1.0.23...fs-target-file@1.0.24) (2026-03-01)
7
+
8
+ **Note:** Version bump only for package fs-target-file
9
+
10
+
11
+
12
+
13
+
14
+ ## [1.0.23](https://github.com/bluelovers/ws-iconv/compare/fs-target-file@1.0.22...fs-target-file@1.0.23) (2026-03-01)
15
+
16
+
17
+
18
+ ### 📚 Documentation
19
+
20
+ * 为多个包添加双语 README 和 JSDoc 注释 ([71544eb](https://github.com/bluelovers/ws-iconv/commit/71544eb1347aa061cb4ac71afc8d30e79f1ad3ad))
21
+
22
+
23
+ ### ♻️ Chores
24
+
25
+ * Update jest config and add new files for testing ([f370583](https://github.com/bluelovers/ws-iconv/commit/f37058385c7bf24d3d0bc975c752f2f35cfe8356))
26
+
27
+
28
+
29
+ ## [1.0.22](https://github.com/bluelovers/ws-iconv/compare/fs-target-file@1.0.21...fs-target-file@1.0.22) (2024-08-29)
30
+
31
+
32
+
33
+ ### 🛠 Build System
34
+
35
+ * update build ([263e72e](https://github.com/bluelovers/ws-iconv/commit/263e72e423867a305d52992f40543e2efd19a349))
36
+
37
+
38
+ ### 📌 Dependencies
39
+
40
+ * update deps ([dffc6e3](https://github.com/bluelovers/ws-iconv/commit/dffc6e313e4017a32d608bd0dad6ef6faaf761a3))
41
+
42
+
43
+
6
44
  ## [1.0.21](https://github.com/bluelovers/ws-iconv/compare/fs-target-file@1.0.20...fs-target-file@1.0.21) (2022-10-16)
7
45
 
8
46
 
package/README.md CHANGED
@@ -1,8 +1,16 @@
1
- # README.md
1
+ # fs-target-file - 檔案目標處理工具
2
2
 
3
+ 這個模組提供了檔案目標處理的功能,支援讀取和寫入操作,並可以指定輸入和輸出檔案。
3
4
 
5
+ ## 主要功能
4
6
 
5
- ## install
7
+ - 檔案目標處理
8
+ - 讀取和寫入操作
9
+ - 支援 JSON 檔案
10
+ - 輸入和輸出檔案指定
11
+ - 異步處理
12
+
13
+ ## 安裝
6
14
 
7
15
  ```bash
8
16
  yarn add fs-target-file
@@ -10,3 +18,5 @@ yarn-tool add fs-target-file
10
18
  yt add fs-target-file
11
19
  ```
12
20
 
21
+ ## 快速開始
22
+
package/index.d.ts CHANGED
@@ -9,7 +9,7 @@ export interface IFileMethodAsyncOptions<RO = ReadOptions, WO = WriteOptions, D
9
9
  }
10
10
  export declare function fsFileMethodAsync<RO = ReadOptions, WO = WriteOptions, D = unknown, N = string>(options?: IFileMethodAsyncOptions<RO, WO, D, N>): {
11
11
  read: (<T = D>(file: N, options?: RO) => Promise<T>) | ((file: any, options: any) => Promise<any>);
12
- write: <T_1 = D>(file: N, data: ITSResolvable<T_1>, options?: RO) => Promise<any>;
12
+ write: <T = D>(file: N, data: ITSResolvable<T>, options?: RO) => Promise<any>;
13
13
  };
14
14
  export interface ITargetFileOptions<N = string> {
15
15
  inputFile: N;
@@ -20,7 +20,7 @@ export declare function fsTargetFile<D = unknown, RO = ReadOptions, WO = WriteOp
20
20
  readonly inputFile: N;
21
21
  readonly outputFile: N;
22
22
  read<T = D>(options?: RO): Promise<T>;
23
- write<T_1 extends D = D>(data: T_1, options?: RO): Promise<unknown>;
23
+ write<T extends D = D>(data: T, options?: RO): Promise<unknown>;
24
24
  async(): Promise<any>;
25
25
  };
26
26
  export default fsTargetFile;
package/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fsTargetFile = exports.toTargetFileOptions = exports.fsFileMethodAsync = void 0;
3
+ exports.fsFileMethodAsync = fsFileMethodAsync;
4
+ exports.toTargetFileOptions = toTargetFileOptions;
5
+ exports.fsTargetFile = fsTargetFile;
4
6
  const fs_extra_1 = require("fs-extra");
5
7
  function fsFileMethodAsync(options) {
6
8
  options !== null && options !== void 0 ? options : (options = {});
@@ -19,7 +21,6 @@ function fsFileMethodAsync(options) {
19
21
  write,
20
22
  };
21
23
  }
22
- exports.fsFileMethodAsync = fsFileMethodAsync;
23
24
  function toTargetFileOptions(targetOptions) {
24
25
  var _a;
25
26
  let inputFile;
@@ -39,7 +40,6 @@ function toTargetFileOptions(targetOptions) {
39
40
  outputFile,
40
41
  };
41
42
  }
42
- exports.toTargetFileOptions = toTargetFileOptions;
43
43
  function fsTargetFile(targetOptions, options) {
44
44
  const { read, write } = fsFileMethodAsync(options);
45
45
  const { inputFile, outputFile } = toTargetFileOptions(targetOptions);
@@ -62,6 +62,5 @@ function fsTargetFile(targetOptions, options) {
62
62
  };
63
63
  return target;
64
64
  }
65
- exports.fsTargetFile = fsTargetFile;
66
65
  exports.default = fsTargetFile;
67
66
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fs-target-file",
3
- "version": "1.0.21",
3
+ "version": "1.0.24",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/bluelovers/ws-iconv/tree/master/packages/fs-target-file#readme",
6
6
  "bugs": {
@@ -15,9 +15,11 @@
15
15
  "author": "bluelovers",
16
16
  "main": "index.js",
17
17
  "scripts": {
18
+ "coverage": "yarn run test -- --coverage",
18
19
  "lint": "ynpx --quiet eslint -- **/*.ts",
19
20
  "test": "echo \"Error: no test specified\"",
20
21
  "test:jest": "ynpx --quiet jest -- --coverage --passWithNoTests",
22
+ "test:jest:coverage": "yarn run test:jest -- --coverage",
21
23
  "test:jest:snapshot": "yarn run test:jest -- -u",
22
24
  "test:mocha": "ynpx --quiet -p ts-node -p mocha mocha -- --require ts-node/register \"!(node_modules)/**/*.{test,spec}.{ts,tsx}\"",
23
25
  "test:snapshot": "yarn run test -- -u",
@@ -27,15 +29,16 @@
27
29
  "prepublishOnly:check-bin": "ynpx --quiet @yarn-tool/check-pkg-bin",
28
30
  "prepublishOnly:update": "yarn run ncu && yarn run sort-package-json",
29
31
  "ncu": "yarn-tool ncu -u",
30
- "sort-package-json": "yarn-tool sort"
32
+ "sort-package-json": "yarn-tool sort",
33
+ "tsc:showConfig": "ynpx get-current-tsconfig -p"
31
34
  },
32
35
  "dependencies": {
33
- "fs-extra": "^10.1.0",
36
+ "fs-extra": "^11.2.0",
34
37
  "ts-type": "^3.0.1",
35
38
  "tslib": "^2"
36
39
  },
37
40
  "devDependencies": {
38
- "@types/fs-extra": "^9"
41
+ "@types/fs-extra": "^11"
39
42
  },
40
- "gitHead": "c0b9fe1181976f749a069a0eda79eebebccb52cb"
43
+ "gitHead": "6bcfe6a585ad7e5657a40a5b0727c6281b564b60"
41
44
  }
package/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,uCAA2E;AAa3E,SAAgB,iBAAiB,CAA+D,OAA+C;IAE9I,OAAO,aAAP,OAAO,cAAP,OAAO,IAAP,OAAO,GAAK,EAAE,EAAC;IAEf,MAAM,EACL,WAAW,EACX,YAAY,GAAG;QACd,MAAM,EAAE,CAAC;KACT,GACD,GAAG,OAAO,CAAC;IAEZ,MAAM,EACL,IAAI,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,IAAA,mBAAQ,EAAC,IAAI,EAAE;QACxC,GAAG,WAAW;QACd,GAAG,OAAO;KACV,CAAC,EACF,KAAK,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,IAAA,qBAAU,EAAC,IAAI,EAAE,IAAI,EAAE;QACvD,GAAG,YAAY;QACf,GAAG,OAAO;KACV,CAAC,GACF,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC;IAElB,OAAO;QACN,IAAI;QACJ,KAAK;KACL,CAAA;AACF,C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lib/generic';\nimport { ITSRequiredPick } from 'ts-type/lib/type/record';\n\nexport interface IFileMethodAsyncOptions<RO = ReadOptions, WO = WriteOptions, D = unknown, N = string>\n{\n\tread?<T = D>(file: N, options?: RO): Promise<T>,\n\twrite?<T = D>(file: N, data: ITSResolvable<T>, options?: RO): Promise<any>,\n\n\treadOptions?: RO,\n\twriteOptions?: WO,\n}\n\nexport function fsFileMethodAsync<RO = ReadOptions, WO = WriteOptions, D = unknown, N = string>(options?: IFileMethodAsyncOptions<RO, WO, D, N>)\n{\n\toptions ??= {};\n\n\tconst {\n\t\treadOptions,\n\t\twriteOptions = {\n\t\t\tspaces: 2,\n\t\t},\n\t} = options;\n\n\tconst {\n\t\tread = (file, options) => readJSON(file, {\n\t\t\t...readOptions,\n\t\t\t...options,\n\t\t}),\n\t\twrite = (file, data, options) => outputJSON(file, data, {\n\t\t\t...writeOptions,\n\t\t\t...options,\n\t\t}),\n\t} = options ?? {};\n\n\treturn {\n\t\tread,\n\t\twrite,\n\t}\n}\n\nexport interface ITargetFileOptions<N = string>\n{\n\tinputFile: N,\n\toutputFile?: N,\n}\n\nexport function toTargetFileOptions<N = string>(targetOptions: N | ITargetFileOptions<N>): ITSRequiredPick<ITargetFileOptions<N>>\n{\n\tlet inputFile: N;\n\tlet outputFile: N;\n\n\t// @ts-ignore\n\tif (typeof targetOptions?.inputFile !== 'undefined')\n\t{\n\t\t// @ts-ignore\n\t\tinputFile = targetOptions.inputFile;\n\t\t// @ts-ignore\n\t\toutputFile = targetOptions.outputFile ?? inputFile;\n\t}\n\telse\n\t{\n\t\tinputFile = outputFile = targetOptions as N;\n\t}\n\n\treturn {\n\t\tinputFile,\n\t\toutputFile,\n\t}\n}\n\nexport function fsTargetFile<D = unknown, RO = ReadOptions, WO = WriteOptions, N = string>(targetOptions: N | ITargetFileOptions<N>, options?: IFileMethodAsyncOptions<RO, WO, D, N>)\n{\n\tconst { read, write } = fsFileMethodAsync<RO, WO, D, N>(options);\n\n\tconst { inputFile, outputFile } = toTargetFileOptions(targetOptions);\n\n\tconst target = {\n\n\t\tget inputFile()\n\t\t{\n\t\t\treturn inputFile\n\t\t},\n\n\t\tget outputFile()\n\t\t{\n\t\t\treturn outputFile\n\t\t},\n\n\t\tread<T = D>(options?: RO): Promise<T>\n\t\t{\n\t\t\treturn read(inputFile, options)\n\t\t},\n\n\t\twrite<T extends D = D>(data: T, options?: RO): Promise<unknown>\n\t\t{\n\t\t\treturn write(outputFile, data, options)\n\t\t},\n\n\t\tasync async()\n\t\t{\n\t\t\treturn target\n\t\t}\n\n\t};\n\n\treturn target\n\n}\n\nexport default fsTargetFile\n"]}