@ainc/fs 0.1.12 → 0.1.16

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.
Files changed (187) hide show
  1. package/README.md +1 -0
  2. package/dist/basename.d.ts +6 -6
  3. package/dist/basename.js +16 -16
  4. package/dist/copy.d.ts +40 -40
  5. package/dist/copy.js +89 -89
  6. package/dist/copy.js.map +1 -1
  7. package/dist/cpdir.d.ts +19 -19
  8. package/dist/cpdir.js +28 -28
  9. package/dist/cpdir.js.map +1 -1
  10. package/dist/cwd.d.ts +6 -6
  11. package/dist/cwd.js +16 -16
  12. package/dist/dirname.d.ts +6 -6
  13. package/dist/dirname.js +30 -30
  14. package/dist/extname.d.ts +6 -6
  15. package/dist/extname.js +16 -16
  16. package/dist/filename.d.ts +6 -6
  17. package/dist/filename.js +24 -24
  18. package/dist/find.d.ts +26 -26
  19. package/dist/find.js +72 -72
  20. package/dist/find.js.map +1 -1
  21. package/dist/findFile.d.ts +20 -20
  22. package/dist/findFile.js +39 -39
  23. package/dist/findFile.js.map +1 -1
  24. package/dist/finddir.d.ts +20 -20
  25. package/dist/finddir.js +39 -39
  26. package/dist/finddir.js.map +1 -1
  27. package/dist/helpers/FileResolver.d.ts +54 -0
  28. package/dist/helpers/FileResolver.d.ts.map +1 -0
  29. package/dist/helpers/FileResolver.js +184 -0
  30. package/dist/helpers/FileResolver.js.map +1 -0
  31. package/dist/helpers/compose.d.ts +14 -0
  32. package/dist/helpers/compose.d.ts.map +1 -0
  33. package/dist/helpers/compose.js +38 -0
  34. package/dist/helpers/compose.js.map +1 -0
  35. package/dist/helpers/each.d.ts +7 -0
  36. package/dist/helpers/each.d.ts.map +1 -0
  37. package/dist/helpers/each.js +21 -0
  38. package/dist/helpers/each.js.map +1 -0
  39. package/dist/helpers/match.d.ts +7 -0
  40. package/dist/helpers/match.d.ts.map +1 -0
  41. package/dist/helpers/match.js +30 -0
  42. package/dist/helpers/match.js.map +1 -0
  43. package/dist/helpers/normalizePath.d.ts +23 -0
  44. package/dist/helpers/normalizePath.d.ts.map +1 -0
  45. package/dist/helpers/normalizePath.js +37 -0
  46. package/dist/helpers/normalizePath.js.map +1 -0
  47. package/dist/helpers/safeCall.d.ts +7 -0
  48. package/dist/helpers/safeCall.d.ts.map +1 -0
  49. package/dist/helpers/safeCall.js +24 -0
  50. package/dist/helpers/safeCall.js.map +1 -0
  51. package/dist/helpers/split.d.ts +7 -0
  52. package/dist/helpers/split.d.ts.map +1 -0
  53. package/dist/helpers/split.js +25 -0
  54. package/dist/helpers/split.js.map +1 -0
  55. package/dist/helpers/stripBOM.d.ts +7 -0
  56. package/dist/helpers/stripBOM.d.ts.map +1 -0
  57. package/dist/helpers/stripBOM.js +19 -0
  58. package/dist/helpers/stripBOM.js.map +1 -0
  59. package/dist/helpers/stripComments.d.ts +7 -0
  60. package/dist/helpers/stripComments.d.ts.map +1 -0
  61. package/dist/{normalizeJSON.js → helpers/stripComments.js} +147 -145
  62. package/dist/helpers/stripComments.js.map +1 -0
  63. package/dist/homedir.d.ts +6 -6
  64. package/dist/homedir.js +31 -31
  65. package/dist/includePaths.d.ts +6 -6
  66. package/dist/includePaths.js +53 -53
  67. package/dist/includePaths.js.map +1 -1
  68. package/dist/index.d.ts +43 -44
  69. package/dist/index.d.ts.map +1 -1
  70. package/dist/index.js +90 -92
  71. package/dist/index.js.map +1 -1
  72. package/dist/indir.d.ts +13 -13
  73. package/dist/indir.js +26 -26
  74. package/dist/isAbsolutePath.d.ts +6 -6
  75. package/dist/isAbsolutePath.js +24 -24
  76. package/dist/isDirectory.d.ts +12 -12
  77. package/dist/isDirectory.js +26 -26
  78. package/dist/isDirectory.js.map +1 -1
  79. package/dist/isRelativePath.d.ts +6 -6
  80. package/dist/isRelativePath.js +44 -44
  81. package/dist/json.d.ts +21 -21
  82. package/dist/json.d.ts.map +1 -1
  83. package/dist/json.js +34 -33
  84. package/dist/json.js.map +1 -1
  85. package/dist/jsonc.d.ts +27 -21
  86. package/dist/jsonc.d.ts.map +1 -1
  87. package/dist/jsonc.js +49 -40
  88. package/dist/jsonc.js.map +1 -1
  89. package/dist/lstat.d.ts +22 -22
  90. package/dist/lstat.js +30 -30
  91. package/dist/mapdir.d.ts +22 -22
  92. package/dist/mapdir.js +42 -42
  93. package/dist/mapdir.js.map +1 -1
  94. package/dist/mkdir.d.ts +6 -6
  95. package/dist/mkdir.js +37 -37
  96. package/dist/mkdir.js.map +1 -1
  97. package/dist/parseJSON.d.ts +16 -0
  98. package/dist/parseJSON.d.ts.map +1 -0
  99. package/dist/parseJSON.js +29 -0
  100. package/dist/parseJSON.js.map +1 -0
  101. package/dist/readFile.d.ts +29 -29
  102. package/dist/readFile.js +26 -26
  103. package/dist/readFile.js.map +1 -1
  104. package/dist/readStream.d.ts +36 -36
  105. package/dist/readStream.d.ts.map +1 -1
  106. package/dist/readStream.js +19 -19
  107. package/dist/readStream.js.map +1 -1
  108. package/dist/readdir.d.ts +16 -16
  109. package/dist/readdir.js +34 -34
  110. package/dist/readdir.js.map +1 -1
  111. package/dist/readline.d.ts +16 -16
  112. package/dist/readline.d.ts.map +1 -1
  113. package/dist/readline.js +24 -24
  114. package/dist/readline.js.map +1 -1
  115. package/dist/realpath.d.ts +12 -12
  116. package/dist/realpath.js +32 -32
  117. package/dist/realpath.js.map +1 -1
  118. package/dist/relative.d.ts +6 -6
  119. package/dist/relative.js +38 -38
  120. package/dist/resolve.d.ts +26 -26
  121. package/dist/resolve.js +53 -53
  122. package/dist/resolve.js.map +1 -1
  123. package/dist/resolvePath.d.ts +27 -0
  124. package/dist/resolvePath.d.ts.map +1 -0
  125. package/dist/resolvePath.js +178 -0
  126. package/dist/resolvePath.js.map +1 -0
  127. package/dist/rmdir.d.ts +6 -6
  128. package/dist/rmdir.js +40 -40
  129. package/dist/rmdir.js.map +1 -1
  130. package/dist/stat.d.ts +21 -21
  131. package/dist/stat.js +30 -30
  132. package/dist/supdir.d.ts +21 -15
  133. package/dist/supdir.d.ts.map +1 -1
  134. package/dist/supdir.js +62 -35
  135. package/dist/supdir.js.map +1 -1
  136. package/dist/symlink.d.ts +22 -22
  137. package/dist/symlink.js +39 -39
  138. package/dist/symlink.js.map +1 -1
  139. package/dist/unlink.d.ts +6 -6
  140. package/dist/unlink.js +28 -28
  141. package/dist/unlink.js.map +1 -1
  142. package/dist/usedir.d.ts +6 -6
  143. package/dist/usedir.js +24 -24
  144. package/dist/writeFile.d.ts +33 -33
  145. package/dist/writeFile.js +49 -49
  146. package/dist/writeFile.js.map +1 -1
  147. package/dist/writeStream.d.ts +35 -35
  148. package/dist/writeStream.d.ts.map +1 -1
  149. package/dist/writeStream.js +19 -19
  150. package/dist/writeStream.js.map +1 -1
  151. package/package.json +4 -4
  152. package/src/helpers/FileResolver.ts +282 -0
  153. package/src/helpers/compose.ts +49 -0
  154. package/src/helpers/each.ts +19 -0
  155. package/src/helpers/match.ts +31 -0
  156. package/src/helpers/normalizePath.ts +51 -0
  157. package/src/helpers/safeCall.ts +21 -0
  158. package/src/helpers/split.ts +25 -0
  159. package/src/helpers/stripBOM.ts +17 -0
  160. package/src/{normalizeJSON.ts → helpers/stripComments.ts} +58 -52
  161. package/src/index.ts +2 -3
  162. package/src/json.ts +2 -1
  163. package/src/jsonc.ts +22 -11
  164. package/src/parseJSON.ts +40 -0
  165. package/src/readStream.ts +2 -2
  166. package/src/readline.ts +2 -2
  167. package/src/resolvePath.ts +234 -0
  168. package/src/supdir.ts +31 -0
  169. package/src/writeStream.ts +2 -2
  170. package/dist/normalizeJSON.d.ts +0 -7
  171. package/dist/normalizeJSON.d.ts.map +0 -1
  172. package/dist/normalizeJSON.js.map +0 -1
  173. package/dist/resolveFile.d.ts +0 -22
  174. package/dist/resolveFile.d.ts.map +0 -1
  175. package/dist/resolveFile.js +0 -80
  176. package/dist/resolveFile.js.map +0 -1
  177. package/dist/resolveModule.d.ts +0 -41
  178. package/dist/resolveModule.d.ts.map +0 -1
  179. package/dist/resolveModule.js +0 -119
  180. package/dist/resolveModule.js.map +0 -1
  181. package/dist/resolvePaths.d.ts +0 -22
  182. package/dist/resolvePaths.d.ts.map +0 -1
  183. package/dist/resolvePaths.js +0 -233
  184. package/dist/resolvePaths.js.map +0 -1
  185. package/src/resolveFile.ts +0 -103
  186. package/src/resolveModule.ts +0 -157
  187. package/src/resolvePaths.ts +0 -320
