@ainc/fs 0.1.10 → 0.1.14
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/README.md +2 -0
- package/dist/basename.d.ts +6 -6
- package/dist/basename.js +16 -16
- package/dist/copy.d.ts +40 -40
- package/dist/copy.d.ts.map +1 -1
- package/dist/copy.js +89 -86
- package/dist/copy.js.map +1 -1
- package/dist/cpdir.d.ts +19 -19
- package/dist/cpdir.js +28 -28
- package/dist/cwd.d.ts +6 -6
- package/dist/cwd.js +16 -16
- package/dist/dirname.d.ts +6 -6
- package/dist/dirname.js +30 -30
- package/dist/extname.d.ts +6 -6
- package/dist/extname.js +16 -16
- package/dist/filename.d.ts +6 -6
- package/dist/filename.js +24 -24
- package/dist/find.d.ts +26 -26
- package/dist/find.d.ts.map +1 -1
- package/dist/find.js +72 -68
- package/dist/find.js.map +1 -1
- package/dist/findFile.d.ts +20 -20
- package/dist/findFile.d.ts.map +1 -1
- package/dist/findFile.js +39 -39
- package/dist/findFile.js.map +1 -1
- package/dist/finddir.d.ts +20 -20
- package/dist/finddir.d.ts.map +1 -1
- package/dist/finddir.js +39 -39
- package/dist/finddir.js.map +1 -1
- package/dist/helpers/FileResolver.d.ts +54 -0
- package/dist/helpers/FileResolver.d.ts.map +1 -0
- package/dist/helpers/FileResolver.js +184 -0
- package/dist/helpers/FileResolver.js.map +1 -0
- package/dist/helpers/compose.d.ts +14 -0
- package/dist/helpers/compose.d.ts.map +1 -0
- package/dist/helpers/compose.js +38 -0
- package/dist/helpers/compose.js.map +1 -0
- package/dist/helpers/each.d.ts +7 -0
- package/dist/helpers/each.d.ts.map +1 -0
- package/dist/helpers/each.js +21 -0
- package/dist/helpers/each.js.map +1 -0
- package/dist/helpers/match.d.ts +7 -0
- package/dist/helpers/match.d.ts.map +1 -0
- package/dist/helpers/match.js +30 -0
- package/dist/helpers/match.js.map +1 -0
- package/dist/helpers/normalizePath.d.ts +23 -0
- package/dist/helpers/normalizePath.d.ts.map +1 -0
- package/dist/helpers/normalizePath.js +37 -0
- package/dist/helpers/normalizePath.js.map +1 -0
- package/dist/helpers/safeCall.d.ts +7 -0
- package/dist/helpers/safeCall.d.ts.map +1 -0
- package/dist/helpers/safeCall.js +24 -0
- package/dist/helpers/safeCall.js.map +1 -0
- package/dist/helpers/split.d.ts +7 -0
- package/dist/helpers/split.d.ts.map +1 -0
- package/dist/helpers/split.js +25 -0
- package/dist/helpers/split.js.map +1 -0
- package/dist/homedir.d.ts +6 -6
- package/dist/homedir.js +31 -31
- package/dist/includePaths.d.ts +6 -6
- package/dist/includePaths.js +53 -53
- package/dist/index.d.ts +42 -41
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +88 -86
- package/dist/index.js.map +1 -1
- package/dist/indir.d.ts +13 -13
- package/dist/indir.js +26 -26
- package/dist/isAbsolutePath.d.ts +6 -6
- package/dist/isAbsolutePath.js +24 -24
- package/dist/isDirectory.d.ts +12 -12
- package/dist/isDirectory.js +26 -26
- package/dist/isRelativePath.d.ts +6 -6
- package/dist/isRelativePath.d.ts.map +1 -1
- package/dist/isRelativePath.js +44 -18
- package/dist/isRelativePath.js.map +1 -1
- package/dist/json.d.ts +21 -21
- package/dist/json.js +33 -33
- package/dist/jsonc.d.ts +21 -21
- package/dist/jsonc.d.ts.map +1 -1
- package/dist/jsonc.js +40 -41
- package/dist/jsonc.js.map +1 -1
- package/dist/lstat.d.ts +22 -22
- package/dist/lstat.js +30 -30
- package/dist/mapdir.d.ts +22 -22
- package/dist/mapdir.js +42 -42
- package/dist/mkdir.d.ts +6 -6
- package/dist/mkdir.js +37 -37
- package/dist/normalizeJSON.d.ts +7 -0
- package/dist/normalizeJSON.d.ts.map +1 -0
- package/dist/normalizeJSON.js +145 -0
- package/dist/normalizeJSON.js.map +1 -0
- package/dist/readFile.d.ts +29 -29
- package/dist/readFile.js +26 -26
- package/dist/readStream.d.ts +36 -36
- package/dist/readStream.js +19 -19
- package/dist/readdir.d.ts +16 -16
- package/dist/readdir.js +34 -34
- package/dist/readline.d.ts +16 -16
- package/dist/readline.js +24 -24
- package/dist/realpath.d.ts +13 -0
- package/dist/realpath.d.ts.map +1 -0
- package/dist/realpath.js +33 -0
- package/dist/realpath.js.map +1 -0
- package/dist/relative.d.ts +6 -6
- package/dist/relative.js +38 -38
- package/dist/relative.js.map +1 -1
- package/dist/resolve.d.ts +26 -25
- package/dist/resolve.d.ts.map +1 -1
- package/dist/resolve.js +53 -53
- package/dist/resolve.js.map +1 -1
- package/dist/resolvePath.d.ts +27 -0
- package/dist/resolvePath.d.ts.map +1 -0
- package/dist/resolvePath.js +178 -0
- package/dist/resolvePath.js.map +1 -0
- package/dist/rmdir.d.ts +6 -6
- package/dist/rmdir.js +40 -40
- package/dist/stat.d.ts +21 -22
- package/dist/stat.d.ts.map +1 -1
- package/dist/stat.js +30 -30
- package/dist/supdir.d.ts +21 -15
- package/dist/supdir.d.ts.map +1 -1
- package/dist/supdir.js +62 -35
- package/dist/supdir.js.map +1 -1
- package/dist/symlink.d.ts +22 -22
- package/dist/symlink.js +39 -39
- package/dist/unlink.d.ts +6 -6
- package/dist/unlink.js +28 -28
- package/dist/usedir.d.ts +6 -6
- package/dist/usedir.js +24 -24
- package/dist/writeFile.d.ts +33 -27
- package/dist/writeFile.d.ts.map +1 -1
- package/dist/writeFile.js +49 -46
- package/dist/writeFile.js.map +1 -1
- package/dist/writeStream.d.ts +35 -35
- package/dist/writeStream.js +19 -19
- package/package.json +7 -7
- package/src/copy.ts +10 -4
- package/src/find.ts +16 -12
- package/src/findFile.ts +1 -1
- package/src/finddir.ts +1 -1
- package/src/helpers/FileResolver.ts +282 -0
- package/src/helpers/compose.ts +49 -0
- package/src/helpers/each.ts +19 -0
- package/src/helpers/match.ts +31 -0
- package/src/helpers/normalizePath.ts +51 -0
- package/src/helpers/safeCall.ts +21 -0
- package/src/helpers/split.ts +25 -0
- package/src/{stripBOM.ts → helpers/stripBOM.ts} +3 -10
- package/src/helpers/stripComments.ts +167 -0
- package/src/index.ts +3 -1
- package/src/isRelativePath.ts +36 -1
- package/src/json.ts +2 -1
- package/src/jsonc.ts +2 -3
- package/src/parseJSON.ts +40 -0
- package/src/realpath.ts +35 -0
- package/src/relative.ts +1 -1
- package/src/resolve.ts +2 -1
- package/src/resolvePath.ts +234 -0
- package/src/stat.ts +1 -1
- package/src/supdir.ts +31 -0
- package/src/writeFile.ts +11 -8
- package/dist/resolveAlias.d.ts +0 -21
- package/dist/resolveAlias.d.ts.map +0 -1
- package/dist/resolveAlias.js +0 -108
- package/dist/resolveAlias.js.map +0 -1
- package/dist/stripBOM.d.ts +0 -7
- package/dist/stripBOM.d.ts.map +0 -1
- package/dist/stripBOM.js +0 -24
- package/dist/stripBOM.js.map +0 -1
- package/dist/stripComments.d.ts +0 -7
- package/dist/stripComments.d.ts.map +0 -1
- package/dist/stripComments.js +0 -100
- package/dist/stripComments.js.map +0 -1
- package/src/resolveAlias.ts +0 -153
- package/src/stripComments.ts +0 -112
package/dist/mkdir.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*****************************************
|
|
3
|
-
* Created by edonet@163.com
|
|
4
|
-
* Created on 2019-11-07 16:48:57
|
|
5
|
-
*****************************************
|
|
6
|
-
*/
|
|
7
|
-
'use strict';
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.mkdir = void 0;
|
|
10
|
-
/**
|
|
11
|
-
*****************************************
|
|
12
|
-
* 加载依赖
|
|
13
|
-
*****************************************
|
|
14
|
-
*/
|
|
15
|
-
const fs = require("fs");
|
|
16
|
-
const path = require("path");
|
|
17
|
-
const isDirectory_1 = require("./isDirectory");
|
|
18
|
-
const dirname_1 = require("./dirname");
|
|
19
|
-
/**
|
|
20
|
-
*****************************************
|
|
21
|
-
* 创建目录
|
|
22
|
-
*****************************************
|
|
23
|
-
*/
|
|
24
|
-
function mkdir(dir) {
|
|
25
|
-
// 解析目录
|
|
26
|
-
dir = path.resolve(dir);
|
|
27
|
-
// 创建目录
|
|
28
|
-
if (!isDirectory_1.isDirectory(dir)) {
|
|
29
|
-
// 创建上级目录
|
|
30
|
-
mkdir(dirname_1.dirname(dir));
|
|
31
|
-
// 创建目录
|
|
32
|
-
fs.mkdirSync(dir);
|
|
33
|
-
}
|
|
34
|
-
// 返回目录
|
|
35
|
-
return dir;
|
|
36
|
-
}
|
|
37
|
-
exports.mkdir = mkdir;
|
|
1
|
+
/**
|
|
2
|
+
*****************************************
|
|
3
|
+
* Created by edonet@163.com
|
|
4
|
+
* Created on 2019-11-07 16:48:57
|
|
5
|
+
*****************************************
|
|
6
|
+
*/
|
|
7
|
+
'use strict';
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.mkdir = void 0;
|
|
10
|
+
/**
|
|
11
|
+
*****************************************
|
|
12
|
+
* 加载依赖
|
|
13
|
+
*****************************************
|
|
14
|
+
*/
|
|
15
|
+
const fs = require("fs");
|
|
16
|
+
const path = require("path");
|
|
17
|
+
const isDirectory_1 = require("./isDirectory");
|
|
18
|
+
const dirname_1 = require("./dirname");
|
|
19
|
+
/**
|
|
20
|
+
*****************************************
|
|
21
|
+
* 创建目录
|
|
22
|
+
*****************************************
|
|
23
|
+
*/
|
|
24
|
+
function mkdir(dir) {
|
|
25
|
+
// 解析目录
|
|
26
|
+
dir = path.resolve(dir);
|
|
27
|
+
// 创建目录
|
|
28
|
+
if (!isDirectory_1.isDirectory(dir)) {
|
|
29
|
+
// 创建上级目录
|
|
30
|
+
mkdir(dirname_1.dirname(dir));
|
|
31
|
+
// 创建目录
|
|
32
|
+
fs.mkdirSync(dir);
|
|
33
|
+
}
|
|
34
|
+
// 返回目录
|
|
35
|
+
return dir;
|
|
36
|
+
}
|
|
37
|
+
exports.mkdir = mkdir;
|
|
38
38
|
//# sourceMappingURL=mkdir.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeJSON.d.ts","sourceRoot":"","sources":["../src/normalizeJSON.ts"],"names":[],"mappings":"AAiGA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAgErD"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*****************************************
|
|
3
|
+
* Created by edonet@163.com
|
|
4
|
+
* Created on 2021-05-31 22:41:48
|
|
5
|
+
*****************************************
|
|
6
|
+
*/
|
|
7
|
+
'use strict';
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.normalizeJSON = void 0;
|
|
10
|
+
/**
|
|
11
|
+
*****************************************
|
|
12
|
+
* 判断是否为转义字符
|
|
13
|
+
*****************************************
|
|
14
|
+
*/
|
|
15
|
+
function isEscaped(index, source) {
|
|
16
|
+
let count = 1;
|
|
17
|
+
// 统计转义字符
|
|
18
|
+
while (source[index - count] === '\\') {
|
|
19
|
+
count++;
|
|
20
|
+
}
|
|
21
|
+
// 判断是否转义
|
|
22
|
+
return count % 2;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
*****************************************
|
|
26
|
+
* 判断是否为结尾的逗号
|
|
27
|
+
*****************************************
|
|
28
|
+
*/
|
|
29
|
+
function isTrailingComma(start, source) {
|
|
30
|
+
let ch = source[start];
|
|
31
|
+
// 过滤空白字符
|
|
32
|
+
while (' \n\r'.indexOf(ch) > -1) {
|
|
33
|
+
ch = source[++start];
|
|
34
|
+
}
|
|
35
|
+
// 返回是否为结束符
|
|
36
|
+
return '}]'.indexOf(ch) > -1;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
*****************************************
|
|
40
|
+
* 查找字符串结束
|
|
41
|
+
*****************************************
|
|
42
|
+
*/
|
|
43
|
+
function indexStringEnd(start, ch, source) {
|
|
44
|
+
const idx = source.indexOf(ch, start);
|
|
45
|
+
// 判断是否查找结束
|
|
46
|
+
if (idx === -1) {
|
|
47
|
+
return source.length;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return isEscaped(idx, source) ? idx + 1 : indexStringEnd(idx + 1, ch, source);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
*****************************************
|
|
55
|
+
* 查找行注释结束
|
|
56
|
+
*****************************************
|
|
57
|
+
*/
|
|
58
|
+
function indexLineCommentEnd(start, source) {
|
|
59
|
+
const idx = source.indexOf('\n', start);
|
|
60
|
+
// 判断是否查找结束
|
|
61
|
+
if (idx === -1) {
|
|
62
|
+
return source.length;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
return source[idx - 1] === '\r' ? idx - 1 : idx;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
*****************************************
|
|
70
|
+
* 查找块注释结束
|
|
71
|
+
*****************************************
|
|
72
|
+
*/
|
|
73
|
+
function indexBlockCommentEnd(start, source) {
|
|
74
|
+
const idx = source.indexOf('/', start);
|
|
75
|
+
if (idx === -1) {
|
|
76
|
+
return source.length;
|
|
77
|
+
}
|
|
78
|
+
else if (source[idx - 1] === '*') {
|
|
79
|
+
return idx + 1;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
return indexBlockCommentEnd(idx + 1, source);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
*****************************************
|
|
87
|
+
* 过滤注释
|
|
88
|
+
*****************************************
|
|
89
|
+
*/
|
|
90
|
+
function normalizeJSON(content) {
|
|
91
|
+
let result = '';
|
|
92
|
+
let idx = 0;
|
|
93
|
+
let len = content.length;
|
|
94
|
+
let start = 0;
|
|
95
|
+
// 检测第一个字符是否为BOM
|
|
96
|
+
if (content.charCodeAt(0) === 0xFEFF) {
|
|
97
|
+
idx = start = 1;
|
|
98
|
+
}
|
|
99
|
+
// 遍历字符
|
|
100
|
+
while (idx < len) {
|
|
101
|
+
const ch = content[idx];
|
|
102
|
+
// 跳过字符串
|
|
103
|
+
if (ch === '"' || ch === '\'') {
|
|
104
|
+
idx = indexStringEnd(idx + 1, ch, content);
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
// 自增偏移
|
|
108
|
+
idx++;
|
|
109
|
+
// 判断是为结尾的逗号
|
|
110
|
+
if (ch === ',' && isTrailingComma(idx, content)) {
|
|
111
|
+
result += content.slice(start, idx - 1);
|
|
112
|
+
start = idx;
|
|
113
|
+
idx = start + 1;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
// 非注释
|
|
117
|
+
if (ch !== '/') {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
// 获取下一字符
|
|
121
|
+
const next = content[idx];
|
|
122
|
+
// 处理行注释
|
|
123
|
+
if (next === '/') {
|
|
124
|
+
result += content.slice(start, idx - 1);
|
|
125
|
+
start = indexLineCommentEnd(idx + 1, content);
|
|
126
|
+
idx = start + 1;
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
// 处理多行注释
|
|
130
|
+
if (next === '*') {
|
|
131
|
+
result += content.slice(start, idx - 1);
|
|
132
|
+
start = indexBlockCommentEnd(idx + 2, content);
|
|
133
|
+
idx = start;
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// 添加结束片段
|
|
138
|
+
if (start < len) {
|
|
139
|
+
result += content.slice(start);
|
|
140
|
+
}
|
|
141
|
+
// 返回结果
|
|
142
|
+
return result;
|
|
143
|
+
}
|
|
144
|
+
exports.normalizeJSON = normalizeJSON;
|
|
145
|
+
//# sourceMappingURL=normalizeJSON.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizeJSON.js","sourceRoot":"","sources":["../src/normalizeJSON.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,YAAY,CAAC;;;AAGb;;;;GAIG;AACH,SAAS,SAAS,CAAC,KAAa,EAAE,MAAc;IAC5C,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,SAAS;IACT,OA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C7C,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;YACxC,KAAK,GAAG,GAAG,CAAC;YACZ,GAAG,GAAG,KAAK,GAAG,CAAC,CAAC;YAChB,SAAS;SACZ;QAED,MAAM;QACN,IAAI,EAAE,KAAK,GAAG,EAAE;YACZ,SAAS;SACZ;QAED,SAAS;QACT,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAE1B,QAAQ;QACR,IAAI,IAAI,KAAK,GAAG,EAAE;YACd,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;YACxC,KAAK,GAAG,mBAAmB,CAAC,GAAG,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;YAC9C,GAAG,GAAG,KAAK,GAAG,CAAC,CAAC;YAChB,SAAS;SACZ;QAED,SAAS;QACT,IAAI,IAAI,KAAK,GAAG,EAAE;YACd,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;YACxC,KAAK,GAAG,oBAAoB,CAAC,GAAG,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;YAC/C,GAAG,GAAG,KAAK,CAAC;YACZ,SAAS;SACZ;KACJ;IAED,SAAS;IACT,IAAI,KAAK,GAAG,GAAG,EAAE;QACb,MAAM,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KAClC;IAED,OAAO;IACP,OAAO,MAAM,CAAC;AAClB,CAAC;AAhED,sCAgEC"}
|
package/dist/readFile.d.ts
CHANGED
|
@@ -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 = 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
|
package/dist/readStream.d.ts
CHANGED
|
@@ -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?: string): 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
|
package/dist/readStream.js
CHANGED
|
@@ -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
|
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 = 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
|
package/dist/readline.d.ts
CHANGED
|
@@ -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?: string): 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
|
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(readline_1.createInterface({ input, crlfDelay: Infinity }));
|
|
21
|
+
// 返回可读流
|
|
22
|
+
return readable;
|
|
23
|
+
}
|
|
24
|
+
exports.readline = readline;
|
|
25
25
|
//# sourceMappingURL=readline.js.map
|
|
@@ -0,0 +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;
|
|
13
|
+
//# sourceMappingURL=realpath.d.ts.map
|