@@ -1,30 +1,30 @@
1
- /**
2
- *****************************************
3
- * 编码类型
4
- *****************************************
5
- */
6
- declare type Encoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'latin1' | 'binary' | 'hex';
7
- /**
8
- *****************************************
9
- * 配置
10
- *****************************************
11
- */
12
- interface Options {
13
- encoding?: Encoding;
14
- flag?: string;
15
- }
16
- /**
17
- *****************************************
18
- * 读取文件
19
- *****************************************
20
- */
21
- declare function readFile(path: string): string;
22
- declare function readFile(path: string, encoding: Encoding): string;
23
- declare function readFile(path: string, options: Options): string;
24
- /**
25
- *****************************************
26
- *
27
- *****************************************
28
- */
29
- export { readFile };
1
+ /**
2
+ *****************************************
3
+ * 编码类型
4
+ *****************************************
5
+ */
6
+ declare type Encoding = 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'ucs2' | 'ucs-2' | 'base64' | 'latin1' | 'binary' | 'hex';
7
+ /**
8
+ *****************************************
9
+ * 配置
10
+ *****************************************
11
+ */
12
+ interface Options {
13
+ encoding?: Encoding;
14
+ flag?: string;
15
+ }
16
+ /**
17
+ *****************************************
18
+ * 读取文件
19
+ *****************************************
20
+ */
21
+ declare function readFile(path: string): string;
22
+ declare function readFile(path: string, encoding: Encoding): string;
23
+ declare function readFile(path: string, options: Options): string;
24
+ /**
25
+ *****************************************
26
+ *
27
+ *****************************************
28
+ */
29
+ export { readFile };
30
30
  //# sourceMappingURL=readFile.d.ts.map
package/dist/readFile.js CHANGED
@@ -1,27 +1,27 @@
1
- /**
2
- *****************************************
3
- * Created by edonet@163.com
4
- * Created on 2019-11-07 16:27:01
5
- *****************************************
6
- */
7
- 'use strict';
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.readFile = void 0;
10
- /**
11
- *****************************************
12
- * 加载依赖
13
- *****************************************
14
- */
15
- const fs = require("fs");
16
- const stat_1 = require("./stat");
17
- function readFile(path, encoding) {
18
- let stats = stat_1.stat(path);
19
- // 存在文件
20
- if (stats && !stats.isDirectory()) {
21
- return fs.readFileSync(path, encoding || 'utf8');
22
- }
23
- // 返回空
24
- return '';
25
- }
26
- exports.readFile = readFile;
1
+ /**
2
+ *****************************************
3
+ * Created by edonet@163.com
4
+ * Created on 2019-11-07 16:27:01
5
+ *****************************************
6
+ */
7
+ 'use strict';
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.readFile = void 0;
10
+ /**
11
+ *****************************************
12
+ * 加载依赖
13
+ *****************************************
14
+ */
15
+ const fs = require("fs");
16
+ const stat_1 = require("./stat");
17
+ function readFile(path, encoding) {
18
+ let stats = (0, stat_1.stat)(path);
19
+ // 存在文件
20
+ if (stats && !stats.isDirectory()) {
21
+ return fs.readFileSync(path, encoding || 'utf8');
22
+ }
23
+ // 返回空
24
+ return '';
25
+ }
26
+ exports.readFile = readFile;
27
27
  //# sourceMappingURL=readFile.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"readFile.js","sourceRoot":"","sources":["../src/readFile.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,YAAY,CAAC;;;AAGb;;;;GAIG;AACH,yBAAyB;AACzB,iCAA8B;AA8B9B,SAAS,QAAQ,CAAC,IAAY,EAAE,QAA6B;IACzD,IAAI,KAAK,GAAG,WAAI,CAAC,IAAI,CAAC,CAAC;IAEvB,OAAO;IACP,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE;QAC/B,OAAO,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,QAAoB,IAAI,MAAM,CAAC,CAAC;KAChE;IAED,MAAM;IACN,OAAO,EAAE,CAAC;AACd,CAAC;AAQQ,4BAAQ"}
1
+ {"version":3,"file":"readFile.js","sourceRoot":"","sources":["../src/readFile.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,YAAY,CAAC;;;AAGb;;;;GAIG;AACH,yBAAyB;AACzB,iCAA8B;AA8B9B,SAAS,QAAQ,CAAC,IAAY,EAAE,QAA6B;IACzD,IAAI,KAAK,GAAG,IAAA,WAAI,EAAC,IAAI,CAAC,CAAC;IAEvB,OAAO;IACP,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE;QAC/B,OAAO,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,QAAoB,IAAI,MAAM,CAAC,CAAC;KAChE;IAED,MAAM;IACN,OAAO,EAAE,CAAC;AACd,CAAC;AAQQ,4BAAQ"}
@@ -1,37 +1,37 @@
1
- /// <reference types="node" />
2
- /**
3
- *****************************************
4
- * 加载依赖
5
- *****************************************
6
- */
7
- import * as fs from 'fs';
8
- /**
9
- *****************************************
10
- * 配置
11
- *****************************************
12
- */
13
- export interface Options {
14
- flags?: string | undefined;
15
- encoding?: BufferEncoding | undefined;
16
- fd?: number | undefined;
17
- mode?: number | undefined;
18
- autoClose?: boolean | undefined;
19
- emitClose?: boolean | undefined;
20
- start?: number | undefined;
21
- end?: number | undefined;
22
- highWaterMark?: number | undefined;
23
- }
24
- /**
25
- *****************************************
26
- * 创建可读流
27
- *****************************************
28
- */
29
- declare function readStream(path: string, encoding?: string): fs.ReadStream;
30
- declare function readStream(path: string, options?: Options): fs.ReadStream;
31
- /**
32
- *****************************************
33
- * 抛出接口
34
- *****************************************
35
- */
36
- export { readStream };
1
+ /// <reference types="node" />
2
+ /**
3
+ *****************************************
4
+ * 加载依赖
5
+ *****************************************
6
+ */
7
+ import * as fs from 'fs';
8
+ /**
9
+ *****************************************
10
+ * 配置
11
+ *****************************************
12
+ */
13
+ export interface Options {
14
+ flags?: string | undefined;
15
+ encoding?: BufferEncoding | undefined;
16
+ fd?: number | undefined;
17
+ mode?: number | undefined;
18
+ autoClose?: boolean | undefined;
19
+ emitClose?: boolean | undefined;
20
+ start?: number | undefined;
21
+ end?: number | undefined;
22
+ highWaterMark?: number | undefined;
23
+ }
24
+ /**
25
+ *****************************************
26
+ * 创建可读流
27
+ *****************************************
28
+ */
29
+ declare function readStream(path: string, encoding?: BufferEncoding): fs.ReadStream;
30
+ declare function readStream(path: string, options?: Options): fs.ReadStream;
31
+ /**
32
+ *****************************************
33
+ * 抛出接口
34
+ *****************************************
35
+ */
36
+ export { readStream };
37
37
  //# sourceMappingURL=readStream.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"readStream.d.ts","sourceRoot":"","sources":["../src/readStream.ts"],"names":[],"mappings":";AASA;;;;GAIG;AACH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAGzB;;;;GAIG;AACH,MAAM,WAAW,OAAO;IACpB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,QAAQ,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;IACtC,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAGD;;;;GAIG;AACH,iBAAS,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,UAAU,CAAC;AACpE,iBAAS,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC;AAMpE;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,CAAC"}
1
+ {"version":3,"file":"readStream.d.ts","sourceRoot":"","sources":["../src/readStream.ts"],"names":[],"mappings":";AASA;;;;GAIG;AACH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAGzB;;;;GAIG;AACH,MAAM,WAAW,OAAO;IACpB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,QAAQ,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;IACtC,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAGD;;;;GAIG;AACH,iBAAS,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,EAAE,CAAC,UAAU,CAAC;AAC5E,iBAAS,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC;AAMpE;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -1,20 +1,20 @@
1
- /**
2
- *****************************************
3
- * Created by edonet@163.com
4
- * Created on 2021-05-22 11:41:18
5
- *****************************************
6
- */
7
- 'use strict';
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.readStream = void 0;
10
- /**
11
- *****************************************
12
- * 加载依赖
13
- *****************************************
14
- */
15
- const fs = require("fs");
16
- function readStream(path, options) {
17
- return fs.createReadStream(path, options);
18
- }
19
- exports.readStream = readStream;
1
+ /**
2
+ *****************************************
3
+ * Created by edonet@163.com
4
+ * Created on 2021-05-22 11:41:18
5
+ *****************************************
6
+ */
7
+ 'use strict';
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.readStream = void 0;
10
+ /**
11
+ *****************************************
12
+ * 加载依赖
13
+ *****************************************
14
+ */
15
+ const fs = require("fs");
16
+ function readStream(path, options) {
17
+ return fs.createReadStream(path, options);
18
+ }
19
+ exports.readStream = readStream;
20
20
  //# sourceMappingURL=readStream.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"readStream.js","sourceRoot":"","sources":["../src/readStream.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,YAAY,CAAC;;;AAGb;;;;GAIG;AACH,yBAAyB;AA4BzB,SAAS,UAAU,CAAC,IAAY,EAAE,OAA0B;IACxD,OAAO,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAQQ,gCAAU"}
1
+ {"version":3,"file":"readStream.js","sourceRoot":"","sources":["../src/readStream.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,YAAY,CAAC;;;AAGb;;;;GAIG;AACH,yBAAyB;AA4BzB,SAAS,UAAU,CAAC,IAAY,EAAE,OAAkC;IAChE,OAAO,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAQQ,gCAAU"}
package/dist/readdir.d.ts CHANGED
@@ -1,17 +1,17 @@
1
- /**
2
- *****************************************
3
- * 状态
4
- *****************************************
5
- */
6
- interface State {
7
- name: string;
8
- path: string;
9
- }
10
- /**
11
- *****************************************
12
- * 读取目录
13
- *****************************************
14
- */
15
- export declare function readdir(dir: string): State[];
16
- export {};
1
+ /**
2
+ *****************************************
3
+ * 状态
4
+ *****************************************
5
+ */
6
+ interface State {
7
+ name: string;
8
+ path: string;
9
+ }
10
+ /**
11
+ *****************************************
12
+ * 读取目录
13
+ *****************************************
14
+ */
15
+ export declare function readdir(dir: string): State[];
16
+ export {};
17
17
  //# sourceMappingURL=readdir.d.ts.map
package/dist/readdir.js CHANGED
@@ -1,35 +1,35 @@
1
- /**
2
- *****************************************
3
- * Created by edonet@163.com
4
- * Created on 2019-11-07 16:20:26
5
- *****************************************
6
- */
7
- 'use strict';
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.readdir = void 0;
10
- /**
11
- *****************************************
12
- * 加载依赖
13
- *****************************************
14
- */
15
- const fs = require("fs");
16
- const path = require("path");
17
- const isDirectory_1 = require("./isDirectory");
18
- /**
19
- *****************************************
20
- * 读取目录
21
- *****************************************
22
- */
23
- function readdir(dir) {
24
- let stats = isDirectory_1.isDirectory(dir);
25
- // 存在目录
26
- if (stats) {
27
- dir = stats.path;
28
- // 读取文件夹
29
- return fs.readdirSync(dir).map(name => ({ name, path: path.join(dir, name) }));
30
- }
31
- // 返回对象
32
- return [];
33
- }
34
- exports.readdir = readdir;
1
+ /**
2
+ *****************************************
3
+ * Created by edonet@163.com
4
+ * Created on 2019-11-07 16:20:26
5
+ *****************************************
6
+ */
7
+ 'use strict';
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.readdir = void 0;
10
+ /**
11
+ *****************************************
12
+ * 加载依赖
13
+ *****************************************
14
+ */
15
+ const fs = require("fs");
16
+ const path = require("path");
17
+ const isDirectory_1 = require("./isDirectory");
18
+ /**
19
+ *****************************************
20
+ * 读取目录
21
+ *****************************************
22
+ */
23
+ function readdir(dir) {
24
+ let stats = (0, isDirectory_1.isDirectory)(dir);
25
+ // 存在目录
26
+ if (stats) {
27
+ dir = stats.path;
28
+ // 读取文件夹
29
+ return fs.readdirSync(dir).map(name => ({ name, path: path.join(dir, name) }));
30
+ }
31
+ // 返回对象
32
+ return [];
33
+ }
34
+ exports.readdir = readdir;
35
35
  //# sourceMappingURL=readdir.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"readdir.js","sourceRoot":"","sources":["../src/readdir.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,YAAY,CAAC;;;AAGb;;;;GAIG;AACH,yBAAyB;AACzB,6BAA6B;AAC7B,+CAA4C;AAc5C;;;;GAIG;AACH,SAAgB,OAAO,CAAC,GAAW;IAC/B,IAAI,KAAK,GAAG,yBAAW,CAAC,GAAG,CAAC,CAAC;IAE7B,OAAO;IACP,IAAI,KAAK,EAAE;QACP,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC;QAEjB,QAAQ;QACR,OAAO,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,CAC1B,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC,CACjD,CAAC;KACL;IAED,OAAO;IACP,OAAO,EAAE,CAAC;AACd,CAAC;AAfD,0BAeC"}
1
+ {"version":3,"file":"readdir.js","sourceRoot":"","sources":["../src/readdir.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,YAAY,CAAC;;;AAGb;;;;GAIG;AACH,yBAAyB;AACzB,6BAA6B;AAC7B,+CAA4C;AAc5C;;;;GAIG;AACH,SAAgB,OAAO,CAAC,GAAW;IAC/B,IAAI,KAAK,GAAG,IAAA,yBAAW,EAAC,GAAG,CAAC,CAAC;IAE7B,OAAO;IACP,IAAI,KAAK,EAAE;QACP,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC;QAEjB,QAAQ;QACR,OAAO,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,CAC1B,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC,CACjD,CAAC;KACL;IAED,OAAO;IACP,OAAO,EAAE,CAAC;AACd,CAAC;AAfD,0BAeC"}
@@ -1,17 +1,17 @@
1
- /// <reference types="node" />
2
- import { Readable } from 'stream';
3
- import { Options } from './readStream';
4
- /**
5
- *****************************************
6
- * 逐行读取
7
- *****************************************
8
- */
9
- declare function readline(path: string, encoding?: string): Readable;
10
- declare function readline(path: string, options?: Options): Readable;
11
- /**
12
- *****************************************
13
- * 抛出接口
14
- *****************************************
15
- */
16
- export { readline };
1
+ /// <reference types="node" />
2
+ import { Readable } from 'stream';
3
+ import { Options } from './readStream';
4
+ /**
5
+ *****************************************
6
+ * 逐行读取
7
+ *****************************************
8
+ */
9
+ declare function readline(path: string, encoding?: BufferEncoding): Readable;
10
+ declare function readline(path: string, options?: Options): Readable;
11
+ /**
12
+ *****************************************
13
+ * 抛出接口
14
+ *****************************************
15
+ */
16
+ export { readline };
17
17
  //# sourceMappingURL=readline.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"readline.d.ts","sourceRoot":"","sources":["../src/readline.ts"],"names":[],"mappings":";AAeA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC;;;;GAIG;AACH,iBAAS,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;AAC7D,iBAAS,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;AAU7D;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAE,CAAC"}
1
+ {"version":3,"file":"readline.d.ts","sourceRoot":"","sources":["../src/readline.ts"],"names":[],"mappings":";AAeA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC;;;;GAIG;AACH,iBAAS,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,QAAQ,CAAC;AACrE,iBAAS,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;AAU7D;;;;GAIG;AACH,OAAO,EAAE,QAAQ,EAAE,CAAC"}
package/dist/readline.js CHANGED
@@ -1,25 +1,25 @@
1
- /**
2
- *****************************************
3
- * Created by edonet@163.com
4
- * Created on 2021-05-22 11:53:49
5
- *****************************************
6
- */
7
- 'use strict';
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.readline = void 0;
10
- /**
11
- *****************************************
12
- * 加载依赖
13
- *****************************************
14
- */
15
- const fs = require("fs");
16
- const stream_1 = require("stream");
17
- const readline_1 = require("readline");
18
- function readline(path, options) {
19
- const input = fs.createReadStream(path, options);
20
- const readable = stream_1.Readable.from(readline_1.createInterface({ input, crlfDelay: Infinity }));
21
- // 返回可读流
22
- return readable;
23
- }
24
- exports.readline = readline;
1
+ /**
2
+ *****************************************
3
+ * Created by edonet@163.com
4
+ * Created on 2021-05-22 11:53:49
5
+ *****************************************
6
+ */
7
+ 'use strict';
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.readline = void 0;
10
+ /**
11
+ *****************************************
12
+ * 加载依赖
13
+ *****************************************
14
+ */
15
+ const fs = require("fs");
16
+ const stream_1 = require("stream");
17
+ const readline_1 = require("readline");
18
+ function readline(path, options) {
19
+ const input = fs.createReadStream(path, options);
20
+ const readable = stream_1.Readable.from((0, readline_1.createInterface)({ input, crlfDelay: Infinity }));
21
+ // 返回可读流
22
+ return readable;
23
+ }
24
+ exports.readline = readline;
25
25
  //# sourceMappingURL=readline.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"readline.js","sourceRoot":"","sources":["../src/readline.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,YAAY,CAAC;;;AAGb;;;;GAIG;AACH,yBAAyB;AACzB,mCAAkC;AAClC,uCAA2C;AAW3C,SAAS,QAAQ,CAAC,IAAY,EAAE,OAA0B;IACtD,MAAM,KAAK,GAAG,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACjD,MAAM,QAAQ,GAAG,iBAAQ,CAAC,IAAI,CAAC,0BAAe,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IAEhF,QAAQ;IACR,OAAO,QAAQ,CAAC;AACpB,CAAC;AAQQ,4BAAQ"}
1
+ {"version":3,"file":"readline.js","sourceRoot":"","sources":["../src/readline.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,YAAY,CAAC;;;AAGb;;;;GAIG;AACH,yBAAyB;AACzB,mCAAkC;AAClC,uCAA2C;AAW3C,SAAS,QAAQ,CAAC,IAAY,EAAE,OAAkC;IAC9D,MAAM,KAAK,GAAG,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACjD,MAAM,QAAQ,GAAG,iBAAQ,CAAC,IAAI,CAAC,IAAA,0BAAe,EAAC,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IAEhF,QAAQ;IACR,OAAO,QAAQ,CAAC;AACpB,CAAC;AAQQ,4BAAQ"}
@@ -1,13 +1,13 @@
1
- /**
2
- *****************************************
3
- * 获取基准路径
4
- *****************************************
5
- */
6
- export declare const baseDir: string;
7
- /**
8
- *****************************************
9
- * 解析真实地址
10
- *****************************************
11
- */
12
- export declare function realpath(path: string): string;
1
+ /**
2
+ *****************************************
3
+ * 获取基准路径
4
+ *****************************************
5
+ */
6
+ export declare const baseDir: string;
7
+ /**
8
+ *****************************************
9
+ * 解析真实地址
10
+ *****************************************
11
+ */
12
+ export declare function realpath(path: string): string;
13
13
  //# sourceMappingURL=realpath.d.ts.map
package/dist/realpath.js CHANGED
@@ -1,33 +1,33 @@
1
- /**
2
- *****************************************
3
- * Created by edonet@163.com
4
- * Created on 2021-07-17 17:42:34
5
- *****************************************
6
- */
7
- 'use strict';
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.realpath = exports.baseDir = void 0;
10
- /**
11
- *****************************************
12
- * 加载依赖
13
- *****************************************
14
- */
15
- const fs_1 = require("fs");
16
- const path_1 = require("path");
17
- const isAbsolutePath_1 = require("./isAbsolutePath");
18
- /**
19
- *****************************************
20
- * 获取基准路径
21
- *****************************************
22
- */
23
- exports.baseDir = fs_1.realpathSync(process.cwd());
24
- /**
25
- *****************************************
26
- * 解析真实地址
27
- *****************************************
28
- */
29
- function realpath(path) {
30
- return isAbsolutePath_1.isAbsolutePath(path) ? fs_1.realpathSync(path) : path_1.resolve(exports.baseDir, path);
31
- }
32
- exports.realpath = realpath;
1
+ /**
2
+ *****************************************
3
+ * Created by edonet@163.com
4
+ * Created on 2021-07-17 17:42:34
5
+ *****************************************
6
+ */
7
+ 'use strict';
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.realpath = exports.baseDir = void 0;
10
+ /**
11
+ *****************************************
12
+ * 加载依赖
13
+ *****************************************
14
+ */
15
+ const fs_1 = require("fs");
16
+ const path_1 = require("path");
17
+ const isAbsolutePath_1 = require("./isAbsolutePath");
18
+ /**
19
+ *****************************************
20
+ * 获取基准路径
21
+ *****************************************
22
+ */
23
+ exports.baseDir = (0, fs_1.realpathSync)(process.cwd());
24
+ /**
25
+ *****************************************
26
+ * 解析真实地址
27
+ *****************************************
28
+ */
29
+ function realpath(path) {
30
+ return (0, isAbsolutePath_1.isAbsolutePath)(path) ? (0, fs_1.realpathSync)(path) : (0, path_1.resolve)(exports.baseDir, path);
31
+ }
32
+ exports.realpath = realpath;
33
33
  //# sourceMappingURL=realpath.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"realpath.js","sourceRoot":"","sources":["../src/realpath.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,YAAY,CAAC;;;AAGb;;;;GAIG;AACH,2BAAkC;AAClC,+BAA+B;AAC/B,qDAAkD;AAGlD;;;;GAIG;AACU,QAAA,OAAO,GAAG,iBAAY,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AAGnD;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,IAAY;IACjC,OAAO,+BAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,iBAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,cAAO,CAAC,eAAO,EAAE,IAAI,CAAC,CAAC;AAC9E,CAAC;AAFD,4BAEC"}
1
+ {"version":3,"file":"realpath.js","sourceRoot":"","sources":["../src/realpath.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,YAAY,CAAC;;;AAGb;;;;GAIG;AACH,2BAAkC;AAClC,+BAA+B;AAC/B,qDAAkD;AAGlD;;;;GAIG;AACU,QAAA,OAAO,GAAG,IAAA,iBAAY,EAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;AAGnD;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,IAAY;IACjC,OAAO,IAAA,+BAAc,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAY,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAA,cAAO,EAAC,eAAO,EAAE,IAAI,CAAC,CAAC;AAC9E,CAAC;AAFD,4BAEC"}
@@ -1,7 +1,7 @@
1
- /**
2
- *****************************************
3
- * 获取相对路径
4
- *****************************************
5
- */
6
- export declare function relative(from: string, to: string): string;
1
+ /**
2
+ *****************************************
3
+ * 获取相对路径
4
+ *****************************************
5
+ */
6
+ export declare function relative(from: string, to: string): string;
7
7
  //# sourceMappingURL=relative.d.ts.map
package/dist/relative.js CHANGED
@@ -1,39 +1,39 @@
1
- /**
2
- *****************************************
3
- * Created by edonet@163.com
4
- * Created on 2021-04-18 15:00:57
5
- *****************************************
6
- */
7
- 'use strict';
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.relative = void 0;
10
- /**
11
- *****************************************
12
- * 获取相对路径
13
- *****************************************
14
- */
15
- const path = require("path");
16
- /**
17
- *****************************************
18
- * 获取相对路径
19
- *****************************************
20
- */
21
- function relative(from, to) {
22
- let result = path.relative(from, to);
23
- // 替换分隔符
24
- if (path.sep === '\\') {
25
- result = result.split('\\').join('/');
26
- }
27
- // 补全相对路径
28
- if (result.charAt(0) !== '.') {
29
- return './' + result;
30
- }
31
- // 纯目录
32
- if (['..', '.'].includes(result) || result.endsWith('/..')) {
33
- return result + '/';
34
- }
35
- // 返回结果
36
- return result;
37
- }
38
- exports.relative = relative;
1
+ /**
2
+ *****************************************
3
+ * Created by edonet@163.com
4
+ * Created on 2021-04-18 15:00:57
5
+ *****************************************
6
+ */
7
+ 'use strict';
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.relative = void 0;
10
+ /**
11
+ *****************************************
12
+ * 获取相对路径
13
+ *****************************************
14
+ */
15
+ const path = require("path");
16
+ /**
17
+ *****************************************
18
+ * 获取相对路径
19
+ *****************************************
20
+ */
21
+ function relative(from, to) {
22
+ let result = path.relative(from, to);
23
+ // 替换分隔符
24
+ if (path.sep === '\\') {
25
+ result = result.split('\\').join('/');
26
+ }
27
+ // 补全相对路径
28
+ if (result.charAt(0) !== '.') {
29
+ return './' + result;
30
+ }
31
+ // 纯目录
32
+ if (['..', '.'].includes(result) || result.endsWith('/..')) {
33
+ return result + '/';
34
+ }
35
+ // 返回结果
36
+ return result;
37
+ }
38
+ exports.relative = relative;
39
39
  //# sourceMappingURL=relative.js.map