@e-mc/module 0.10.0 → 0.10.2
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/LICENSE +10 -10
- package/README.md +414 -413
- package/index.d.ts +4 -4
- package/index.js +48 -47
- package/lib-v4.d.ts +4 -4
- package/package.json +31 -31
package/LICENSE
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
Copyright 2024 An Pham
|
|
2
|
-
|
|
3
|
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
4
|
-
|
|
5
|
-
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
6
|
-
|
|
7
|
-
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
8
|
-
|
|
9
|
-
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
10
|
-
|
|
1
|
+
Copyright 2024 An Pham
|
|
2
|
+
|
|
3
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
4
|
+
|
|
5
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
6
|
+
|
|
7
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
8
|
+
|
|
9
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
10
|
+
|
|
11
11
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
CHANGED
|
@@ -1,414 +1,415 @@
|
|
|
1
|
-
# @e-mc/module
|
|
2
|
-
|
|
3
|
-
* NodeJS 16
|
|
4
|
-
* ES2020
|
|
5
|
-
|
|
6
|
-
## General Usage
|
|
7
|
-
|
|
8
|
-
* [Read the Docs](https://e-mc.readthedocs.io)
|
|
9
|
-
|
|
10
|
-
## Interface
|
|
11
|
-
|
|
12
|
-
* [View Source](https://www.unpkg.com/@e-mc/types@0.10.
|
|
13
|
-
|
|
14
|
-
```typescript
|
|
15
|
-
import type { LogStatus } from "./squared";
|
|
16
|
-
|
|
17
|
-
import type { IHost } from "./index";
|
|
18
|
-
import type { IAbortComponent, IPermission } from "./core";
|
|
19
|
-
import type { LOG_TYPE, STATUS_TYPE, ExecCommand, LogArguments, LogComponent, LogDate, LogFailOptions, LogMessageOptions, LogOptions, LogProcessOptions, LogTime, LogType, LogValue, LoggerFormat, StatusType } from "./logger";
|
|
20
|
-
import type { AsHashOptions, CheckSemVerOptions, CopyDirOptions, CopyDirResult, CopyFileOptions, CreateDirOptions, DeleteFileOptions, MoveFileOptions, ParseFunctionOptions, PermissionOptions, ProtocolType, ReadBufferOptions, ReadFileCallback, ReadFileOptions, ReadHashOptions, ReadTextOptions, RemoveDirOptions, TempDirOptions, WriteFileOptions } from "./module";
|
|
21
|
-
import type { Settings } from "./node";
|
|
22
|
-
import type { LoggerFormatSettings } from "/settings";
|
|
23
|
-
|
|
24
|
-
import type { SpawnOptions } from "child_process";
|
|
25
|
-
import type { BinaryLike, HashOptions } from "crypto";
|
|
26
|
-
import type { FileTypeResult } from "file-type";
|
|
27
|
-
import type { NoParamCallback } from "fs";
|
|
28
|
-
import type * as EventEmitter from "events";
|
|
29
|
-
|
|
30
|
-
type BufferView = Buffer | string | NodeJS.ArrayBufferView;
|
|
31
|
-
type CpuUsage = NodeJS.CpuUsage;
|
|
32
|
-
|
|
33
|
-
interface IModule extends EventEmitter, IAbortComponent {
|
|
34
|
-
readonly status: LogStatus<StatusType>[];
|
|
35
|
-
readonly errors: unknown[];
|
|
36
|
-
/** @deprecated Types.supported */
|
|
37
|
-
supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
|
|
38
|
-
supports(name: string, value?: boolean): boolean;
|
|
39
|
-
getTempDir(options: TempDirOptions): string;
|
|
40
|
-
getTempDir(uuidDir: boolean, createDir: boolean): string;
|
|
41
|
-
getTempDir(pathname: string, createDir: boolean): string;
|
|
42
|
-
getTempDir(uuidDir: boolean, filename?: string, createDir?: boolean): string;
|
|
43
|
-
getTempDir(pathname?: string, filename?: string, createDir?: boolean): string;
|
|
44
|
-
canRead(uri: string, options?: PermissionOptions): boolean;
|
|
45
|
-
canWrite(uri: string, options?: PermissionOptions): boolean;
|
|
46
|
-
readFile(src: string): Buffer | undefined;
|
|
47
|
-
readFile(src: string, options?: ReadFileOptions): Promise<Buffer | string> | Buffer | string | undefined;
|
|
48
|
-
readFile(src: string, promises: true): Promise<Buffer | undefined>;
|
|
49
|
-
readFile(src: string, options: ReadFileOptions, promises: true): Promise<Buffer | string | undefined>;
|
|
50
|
-
readFile(src: string, callback: ReadFileCallback<Buffer | string>): Buffer | string | undefined;
|
|
51
|
-
readFile(src: string, options: ReadFileOptions, callback: ReadFileCallback<Buffer | string>): Buffer | string | undefined;
|
|
52
|
-
writeFile(src: string, data: BufferView, options?: WriteFileOptions): boolean;
|
|
53
|
-
writeFile(src: string, data: BufferView, promises: true): Promise<boolean>;
|
|
54
|
-
writeFile(src: string, data: BufferView, options: WriteFileOptions, promises: true): Promise<boolean>;
|
|
55
|
-
writeFile(src: string, data: BufferView, callback: NoParamCallback): void;
|
|
56
|
-
writeFile(src: string, data: BufferView, options: WriteFileOptions, callback: NoParamCallback): void;
|
|
57
|
-
deleteFile(src: string, options?: DeleteFileOptions): boolean;
|
|
58
|
-
deleteFile(src: string, promises: true): Promise<boolean>;
|
|
59
|
-
deleteFile(src: string, options: DeleteFileOptions, promises: true): Promise<boolean>;
|
|
60
|
-
deleteFile(src: string, callback: NoParamCallback): void;
|
|
61
|
-
deleteFile(src: string, options: DeleteFileOptions, callback: NoParamCallback): void;
|
|
62
|
-
copyFile(src: string, dest: string, options?: CopyFileOptions): boolean;
|
|
63
|
-
copyFile(src: string, dest: string, promises: true): Promise<boolean>;
|
|
64
|
-
copyFile(src: string, dest: string, options: CopyFileOptions, promises: true): Promise<boolean>;
|
|
65
|
-
copyFile(src: string, dest: string, callback: NoParamCallback): void;
|
|
66
|
-
copyFile(src: string, dest: string, options: CopyFileOptions, callback: NoParamCallback): void;
|
|
67
|
-
moveFile(src: string, dest: string, options?: MoveFileOptions): boolean;
|
|
68
|
-
moveFile(src: string, dest: string, promises: true): Promise<boolean>;
|
|
69
|
-
moveFile(src: string, dest: string, options: MoveFileOptions, promises: true): Promise<boolean>;
|
|
70
|
-
moveFile(src: string, dest: string, callback: NoParamCallback): void;
|
|
71
|
-
moveFile(src: string, dest: string, options: MoveFileOptions, callback: NoParamCallback): void;
|
|
72
|
-
createDir(src: string, options?: CreateDirOptions): boolean;
|
|
73
|
-
createDir(src: string, promises: true): Promise<boolean>;
|
|
74
|
-
createDir(src: string, options: CreateDirOptions, promises: true): Promise<boolean>;
|
|
75
|
-
createDir(src: string, callback: NoParamCallback): void;
|
|
76
|
-
createDir(src: string, options: CreateDirOptions, callback: NoParamCallback): void;
|
|
77
|
-
removeDir(src: string, options?: RemoveDirOptions): boolean;
|
|
78
|
-
removeDir(src: string, promises: true): Promise<boolean>;
|
|
79
|
-
removeDir(src: string, options: RemoveDirOptions, promises: true): Promise<boolean>;
|
|
80
|
-
removeDir(src: string, callback: NoParamCallback): void;
|
|
81
|
-
removeDir(src: string, options: RemoveDirOptions, callback: NoParamCallback): void;
|
|
82
|
-
allSettled(values: readonly PromiseLike<unknown>[], rejected?: LogValue, type?: LogType): Promise<PromiseFulfilledResult<unknown>[]>;
|
|
83
|
-
allSettled(values: readonly PromiseLike<unknown>[], rejected?: LogValue, options?: LogFailOptions): Promise<PromiseFulfilledResult<unknown>[]>;
|
|
84
|
-
formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void;
|
|
85
|
-
formatFail(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogFailOptions): void;
|
|
86
|
-
writeFail(value: LogValue, message?: unknown, type?: LogType): void;
|
|
87
|
-
writeFail(value: LogValue, message?: unknown, options?: LogFailOptions): void;
|
|
88
|
-
writeTimeProcess(title: string, value: string, startTime: LogTime, options?: LogProcessOptions): void;
|
|
89
|
-
writeTimeElapsed(title: string, value: LogValue, startTime: LogTime, options?: LogMessageOptions): void;
|
|
90
|
-
checkPackage(err: unknown, name: string | undefined, type: LogType): boolean;
|
|
91
|
-
checkPackage(err: unknown, name: string | undefined, options: LogFailOptions): boolean;
|
|
92
|
-
checkPackage(err: unknown, name: string | undefined, value?: LogValue, options?: LogFailOptions | LogType): boolean;
|
|
93
|
-
checkFail(message: unknown, options: LogFailOptions): LogArguments | false | undefined;
|
|
94
|
-
writeLog(component: LogComponent, queue?: boolean): void;
|
|
95
|
-
writeLog(type: StatusType, value: unknown, options: LogOptions): void;
|
|
96
|
-
writeLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number): void;
|
|
97
|
-
addLog(component: LogComponent, queue?: boolean): void;
|
|
98
|
-
addLog(type: StatusType, value: unknown, options: LogOptions): void;
|
|
99
|
-
addLog(type: StatusType, value: unknown, from: string, source?: string): void;
|
|
100
|
-
addLog(type: StatusType, value: unknown, timeStamp?: LogDate, from?: string, source?: string): void;
|
|
101
|
-
addLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number, from?: string, source?: string): void;
|
|
102
|
-
getLog(...type: StatusType[]): LogStatus<StatusType>[];
|
|
103
|
-
flushLog(): void;
|
|
104
|
-
willAbort(value: unknown): boolean;
|
|
105
|
-
hasOwnPermission(): boolean;
|
|
106
|
-
isFatal(err?: unknown): boolean;
|
|
107
|
-
detach(): void;
|
|
108
|
-
reset(): void;
|
|
109
|
-
get moduleName(): string;
|
|
110
|
-
set host(value);
|
|
111
|
-
get host(): IHost | null;
|
|
112
|
-
set permission(value);
|
|
113
|
-
get permission(): IPermission | null;
|
|
114
|
-
get aborted(): boolean;
|
|
115
|
-
set abortable(value);
|
|
116
|
-
get abortable(): boolean;
|
|
117
|
-
get threadable(): boolean;
|
|
118
|
-
set sessionId(value);
|
|
119
|
-
get sessionId(): string;
|
|
120
|
-
set broadcastId(value);
|
|
121
|
-
get broadcastId(): string | string[];
|
|
122
|
-
set silent(value);
|
|
123
|
-
get silent(): boolean;
|
|
124
|
-
get logType(): LOG_TYPE;
|
|
125
|
-
set logLevel(value: number | string);
|
|
126
|
-
get logLevel(): number;
|
|
127
|
-
get statusType(): STATUS_TYPE;
|
|
128
|
-
set tempDir(value);
|
|
129
|
-
get tempDir(): string;
|
|
130
|
-
|
|
131
|
-
/* EventEmitter */
|
|
132
|
-
on(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
|
|
133
|
-
on(event: "error", listener: (err: Error) => void): this;
|
|
134
|
-
on(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
|
|
135
|
-
on(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
|
|
136
|
-
on(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
|
|
137
|
-
on(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
|
|
138
|
-
on(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
|
|
139
|
-
on(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
|
|
140
|
-
on(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
|
|
141
|
-
once(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
|
|
142
|
-
once(event: "error", listener: (err: Error) => void): this;
|
|
143
|
-
once(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
|
|
144
|
-
once(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
|
|
145
|
-
once(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
|
|
146
|
-
once(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
|
|
147
|
-
once(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
|
|
148
|
-
once(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
|
|
149
|
-
once(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
|
|
150
|
-
emit(event: "exec", command: ExecCommand, options?: SpawnOptions): boolean;
|
|
151
|
-
emit(event: "error", err: Error): boolean;
|
|
152
|
-
emit(event: "file:read", src: string, data: Buffer | string, options?: ReadFileOptions): boolean;
|
|
153
|
-
emit(event: "file:write", src: string, options?: WriteFileOptions): boolean;
|
|
154
|
-
emit(event: "file:delete", src: string, options?: DeleteFileOptions): boolean;
|
|
155
|
-
emit(event: "file:copy", dest: string, options?: CopyFileOptions): boolean;
|
|
156
|
-
emit(event: "file:move", dest: string, options?: MoveFileOptions): boolean;
|
|
157
|
-
emit(event: "dir:create", src: string, options?: CreateDirOptions): boolean;
|
|
158
|
-
emit(event: "dir:remove", src: string, options?: RemoveDirOptions): boolean;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
interface ModuleConstructor {
|
|
162
|
-
PROCESS_TIMEOUT: number;
|
|
163
|
-
LOG_STYLE_FAIL: LogMessageOptions;
|
|
164
|
-
LOG_STYLE_SUCCESS: LogMessageOptions;
|
|
165
|
-
LOG_STYLE_INFO: LogMessageOptions;
|
|
166
|
-
LOG_STYLE_WARN: LogMessageOptions;
|
|
167
|
-
LOG_STYLE_NOTICE: LogMessageOptions;
|
|
168
|
-
LOG_STYLE_REVERSE: LogMessageOptions;
|
|
169
|
-
readonly VERSION: string;
|
|
170
|
-
readonly LOG_TYPE: LOG_TYPE;
|
|
171
|
-
readonly LOG_FORMAT: LoggerFormatSettings<LoggerFormat<number>>;
|
|
172
|
-
readonly STATUS_TYPE: STATUS_TYPE;
|
|
173
|
-
readonly PLATFORM_WIN32: boolean;
|
|
174
|
-
readonly MAX_TIMEOUT: number;
|
|
175
|
-
readonly TEMP_DIR: string;
|
|
176
|
-
/** @deprecated Types.supported */
|
|
177
|
-
supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
|
|
178
|
-
formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void;
|
|
179
|
-
writeFail(value: LogValue, message?: unknown, options?: LogFailOptions | LogType): void;
|
|
180
|
-
enabled(key: string, username?: string): boolean;
|
|
181
|
-
parseFunction(value: unknown, options?: ParseFunctionOptions): ((...args: unknown[]) => Promise<unknown> | unknown) | null;
|
|
182
|
-
parseFunction(value: unknown, absolute: boolean, sync?: boolean): ((...args: unknown[]) => Promise<unknown> | unknown) | null;
|
|
183
|
-
asString(value: unknown, cacheKey?: boolean | "throws"): string;
|
|
184
|
-
asHash(data: BinaryLike, options?: AsHashOptions): string;
|
|
185
|
-
asHash(data: BinaryLike, algorithm?: string, options?:
|
|
186
|
-
asHash(data: BinaryLike, algorithm?: string, digest?: BinaryToTextEncoding): string;
|
|
187
|
-
readHash(value: string | URL, options?: ReadHashOptions): Promise<string>;
|
|
188
|
-
toPosix(value: unknown, normalize: boolean): string;
|
|
189
|
-
toPosix(value: unknown, filename?: string, normalize?: boolean): string;
|
|
190
|
-
hasLogType(value: LogType): boolean;
|
|
191
|
-
isURL(value: string, ...exclude: string[]): boolean;
|
|
192
|
-
isFile(value: string | URL, type?: ProtocolType): boolean;
|
|
193
|
-
isDir(value: string | URL): boolean;
|
|
194
|
-
isPath(value: string | URL, type?: "unc" | "unc-exists"): boolean;
|
|
195
|
-
isPath(value: string | URL, isFile?: boolean): boolean;
|
|
196
|
-
isErrorCode(err: unknown, ...code: string[]): boolean;
|
|
197
|
-
fromLocalPath(value: string): string;
|
|
198
|
-
resolveFile(value: string): string;
|
|
199
|
-
resolvePath(value: string, base: string | URL): string;
|
|
200
|
-
joinPath(...values: [...paths: unknown[], normalize: boolean][]): string;
|
|
201
|
-
joinPath(...values: unknown[]): string;
|
|
202
|
-
normalizePath(value: unknown, flags?: boolean | number): string;
|
|
203
|
-
createDir(value: string | URL, overwrite?: boolean): boolean;
|
|
204
|
-
removeDir(value: string | URL, sinceCreated: number, recursive?: boolean): boolean;
|
|
205
|
-
removeDir(value: string | URL, empty?: boolean, recursive?: boolean): boolean;
|
|
206
|
-
copyDir(src: string | URL, dest: string | URL, move?: boolean, recursive?: boolean): Promise<CopyDirResult>;
|
|
207
|
-
copyDir(src: string | URL, dest: string | URL, options?: CopyDirOptions): Promise<CopyDirResult>;
|
|
208
|
-
renameFile(src: string | URL, dest: string | URL, throws?: boolean): boolean;
|
|
209
|
-
streamFile(src: string, cache: boolean): Promise<Buffer | string>;
|
|
210
|
-
streamFile(src: string, options: ReadBufferOptions): Promise<Buffer | string>;
|
|
211
|
-
streamFile(src: string, cache?: boolean | ReadBufferOptions, options?: ReadBufferOptions): Promise<Buffer | string>;
|
|
212
|
-
readText(value: string | URL, cache: boolean): string;
|
|
213
|
-
readText(value: string | URL, options: ReadTextOptions): Promise<string> | string;
|
|
214
|
-
readText(value: string | URL, encoding?: BufferEncoding | ReadTextOptions, cache?: boolean): string;
|
|
215
|
-
readBuffer(value: string | URL, options: ReadBufferOptions): Promise<Buffer | null> | Buffer | null;
|
|
216
|
-
readBuffer(value: string | URL, cache?: boolean | ReadBufferOptions): Buffer | null;
|
|
217
|
-
resolveMime(data: string | Buffer | Uint8Array | ArrayBuffer): Promise<FileTypeResult | undefined>;
|
|
218
|
-
lookupMime(value: string, extension?: boolean): string;
|
|
219
|
-
initCpuUsage(instance?: IModule): CpuUsage;
|
|
220
|
-
getCpuUsage(start: CpuUsage, format: true): string;
|
|
221
|
-
getCpuUsage(start: CpuUsage, format?: boolean): number;
|
|
222
|
-
getMemUsage(format: true): string;
|
|
223
|
-
getMemUsage(format?: boolean): number;
|
|
224
|
-
formatCpuMem(start: CpuUsage, all?: boolean): string;
|
|
225
|
-
getPackageVersion(name: string | [string, string], startDir: string, baseDir?: string): string;
|
|
226
|
-
getPackageVersion(name: string | [string, string], unstable?: boolean, startDir?: string, baseDir?: string): string;
|
|
227
|
-
checkSemVer(name: string | [string, string], options: CheckSemVerOptions): boolean;
|
|
228
|
-
|
|
229
|
-
checkSemVer(name: string | [string, string], min: number | string, max
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
sanitizeArgs(
|
|
233
|
-
|
|
234
|
-
purgeMemory(percent: number,
|
|
235
|
-
purgeMemory(percent
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
import type {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
import type {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
406
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
407
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
408
|
-
- https://www.unpkg.com/@e-mc/types@0.10.
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
1
|
+
# @e-mc/module
|
|
2
|
+
|
|
3
|
+
* NodeJS 16
|
|
4
|
+
* ES2020
|
|
5
|
+
|
|
6
|
+
## General Usage
|
|
7
|
+
|
|
8
|
+
* [Read the Docs](https://e-mc.readthedocs.io)
|
|
9
|
+
|
|
10
|
+
## Interface
|
|
11
|
+
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.10.2/lib/index.d.ts)
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import type { LogStatus } from "./squared";
|
|
16
|
+
|
|
17
|
+
import type { IHost } from "./index";
|
|
18
|
+
import type { IAbortComponent, IPermission } from "./core";
|
|
19
|
+
import type { LOG_TYPE, STATUS_TYPE, ExecCommand, LogArguments, LogComponent, LogDate, LogFailOptions, LogMessageOptions, LogOptions, LogProcessOptions, LogTime, LogType, LogValue, LoggerFormat, StatusType } from "./logger";
|
|
20
|
+
import type { AsHashOptions, CheckSemVerOptions, CopyDirOptions, CopyDirResult, CopyFileOptions, CreateDirOptions, DeleteFileOptions, MoveFileOptions, ParseFunctionOptions, PermissionOptions, ProtocolType, ReadBufferOptions, ReadFileCallback, ReadFileOptions, ReadHashOptions, ReadTextOptions, RemoveDirOptions, TempDirOptions, WriteFileOptions } from "./module";
|
|
21
|
+
import type { Settings } from "./node";
|
|
22
|
+
import type { LoggerFormatSettings } from "/settings";
|
|
23
|
+
|
|
24
|
+
import type { SpawnOptions } from "child_process";
|
|
25
|
+
import type { BinaryLike, HashOptions } from "crypto";
|
|
26
|
+
import type { FileTypeResult } from "file-type";
|
|
27
|
+
import type { NoParamCallback } from "fs";
|
|
28
|
+
import type * as EventEmitter from "events";
|
|
29
|
+
|
|
30
|
+
type BufferView = Buffer | string | NodeJS.ArrayBufferView;
|
|
31
|
+
type CpuUsage = NodeJS.CpuUsage;
|
|
32
|
+
|
|
33
|
+
interface IModule extends EventEmitter, IAbortComponent {
|
|
34
|
+
readonly status: LogStatus<StatusType>[];
|
|
35
|
+
readonly errors: unknown[];
|
|
36
|
+
/** @deprecated Types.supported */
|
|
37
|
+
supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
|
|
38
|
+
supports(name: string, value?: boolean): boolean;
|
|
39
|
+
getTempDir(options: TempDirOptions): string;
|
|
40
|
+
getTempDir(uuidDir: boolean, createDir: boolean): string;
|
|
41
|
+
getTempDir(pathname: string, createDir: boolean): string;
|
|
42
|
+
getTempDir(uuidDir: boolean, filename?: string, createDir?: boolean): string;
|
|
43
|
+
getTempDir(pathname?: string, filename?: string, createDir?: boolean): string;
|
|
44
|
+
canRead(uri: string, options?: PermissionOptions): boolean;
|
|
45
|
+
canWrite(uri: string, options?: PermissionOptions): boolean;
|
|
46
|
+
readFile(src: string): Buffer | undefined;
|
|
47
|
+
readFile(src: string, options?: ReadFileOptions): Promise<Buffer | string> | Buffer | string | undefined;
|
|
48
|
+
readFile(src: string, promises: true): Promise<Buffer | undefined>;
|
|
49
|
+
readFile(src: string, options: ReadFileOptions, promises: true): Promise<Buffer | string | undefined>;
|
|
50
|
+
readFile(src: string, callback: ReadFileCallback<Buffer | string>): Buffer | string | undefined;
|
|
51
|
+
readFile(src: string, options: ReadFileOptions, callback: ReadFileCallback<Buffer | string>): Buffer | string | undefined;
|
|
52
|
+
writeFile(src: string, data: BufferView, options?: WriteFileOptions): boolean;
|
|
53
|
+
writeFile(src: string, data: BufferView, promises: true): Promise<boolean>;
|
|
54
|
+
writeFile(src: string, data: BufferView, options: WriteFileOptions, promises: true): Promise<boolean>;
|
|
55
|
+
writeFile(src: string, data: BufferView, callback: NoParamCallback): void;
|
|
56
|
+
writeFile(src: string, data: BufferView, options: WriteFileOptions, callback: NoParamCallback): void;
|
|
57
|
+
deleteFile(src: string, options?: DeleteFileOptions): boolean;
|
|
58
|
+
deleteFile(src: string, promises: true): Promise<boolean>;
|
|
59
|
+
deleteFile(src: string, options: DeleteFileOptions, promises: true): Promise<boolean>;
|
|
60
|
+
deleteFile(src: string, callback: NoParamCallback): void;
|
|
61
|
+
deleteFile(src: string, options: DeleteFileOptions, callback: NoParamCallback): void;
|
|
62
|
+
copyFile(src: string, dest: string, options?: CopyFileOptions): boolean;
|
|
63
|
+
copyFile(src: string, dest: string, promises: true): Promise<boolean>;
|
|
64
|
+
copyFile(src: string, dest: string, options: CopyFileOptions, promises: true): Promise<boolean>;
|
|
65
|
+
copyFile(src: string, dest: string, callback: NoParamCallback): void;
|
|
66
|
+
copyFile(src: string, dest: string, options: CopyFileOptions, callback: NoParamCallback): void;
|
|
67
|
+
moveFile(src: string, dest: string, options?: MoveFileOptions): boolean;
|
|
68
|
+
moveFile(src: string, dest: string, promises: true): Promise<boolean>;
|
|
69
|
+
moveFile(src: string, dest: string, options: MoveFileOptions, promises: true): Promise<boolean>;
|
|
70
|
+
moveFile(src: string, dest: string, callback: NoParamCallback): void;
|
|
71
|
+
moveFile(src: string, dest: string, options: MoveFileOptions, callback: NoParamCallback): void;
|
|
72
|
+
createDir(src: string, options?: CreateDirOptions): boolean;
|
|
73
|
+
createDir(src: string, promises: true): Promise<boolean>;
|
|
74
|
+
createDir(src: string, options: CreateDirOptions, promises: true): Promise<boolean>;
|
|
75
|
+
createDir(src: string, callback: NoParamCallback): void;
|
|
76
|
+
createDir(src: string, options: CreateDirOptions, callback: NoParamCallback): void;
|
|
77
|
+
removeDir(src: string, options?: RemoveDirOptions): boolean;
|
|
78
|
+
removeDir(src: string, promises: true): Promise<boolean>;
|
|
79
|
+
removeDir(src: string, options: RemoveDirOptions, promises: true): Promise<boolean>;
|
|
80
|
+
removeDir(src: string, callback: NoParamCallback): void;
|
|
81
|
+
removeDir(src: string, options: RemoveDirOptions, callback: NoParamCallback): void;
|
|
82
|
+
allSettled(values: readonly PromiseLike<unknown>[], rejected?: LogValue, type?: LogType): Promise<PromiseFulfilledResult<unknown>[]>;
|
|
83
|
+
allSettled(values: readonly PromiseLike<unknown>[], rejected?: LogValue, options?: LogFailOptions): Promise<PromiseFulfilledResult<unknown>[]>;
|
|
84
|
+
formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void;
|
|
85
|
+
formatFail(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogFailOptions): void;
|
|
86
|
+
writeFail(value: LogValue, message?: unknown, type?: LogType): void;
|
|
87
|
+
writeFail(value: LogValue, message?: unknown, options?: LogFailOptions): void;
|
|
88
|
+
writeTimeProcess(title: string, value: string, startTime: LogTime, options?: LogProcessOptions): void;
|
|
89
|
+
writeTimeElapsed(title: string, value: LogValue, startTime: LogTime, options?: LogMessageOptions): void;
|
|
90
|
+
checkPackage(err: unknown, name: string | undefined, type: LogType): boolean;
|
|
91
|
+
checkPackage(err: unknown, name: string | undefined, options: LogFailOptions): boolean;
|
|
92
|
+
checkPackage(err: unknown, name: string | undefined, value?: LogValue, options?: LogFailOptions | LogType): boolean;
|
|
93
|
+
checkFail(message: unknown, options: LogFailOptions): LogArguments | false | undefined;
|
|
94
|
+
writeLog(component: LogComponent, queue?: boolean): void;
|
|
95
|
+
writeLog(type: StatusType, value: unknown, options: LogOptions): void;
|
|
96
|
+
writeLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number): void;
|
|
97
|
+
addLog(component: LogComponent, queue?: boolean): void;
|
|
98
|
+
addLog(type: StatusType, value: unknown, options: LogOptions): void;
|
|
99
|
+
addLog(type: StatusType, value: unknown, from: string, source?: string): void;
|
|
100
|
+
addLog(type: StatusType, value: unknown, timeStamp?: LogDate, from?: string, source?: string): void;
|
|
101
|
+
addLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number, from?: string, source?: string): void;
|
|
102
|
+
getLog(...type: StatusType[]): LogStatus<StatusType>[];
|
|
103
|
+
flushLog(): void;
|
|
104
|
+
willAbort(value: unknown): boolean;
|
|
105
|
+
hasOwnPermission(): boolean;
|
|
106
|
+
isFatal(err?: unknown): boolean;
|
|
107
|
+
detach(): void;
|
|
108
|
+
reset(): void;
|
|
109
|
+
get moduleName(): string;
|
|
110
|
+
set host(value);
|
|
111
|
+
get host(): IHost | null;
|
|
112
|
+
set permission(value);
|
|
113
|
+
get permission(): IPermission | null;
|
|
114
|
+
get aborted(): boolean;
|
|
115
|
+
set abortable(value);
|
|
116
|
+
get abortable(): boolean;
|
|
117
|
+
get threadable(): boolean;
|
|
118
|
+
set sessionId(value);
|
|
119
|
+
get sessionId(): string;
|
|
120
|
+
set broadcastId(value);
|
|
121
|
+
get broadcastId(): string | string[];
|
|
122
|
+
set silent(value);
|
|
123
|
+
get silent(): boolean;
|
|
124
|
+
get logType(): LOG_TYPE;
|
|
125
|
+
set logLevel(value: number | string);
|
|
126
|
+
get logLevel(): number;
|
|
127
|
+
get statusType(): STATUS_TYPE;
|
|
128
|
+
set tempDir(value);
|
|
129
|
+
get tempDir(): string;
|
|
130
|
+
|
|
131
|
+
/* EventEmitter */
|
|
132
|
+
on(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
|
|
133
|
+
on(event: "error", listener: (err: Error) => void): this;
|
|
134
|
+
on(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
|
|
135
|
+
on(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
|
|
136
|
+
on(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
|
|
137
|
+
on(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
|
|
138
|
+
on(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
|
|
139
|
+
on(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
|
|
140
|
+
on(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
|
|
141
|
+
once(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
|
|
142
|
+
once(event: "error", listener: (err: Error) => void): this;
|
|
143
|
+
once(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
|
|
144
|
+
once(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
|
|
145
|
+
once(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
|
|
146
|
+
once(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
|
|
147
|
+
once(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
|
|
148
|
+
once(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
|
|
149
|
+
once(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
|
|
150
|
+
emit(event: "exec", command: ExecCommand, options?: SpawnOptions): boolean;
|
|
151
|
+
emit(event: "error", err: Error): boolean;
|
|
152
|
+
emit(event: "file:read", src: string, data: Buffer | string, options?: ReadFileOptions): boolean;
|
|
153
|
+
emit(event: "file:write", src: string, options?: WriteFileOptions): boolean;
|
|
154
|
+
emit(event: "file:delete", src: string, options?: DeleteFileOptions): boolean;
|
|
155
|
+
emit(event: "file:copy", dest: string, options?: CopyFileOptions): boolean;
|
|
156
|
+
emit(event: "file:move", dest: string, options?: MoveFileOptions): boolean;
|
|
157
|
+
emit(event: "dir:create", src: string, options?: CreateDirOptions): boolean;
|
|
158
|
+
emit(event: "dir:remove", src: string, options?: RemoveDirOptions): boolean;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
interface ModuleConstructor {
|
|
162
|
+
PROCESS_TIMEOUT: number;
|
|
163
|
+
LOG_STYLE_FAIL: LogMessageOptions;
|
|
164
|
+
LOG_STYLE_SUCCESS: LogMessageOptions;
|
|
165
|
+
LOG_STYLE_INFO: LogMessageOptions;
|
|
166
|
+
LOG_STYLE_WARN: LogMessageOptions;
|
|
167
|
+
LOG_STYLE_NOTICE: LogMessageOptions;
|
|
168
|
+
LOG_STYLE_REVERSE: LogMessageOptions;
|
|
169
|
+
readonly VERSION: string;
|
|
170
|
+
readonly LOG_TYPE: LOG_TYPE;
|
|
171
|
+
readonly LOG_FORMAT: LoggerFormatSettings<LoggerFormat<number>>;
|
|
172
|
+
readonly STATUS_TYPE: STATUS_TYPE;
|
|
173
|
+
readonly PLATFORM_WIN32: boolean;
|
|
174
|
+
readonly MAX_TIMEOUT: number;
|
|
175
|
+
readonly TEMP_DIR: string;
|
|
176
|
+
/** @deprecated Types.supported */
|
|
177
|
+
supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
|
|
178
|
+
formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void;
|
|
179
|
+
writeFail(value: LogValue, message?: unknown, options?: LogFailOptions | LogType): void;
|
|
180
|
+
enabled(key: string, username?: string): boolean;
|
|
181
|
+
parseFunction(value: unknown, options?: ParseFunctionOptions): ((...args: unknown[]) => Promise<unknown> | unknown) | null;
|
|
182
|
+
parseFunction(value: unknown, absolute: boolean, sync?: boolean): ((...args: unknown[]) => Promise<unknown> | unknown) | null;
|
|
183
|
+
asString(value: unknown, cacheKey?: boolean | "throws"): string;
|
|
184
|
+
asHash(data: BinaryLike, options?: AsHashOptions): string;
|
|
185
|
+
asHash(data: BinaryLike, algorithm?: string, options?: HashOptions): string;
|
|
186
|
+
asHash(data: BinaryLike, algorithm?: string, digest?: BinaryToTextEncoding): string;
|
|
187
|
+
readHash(value: string | URL, options?: ReadHashOptions): Promise<string>;
|
|
188
|
+
toPosix(value: unknown, normalize: boolean): string;
|
|
189
|
+
toPosix(value: unknown, filename?: string, normalize?: boolean): string;
|
|
190
|
+
hasLogType(value: LogType): boolean;
|
|
191
|
+
isURL(value: string, ...exclude: string[]): boolean;
|
|
192
|
+
isFile(value: string | URL, type?: ProtocolType): boolean;
|
|
193
|
+
isDir(value: string | URL): boolean;
|
|
194
|
+
isPath(value: string | URL, type?: "unc" | "unc-exists"): boolean;
|
|
195
|
+
isPath(value: string | URL, isFile?: boolean): boolean;
|
|
196
|
+
isErrorCode(err: unknown, ...code: string[]): boolean;
|
|
197
|
+
fromLocalPath(value: string): string;
|
|
198
|
+
resolveFile(value: string): string;
|
|
199
|
+
resolvePath(value: string, base: string | URL): string;
|
|
200
|
+
joinPath(...values: [...paths: unknown[], normalize: boolean][]): string;
|
|
201
|
+
joinPath(...values: unknown[]): string;
|
|
202
|
+
normalizePath(value: unknown, flags?: boolean | number): string;
|
|
203
|
+
createDir(value: string | URL, overwrite?: boolean): boolean;
|
|
204
|
+
removeDir(value: string | URL, sinceCreated: number, recursive?: boolean): boolean;
|
|
205
|
+
removeDir(value: string | URL, empty?: boolean, recursive?: boolean): boolean;
|
|
206
|
+
copyDir(src: string | URL, dest: string | URL, move?: boolean, recursive?: boolean): Promise<CopyDirResult>;
|
|
207
|
+
copyDir(src: string | URL, dest: string | URL, options?: CopyDirOptions): Promise<CopyDirResult>;
|
|
208
|
+
renameFile(src: string | URL, dest: string | URL, throws?: boolean): boolean;
|
|
209
|
+
streamFile(src: string, cache: boolean): Promise<Buffer | string>;
|
|
210
|
+
streamFile(src: string, options: ReadBufferOptions): Promise<Buffer | string>;
|
|
211
|
+
streamFile(src: string, cache?: boolean | ReadBufferOptions, options?: ReadBufferOptions): Promise<Buffer | string>;
|
|
212
|
+
readText(value: string | URL, cache: boolean): string;
|
|
213
|
+
readText(value: string | URL, options: ReadTextOptions): Promise<string> | string;
|
|
214
|
+
readText(value: string | URL, encoding?: BufferEncoding | ReadTextOptions, cache?: boolean): string;
|
|
215
|
+
readBuffer(value: string | URL, options: ReadBufferOptions): Promise<Buffer | null> | Buffer | null;
|
|
216
|
+
readBuffer(value: string | URL, cache?: boolean | ReadBufferOptions): Buffer | null;
|
|
217
|
+
resolveMime(data: string | Buffer | Uint8Array | ArrayBuffer): Promise<FileTypeResult | undefined>;
|
|
218
|
+
lookupMime(value: string, extension?: boolean): string;
|
|
219
|
+
initCpuUsage(instance?: IModule): CpuUsage;
|
|
220
|
+
getCpuUsage(start: CpuUsage, format: true): string;
|
|
221
|
+
getCpuUsage(start: CpuUsage, format?: boolean): number;
|
|
222
|
+
getMemUsage(format: true): string;
|
|
223
|
+
getMemUsage(format?: boolean): number;
|
|
224
|
+
formatCpuMem(start: CpuUsage, all?: boolean): string;
|
|
225
|
+
getPackageVersion(name: string | [string, string], startDir: string, baseDir?: string): string;
|
|
226
|
+
getPackageVersion(name: string | [string, string], unstable?: boolean, startDir?: string, baseDir?: string): string;
|
|
227
|
+
checkSemVer(name: string | [string, string], options: CheckSemVerOptions): boolean;
|
|
228
|
+
/** @deprecated options */
|
|
229
|
+
checkSemVer(name: string | [string, string], min: number | string, max?: number | string, unstable?: boolean, startDir?: string): boolean;
|
|
230
|
+
checkSemVer(name: string | [string, string], min: number | string, max: number | string, options?: Omit<CheckSemVerOptions, "min" | "max" | "equals">): boolean;
|
|
231
|
+
sanitizeCmd(value: string): string;
|
|
232
|
+
sanitizeArgs(value: string, doubleQuote?: boolean): string;
|
|
233
|
+
sanitizeArgs(values: string[], doubleQuote?: boolean): string[];
|
|
234
|
+
purgeMemory(percent: number, parent: boolean): Promise<number>;
|
|
235
|
+
purgeMemory(percent: number, limit: number, parent?: boolean): Promise<number>;
|
|
236
|
+
purgeMemory(percent?: number, limit?: number | boolean, parent?: unknown): Promise<number>;
|
|
237
|
+
canWrite(name: "temp" | "home"): boolean;
|
|
238
|
+
loadSettings(settings: Settings, password?: string): boolean;
|
|
239
|
+
readonly prototype: IModule<IHost>;
|
|
240
|
+
new(): IModule<IHost>;
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Settings
|
|
245
|
+
|
|
246
|
+
```typescript
|
|
247
|
+
import type { BackgroundColor, ForegroundColor, LogMessageOptions, LogTypeValue, LoggerProgress, LoggerStatus } from "./logger";
|
|
248
|
+
import type { LoggerProcessSettings } from "./settings";
|
|
249
|
+
|
|
250
|
+
import type { BinaryLike, CipherGCMTypes } from "crypto";
|
|
251
|
+
import type { SecureVersion } from "tls";
|
|
252
|
+
|
|
253
|
+
interface NodeModule {
|
|
254
|
+
process?: {
|
|
255
|
+
cpu_usage?: boolean;
|
|
256
|
+
memory_usage?: boolean;
|
|
257
|
+
inline?: boolean;
|
|
258
|
+
};
|
|
259
|
+
require?: {
|
|
260
|
+
ext?: string | string[] | boolean;
|
|
261
|
+
npm?: boolean;
|
|
262
|
+
inline?: boolean;
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
interface ProcessModule {
|
|
267
|
+
env?: {
|
|
268
|
+
apply?: boolean;
|
|
269
|
+
};
|
|
270
|
+
cipher?: {
|
|
271
|
+
algorithm?: CipherGCMTypes;
|
|
272
|
+
key?: BinaryLike;
|
|
273
|
+
iv?: BinaryLike;
|
|
274
|
+
};
|
|
275
|
+
password?: string;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
interface MemoryModule {
|
|
279
|
+
settings?: {
|
|
280
|
+
users?: boolean | string[];
|
|
281
|
+
cache_disk?: {
|
|
282
|
+
enabled?: boolean;
|
|
283
|
+
min_size?: number | string;
|
|
284
|
+
max_size?: number | string;
|
|
285
|
+
include?: string[];
|
|
286
|
+
exclude?: string[];
|
|
287
|
+
expires?: number | string;
|
|
288
|
+
};
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
interface PermissionModule {
|
|
293
|
+
home_read?: boolean;
|
|
294
|
+
home_write?: boolean;
|
|
295
|
+
process_exec?: (string | ExecOptions)[];
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
interface ErrorModule {
|
|
299
|
+
out?: string | (err: Error, data: LogTypeValue, require?: NodeRequire) => void;
|
|
300
|
+
fatal?: boolean;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
interface TempModule {
|
|
304
|
+
dir?: string;
|
|
305
|
+
env?: string;
|
|
306
|
+
write?: boolean;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
interface LoggerModule {
|
|
310
|
+
enabled?: boolean;
|
|
311
|
+
level?: number,
|
|
312
|
+
production?: string[];
|
|
313
|
+
format?: {
|
|
314
|
+
title?: {
|
|
315
|
+
width?: number;
|
|
316
|
+
color?: ForegroundColor;
|
|
317
|
+
bg_color?: BackgroundColor;
|
|
318
|
+
bold?: boolean;
|
|
319
|
+
justify?: "left" | "center" | "right";
|
|
320
|
+
braces?: string;
|
|
321
|
+
as?: StringMap;
|
|
322
|
+
};
|
|
323
|
+
value?: {
|
|
324
|
+
width?: number;
|
|
325
|
+
color?: ForegroundColor;
|
|
326
|
+
bg_color?: BackgroundColor;
|
|
327
|
+
bold?: boolean;
|
|
328
|
+
justify?: "left" | "center" | "right";
|
|
329
|
+
},
|
|
330
|
+
hint?: {
|
|
331
|
+
width?: number;
|
|
332
|
+
color?: ForegroundColor;
|
|
333
|
+
bg_color?: BackgroundColor;
|
|
334
|
+
bold?: boolean;
|
|
335
|
+
braces?: [string, string];
|
|
336
|
+
as?: StringMap;
|
|
337
|
+
unit?: "auto" | "s" | "ms";
|
|
338
|
+
};
|
|
339
|
+
message?: {
|
|
340
|
+
width?: number;
|
|
341
|
+
color?: ForegroundColor;
|
|
342
|
+
bg_color?: BackgroundColor;
|
|
343
|
+
bold?: boolean;
|
|
344
|
+
braces?: [string, string];
|
|
345
|
+
};
|
|
346
|
+
meter?: {
|
|
347
|
+
color?: ForegroundColor;
|
|
348
|
+
bg_color?: BackgroundColor;
|
|
349
|
+
bg_alt_color?: BackgroundColor;
|
|
350
|
+
bold?: boolean;
|
|
351
|
+
};
|
|
352
|
+
error?: {
|
|
353
|
+
color?: ForegroundColor;
|
|
354
|
+
alt_color?: ForegroundColor;
|
|
355
|
+
bg_color?: BackgroundColor;
|
|
356
|
+
braces?: [string, string];
|
|
357
|
+
};
|
|
358
|
+
};
|
|
359
|
+
meter?: {
|
|
360
|
+
http?: number;
|
|
361
|
+
image?: number;
|
|
362
|
+
compress?: number;
|
|
363
|
+
process?: number;
|
|
364
|
+
};
|
|
365
|
+
broadcast?: {
|
|
366
|
+
enabled?: boolean;
|
|
367
|
+
out?: string | (value: string, options: LogMessageOptions, require?: NodeRequire) => void;
|
|
368
|
+
color?: boolean;
|
|
369
|
+
port?: number | number[];
|
|
370
|
+
secure?: {
|
|
371
|
+
port?: number | number[];
|
|
372
|
+
ca?: string;
|
|
373
|
+
key?: string;
|
|
374
|
+
cert?: string;
|
|
375
|
+
version?: SecureVersion
|
|
376
|
+
};
|
|
377
|
+
};
|
|
378
|
+
color?: boolean;
|
|
379
|
+
message?: boolean;
|
|
380
|
+
stdout?: boolean;
|
|
381
|
+
abort?: boolean;
|
|
382
|
+
status?: boolean | LoggerStatus;
|
|
383
|
+
progress?: LoggerProgress;
|
|
384
|
+
unknown?: boolean | LoggerColor;
|
|
385
|
+
system?: boolean | LoggerColor;
|
|
386
|
+
process?: boolean | LoggerProcessSettings;
|
|
387
|
+
image?: boolean | LoggerColor;
|
|
388
|
+
compress?: boolean | LoggerColor;
|
|
389
|
+
watch?: boolean | LoggerColor;
|
|
390
|
+
file?: boolean | LoggerColor;
|
|
391
|
+
cloud?: boolean | LoggerColor;
|
|
392
|
+
db?: boolean | LoggerColor;
|
|
393
|
+
time_elapsed?: boolean | LoggerColor;
|
|
394
|
+
time_process?: boolean | LoggerColor;
|
|
395
|
+
exec?: boolean | LoggerColor;
|
|
396
|
+
http?: boolean | LoggerColor;
|
|
397
|
+
node?: boolean | LoggerColor;
|
|
398
|
+
session_id?: boolean | number;
|
|
399
|
+
stack_trace?: boolean | number;
|
|
400
|
+
}
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
## References
|
|
404
|
+
|
|
405
|
+
- https://www.unpkg.com/@e-mc/types@0.10.2/lib/core.d.ts
|
|
406
|
+
- https://www.unpkg.com/@e-mc/types@0.10.2/lib/logger.d.ts
|
|
407
|
+
- https://www.unpkg.com/@e-mc/types@0.10.2/lib/module.d.ts
|
|
408
|
+
- https://www.unpkg.com/@e-mc/types@0.10.2/lib/node.d.ts
|
|
409
|
+
- https://www.unpkg.com/@e-mc/types@0.10.2/lib/settings.d.ts
|
|
410
|
+
|
|
411
|
+
* https://www.npmjs.com/package/@types/node
|
|
412
|
+
|
|
413
|
+
## LICENSE
|
|
414
|
+
|
|
414
415
|
BSD 3-Clause
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ModuleConstructor } from '../types/lib';
|
|
2
|
-
|
|
3
|
-
declare const Module: ModuleConstructor;
|
|
4
|
-
|
|
1
|
+
import type { ModuleConstructor } from '../types/lib';
|
|
2
|
+
|
|
3
|
+
declare const Module: ModuleConstructor;
|
|
4
|
+
|
|
5
5
|
export = Module;
|
package/index.js
CHANGED
|
@@ -298,9 +298,8 @@ function getLatestRelease(result, unstable = false) {
|
|
|
298
298
|
return result[0];
|
|
299
299
|
}
|
|
300
300
|
function applyStyle(options, style) {
|
|
301
|
-
var _h;
|
|
302
301
|
for (const attr in style) {
|
|
303
|
-
|
|
302
|
+
options[attr] ??= style[attr];
|
|
304
303
|
}
|
|
305
304
|
return options;
|
|
306
305
|
}
|
|
@@ -310,51 +309,51 @@ function checkColorOptions(type, settings, options) {
|
|
|
310
309
|
}
|
|
311
310
|
let result = false;
|
|
312
311
|
if (settings.valueColor) {
|
|
313
|
-
options.valueColor
|
|
312
|
+
options.valueColor ||= settings.valueColor;
|
|
314
313
|
result = true;
|
|
315
314
|
}
|
|
316
315
|
if (settings.valueBgColor) {
|
|
317
|
-
options.valueBgColor
|
|
316
|
+
options.valueBgColor ||= settings.valueBgColor;
|
|
318
317
|
result = true;
|
|
319
318
|
}
|
|
320
319
|
if (typeof settings.valueBold === 'boolean') {
|
|
321
|
-
options.valueBold
|
|
320
|
+
options.valueBold ??= settings.valueBold;
|
|
322
321
|
}
|
|
323
322
|
if (settings.hintColor) {
|
|
324
|
-
options.hintColor
|
|
323
|
+
options.hintColor ||= settings.hintColor;
|
|
325
324
|
result = true;
|
|
326
325
|
}
|
|
327
326
|
if (settings.hintBgColor) {
|
|
328
|
-
options.hintBgColor
|
|
327
|
+
options.hintBgColor ||= settings.hintBgColor;
|
|
329
328
|
result = true;
|
|
330
329
|
}
|
|
331
330
|
if (typeof settings.hintBold === 'boolean') {
|
|
332
|
-
options.hintBold
|
|
331
|
+
options.hintBold ??= settings.hintBold;
|
|
333
332
|
}
|
|
334
333
|
if (type & types_1.LOG_TYPE.FAIL) {
|
|
335
334
|
return result;
|
|
336
335
|
}
|
|
337
336
|
if (settings.titleColor) {
|
|
338
|
-
options.titleColor
|
|
337
|
+
options.titleColor ||= settings.titleColor;
|
|
339
338
|
result = true;
|
|
340
339
|
}
|
|
341
340
|
if (settings.titleBgColor) {
|
|
342
|
-
options.titleBgColor
|
|
341
|
+
options.titleBgColor ||= settings.titleBgColor;
|
|
343
342
|
result = true;
|
|
344
343
|
}
|
|
345
344
|
if (typeof settings.titleBold === 'boolean') {
|
|
346
|
-
options.titleBold
|
|
345
|
+
options.titleBold ??= settings.titleBold;
|
|
347
346
|
}
|
|
348
347
|
if (settings.messageColor) {
|
|
349
|
-
options.messageColor
|
|
348
|
+
options.messageColor ||= settings.messageColor;
|
|
350
349
|
result = true;
|
|
351
350
|
}
|
|
352
351
|
if (settings.messageBgColor) {
|
|
353
|
-
options.messageBgColor
|
|
352
|
+
options.messageBgColor ||= settings.messageBgColor;
|
|
354
353
|
result = true;
|
|
355
354
|
}
|
|
356
355
|
if (typeof settings.messageBold === 'boolean') {
|
|
357
|
-
options.messageBold
|
|
356
|
+
options.messageBold ??= settings.messageBold;
|
|
358
357
|
}
|
|
359
358
|
return result;
|
|
360
359
|
}
|
|
@@ -638,12 +637,11 @@ function checkFunction(value) {
|
|
|
638
637
|
return null;
|
|
639
638
|
}
|
|
640
639
|
function encryptMessage(data, cipher, algorithm) {
|
|
641
|
-
var _h;
|
|
642
640
|
if (cipher?.key && cipher.iv) {
|
|
643
|
-
algorithm
|
|
641
|
+
algorithm ||= cipher.algorithm || 'aes-256-gcm';
|
|
644
642
|
const result = (0, types_1.encryptUTF8)(algorithm, cipher.key, cipher.iv, data);
|
|
645
643
|
if (result) {
|
|
646
|
-
VALUES[
|
|
644
|
+
VALUES["process.cipher.algorithm"] ||= algorithm;
|
|
647
645
|
return result;
|
|
648
646
|
}
|
|
649
647
|
}
|
|
@@ -768,7 +766,7 @@ function checkExDev(err, src, dest) {
|
|
|
768
766
|
return false;
|
|
769
767
|
}
|
|
770
768
|
function applySessionId(instance, options) {
|
|
771
|
-
options.sessionId
|
|
769
|
+
options.sessionId ??= instance.sessionId;
|
|
772
770
|
let value = options.broadcastId;
|
|
773
771
|
if (value === undefined) {
|
|
774
772
|
value = instance.broadcastId;
|
|
@@ -945,7 +943,7 @@ class Module extends EventEmitter {
|
|
|
945
943
|
this[_g] = null;
|
|
946
944
|
}
|
|
947
945
|
static get VERSION() {
|
|
948
|
-
return "0.10.
|
|
946
|
+
return "0.10.2";
|
|
949
947
|
}
|
|
950
948
|
static get LOG_TYPE() {
|
|
951
949
|
return types_1.LOG_TYPE;
|
|
@@ -1106,7 +1104,7 @@ class Module extends EventEmitter {
|
|
|
1106
1104
|
else if (type & 2) {
|
|
1107
1105
|
if (!checkColorOptions(type, SETTINGS.node, options)) {
|
|
1108
1106
|
applyStyle(options, this.LOG_STYLE_REVERSE);
|
|
1109
|
-
options.hintColor
|
|
1107
|
+
options.hintColor ||= 'yellow';
|
|
1110
1108
|
}
|
|
1111
1109
|
titleJustify = 'center';
|
|
1112
1110
|
}
|
|
@@ -1140,7 +1138,7 @@ class Module extends EventEmitter {
|
|
|
1140
1138
|
}
|
|
1141
1139
|
if (type & 128) {
|
|
1142
1140
|
if (!checkColorOptions(type, SETTINGS.time_elapsed, options)) {
|
|
1143
|
-
options.hintColor
|
|
1141
|
+
options.hintColor ||= 'yellow';
|
|
1144
1142
|
}
|
|
1145
1143
|
if (options.titleBgColor) {
|
|
1146
1144
|
titleJustify = 'center';
|
|
@@ -1148,7 +1146,7 @@ class Module extends EventEmitter {
|
|
|
1148
1146
|
}
|
|
1149
1147
|
else if (type & 256) {
|
|
1150
1148
|
if (options.failed) {
|
|
1151
|
-
options.messageBgColor
|
|
1149
|
+
options.messageBgColor ||= 'bgGrey';
|
|
1152
1150
|
}
|
|
1153
1151
|
else {
|
|
1154
1152
|
const { color, bgColor, bold } = format.meter;
|
|
@@ -1161,7 +1159,7 @@ class Module extends EventEmitter {
|
|
|
1161
1159
|
}
|
|
1162
1160
|
}
|
|
1163
1161
|
if (bold) {
|
|
1164
|
-
options.messageBold
|
|
1162
|
+
options.messageBold ??= true;
|
|
1165
1163
|
}
|
|
1166
1164
|
}
|
|
1167
1165
|
}
|
|
@@ -1180,7 +1178,7 @@ class Module extends EventEmitter {
|
|
|
1180
1178
|
}
|
|
1181
1179
|
if (!hintColor && !hintBgColor) {
|
|
1182
1180
|
({ color: hintColor, bgColor: hintBgColor } = formatHint);
|
|
1183
|
-
hintBold
|
|
1181
|
+
hintBold ??= formatHint.bold;
|
|
1184
1182
|
}
|
|
1185
1183
|
value = getValue();
|
|
1186
1184
|
hint = coloring ? (L && chalk.blackBright(L)) + formatLogColumn(truncateEnd(hint, hintWidth), hintColor, hintBgColor, hintBold) + chalk.blackBright(R) : L + truncateEnd(hint, hintWidth) + R;
|
|
@@ -1204,7 +1202,7 @@ class Module extends EventEmitter {
|
|
|
1204
1202
|
}
|
|
1205
1203
|
if (!valueColor && !valueBgColor) {
|
|
1206
1204
|
({ color: valueColor, bgColor: valueBgColor } = formatValue);
|
|
1207
|
-
valueBold
|
|
1205
|
+
valueBold ??= formatValue.bold;
|
|
1208
1206
|
}
|
|
1209
1207
|
try {
|
|
1210
1208
|
let v = value, i = id, m = message;
|
|
@@ -1217,7 +1215,7 @@ class Module extends EventEmitter {
|
|
|
1217
1215
|
const formatMessage = format.message;
|
|
1218
1216
|
if (!messageColor && !messageBgColor) {
|
|
1219
1217
|
({ color: messageColor, bgColor: messageBgColor, bold: messageBold } = formatMessage);
|
|
1220
|
-
messageBold
|
|
1218
|
+
messageBold ??= formatMessage.bold;
|
|
1221
1219
|
}
|
|
1222
1220
|
const [L, R] = formatMessage.braces;
|
|
1223
1221
|
let u = unit;
|
|
@@ -1371,7 +1369,7 @@ class Module extends EventEmitter {
|
|
|
1371
1369
|
}
|
|
1372
1370
|
}
|
|
1373
1371
|
try {
|
|
1374
|
-
result
|
|
1372
|
+
result ||= (0, types_1.asFunction)(fs.readFileSync(pathname, 'utf-8'), sync);
|
|
1375
1373
|
}
|
|
1376
1374
|
catch (err) {
|
|
1377
1375
|
this.writeFail(["Unable to read file", value], err, 32);
|
|
@@ -2030,7 +2028,7 @@ class Module extends EventEmitter {
|
|
|
2030
2028
|
return (minStreamSize !== undefined ? Promise.resolve(null) : null);
|
|
2031
2029
|
}
|
|
2032
2030
|
static async resolveMime(data) {
|
|
2033
|
-
FILETYPE_ESM
|
|
2031
|
+
FILETYPE_ESM ||= await (0, types_1.importESM)('file-type');
|
|
2034
2032
|
return typeof data === 'string' ? FILETYPE_ESM.fileTypeFromFile(data) : data instanceof stream.Readable ? FILETYPE_ESM.fileTypeFromStream(data) : FILETYPE_ESM.fileTypeFromBuffer(data);
|
|
2035
2033
|
}
|
|
2036
2034
|
static lookupMime(value, extension) {
|
|
@@ -2225,11 +2223,19 @@ class Module extends EventEmitter {
|
|
|
2225
2223
|
return '0.0.0';
|
|
2226
2224
|
}
|
|
2227
2225
|
static checkSemVer(name, min = 0, max = Infinity, unstable, startDir) {
|
|
2226
|
+
let equals, includes;
|
|
2228
2227
|
if ((0, types_1.isObject)(min)) {
|
|
2229
|
-
({ min = 0, max = Infinity, unstable, startDir } = min);
|
|
2228
|
+
({ min = 0, max = Infinity, unstable, startDir, equals, includes } = min);
|
|
2230
2229
|
}
|
|
2231
2230
|
else if ((0, types_1.isObject)(unstable)) {
|
|
2232
|
-
({ unstable, startDir } = unstable);
|
|
2231
|
+
({ unstable, startDir, includes } = unstable);
|
|
2232
|
+
}
|
|
2233
|
+
let version = this.getPackageVersion(name, unstable, startDir);
|
|
2234
|
+
if (version === '0.0.0') {
|
|
2235
|
+
return false;
|
|
2236
|
+
}
|
|
2237
|
+
if (equals) {
|
|
2238
|
+
return equals === version;
|
|
2233
2239
|
}
|
|
2234
2240
|
if (typeof min === 'number' && Math.floor(min) !== min) {
|
|
2235
2241
|
min = min.toString();
|
|
@@ -2238,7 +2244,7 @@ class Module extends EventEmitter {
|
|
|
2238
2244
|
max = max.toString();
|
|
2239
2245
|
}
|
|
2240
2246
|
const minVersion = typeof min === 'string' ? min.split('.').map(ver => parseInt(ver)) : [min];
|
|
2241
|
-
let maxVersion, maxRange;
|
|
2247
|
+
let maxVersion, maxRange = false;
|
|
2242
2248
|
if (typeof max === 'string') {
|
|
2243
2249
|
maxVersion = max.split('.').map(ver => parseInt(ver));
|
|
2244
2250
|
}
|
|
@@ -2246,13 +2252,9 @@ class Module extends EventEmitter {
|
|
|
2246
2252
|
maxVersion = [Infinity];
|
|
2247
2253
|
}
|
|
2248
2254
|
else {
|
|
2249
|
-
maxVersion = [max - 1];
|
|
2255
|
+
maxVersion = [max - (includes ? 0 : 1)];
|
|
2250
2256
|
maxRange = true;
|
|
2251
2257
|
}
|
|
2252
|
-
let version = this.getPackageVersion(name, unstable, startDir);
|
|
2253
|
-
if (version === '0.0.0') {
|
|
2254
|
-
return false;
|
|
2255
|
-
}
|
|
2256
2258
|
version = version.split('.').map(ver => parseInt(ver));
|
|
2257
2259
|
for (let i = 0, length = Math.max(version.length, minVersion.length), lower = false, upper = false; i < length; ++i) {
|
|
2258
2260
|
const ver = version[i] || 0;
|
|
@@ -2393,7 +2395,6 @@ class Module extends EventEmitter {
|
|
|
2393
2395
|
}
|
|
2394
2396
|
}
|
|
2395
2397
|
static loadSettings(settings, password) {
|
|
2396
|
-
var _h;
|
|
2397
2398
|
const current = VALUES["process.password"];
|
|
2398
2399
|
if (current) {
|
|
2399
2400
|
const proc = settings.process || {};
|
|
@@ -2455,7 +2456,7 @@ class Module extends EventEmitter {
|
|
|
2455
2456
|
VALUES["process.env.apply"] = env.apply;
|
|
2456
2457
|
}
|
|
2457
2458
|
if ((0, types_1.isString)(pwd)) {
|
|
2458
|
-
VALUES[
|
|
2459
|
+
VALUES["process.password"] ||= encryptMessage(pwd, cipher, null);
|
|
2459
2460
|
}
|
|
2460
2461
|
}
|
|
2461
2462
|
if (memory?.settings) {
|
|
@@ -2706,7 +2707,7 @@ class Module extends EventEmitter {
|
|
|
2706
2707
|
}
|
|
2707
2708
|
let dir = settings.temp_dir, env, write, modified;
|
|
2708
2709
|
if ((0, types_1.isPlainObject)(temp)) {
|
|
2709
|
-
dir
|
|
2710
|
+
dir ||= temp.dir;
|
|
2710
2711
|
if (temp.env) {
|
|
2711
2712
|
env = process.env[temp.env];
|
|
2712
2713
|
}
|
|
@@ -2747,7 +2748,7 @@ class Module extends EventEmitter {
|
|
|
2747
2748
|
} while ((dir !== "tmp") && (dir = "tmp"));
|
|
2748
2749
|
}
|
|
2749
2750
|
if (typeof write === 'boolean') {
|
|
2750
|
-
modified
|
|
2751
|
+
modified ||= VALUES["temp.write"] !== write;
|
|
2751
2752
|
VALUES["temp.write"] = write;
|
|
2752
2753
|
}
|
|
2753
2754
|
if (modified) {
|
|
@@ -2793,11 +2794,11 @@ class Module extends EventEmitter {
|
|
|
2793
2794
|
let result;
|
|
2794
2795
|
if ((0, types_1.isString)(pathname)) {
|
|
2795
2796
|
leading.push(pathname);
|
|
2796
|
-
createDir
|
|
2797
|
+
createDir ??= true;
|
|
2797
2798
|
}
|
|
2798
2799
|
if (uuidDir) {
|
|
2799
2800
|
leading.push(crypto.randomUUID());
|
|
2800
|
-
createDir
|
|
2801
|
+
createDir ??= true;
|
|
2801
2802
|
}
|
|
2802
2803
|
if ((createDir || increment > 0) && !Module.isDir(result = path.join(...leading))) {
|
|
2803
2804
|
const [output] = tryIncrementDir(result, increment);
|
|
@@ -2871,7 +2872,7 @@ class Module extends EventEmitter {
|
|
|
2871
2872
|
[options, promises, callback] = parseFileArgs(options, callback);
|
|
2872
2873
|
if (outSrc = hasFileSystem(this, 0, src, options)) {
|
|
2873
2874
|
let { encoding, requireExt, minStreamSize, cache } = options;
|
|
2874
|
-
encoding
|
|
2875
|
+
encoding &&= (0, types_1.getEncoding)(encoding);
|
|
2875
2876
|
const setCache = (data, cjs) => {
|
|
2876
2877
|
if (data) {
|
|
2877
2878
|
if (cache || cache !== false && autoMemoryCache()) {
|
|
@@ -2896,7 +2897,7 @@ class Module extends EventEmitter {
|
|
|
2896
2897
|
}
|
|
2897
2898
|
}
|
|
2898
2899
|
if (cache) {
|
|
2899
|
-
result
|
|
2900
|
+
result ||= (encoding ? getCacheItem(CACHE_READTEXT, outSrc) : getCacheItem(CACHE_READBUFFER, outSrc));
|
|
2900
2901
|
}
|
|
2901
2902
|
try {
|
|
2902
2903
|
if (!isNaN(minStreamSize = (0, types_1.alignSize)(minStreamSize)) || promises && fs.statSync(outSrc).size >= 2097152000) {
|
|
@@ -3301,7 +3302,7 @@ class Module extends EventEmitter {
|
|
|
3301
3302
|
return false;
|
|
3302
3303
|
}
|
|
3303
3304
|
async allSettled(tasks, rejected, options) {
|
|
3304
|
-
rejected
|
|
3305
|
+
rejected ||= "Unknown";
|
|
3305
3306
|
return Promise.allSettled(tasks).then(result => {
|
|
3306
3307
|
const items = [];
|
|
3307
3308
|
for (const item of result) {
|
|
@@ -3396,7 +3397,7 @@ class Module extends EventEmitter {
|
|
|
3396
3397
|
message = value;
|
|
3397
3398
|
value = '';
|
|
3398
3399
|
}
|
|
3399
|
-
value
|
|
3400
|
+
value ||= isFailed(options) ? "Failed" : "Success";
|
|
3400
3401
|
const duration = getTimeOffset(startTime, 0);
|
|
3401
3402
|
const args = [
|
|
3402
3403
|
(128 | type),
|
|
@@ -3457,7 +3458,7 @@ class Module extends EventEmitter {
|
|
|
3457
3458
|
if ((0, types_1.isPlainObject)(output)) {
|
|
3458
3459
|
output = { ...output };
|
|
3459
3460
|
if (Array.isArray(output.warn)) {
|
|
3460
|
-
(exec.warn
|
|
3461
|
+
(exec.warn ||= []).push(...output.warn);
|
|
3461
3462
|
}
|
|
3462
3463
|
delete output.command;
|
|
3463
3464
|
delete output.warn;
|
package/lib-v4.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { IModuleLibV4 } from '../types/lib/compat-v4';
|
|
2
|
-
|
|
3
|
-
declare const LibV4: IModuleLibV4;
|
|
4
|
-
|
|
1
|
+
import type { IModuleLibV4 } from '../types/lib/compat-v4';
|
|
2
|
+
|
|
3
|
+
declare const LibV4: IModuleLibV4;
|
|
4
|
+
|
|
5
5
|
export = LibV4;
|
package/package.json
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.10.
|
|
4
|
-
"description": "Module base class for E-mc.",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"types": "index.d.ts",
|
|
7
|
-
"publishConfig": {
|
|
8
|
-
"access": "public"
|
|
9
|
-
},
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/anpham6/e-mc.git",
|
|
13
|
-
"directory": "src/module"
|
|
14
|
-
},
|
|
15
|
-
"keywords": [
|
|
16
|
-
"squared",
|
|
17
|
-
"squared-functions"
|
|
18
|
-
],
|
|
19
|
-
"author": "An Pham <anpham6@gmail.com>",
|
|
20
|
-
"license": "BSD 3-Clause",
|
|
21
|
-
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"@e-mc/types": "0.10.
|
|
24
|
-
"chalk": "4.1.2",
|
|
25
|
-
"file-type": "^18.7.0",
|
|
26
|
-
"js-yaml": "^4.1.0",
|
|
27
|
-
"mime-types": "^2.1.35",
|
|
28
|
-
"picomatch": "^4.0.2",
|
|
29
|
-
"strip-ansi": "6.0.1"
|
|
30
|
-
}
|
|
31
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@e-mc/module",
|
|
3
|
+
"version": "0.10.2",
|
|
4
|
+
"description": "Module base class for E-mc.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/anpham6/e-mc.git",
|
|
13
|
+
"directory": "src/module"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"squared",
|
|
17
|
+
"squared-functions"
|
|
18
|
+
],
|
|
19
|
+
"author": "An Pham <anpham6@gmail.com>",
|
|
20
|
+
"license": "BSD 3-Clause",
|
|
21
|
+
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@e-mc/types": "0.10.2",
|
|
24
|
+
"chalk": "4.1.2",
|
|
25
|
+
"file-type": "^18.7.0",
|
|
26
|
+
"js-yaml": "^4.1.0",
|
|
27
|
+
"mime-types": "^2.1.35",
|
|
28
|
+
"picomatch": "^4.0.2",
|
|
29
|
+
"strip-ansi": "6.0.1"
|
|
30
|
+
}
|
|
31
|
+
}
|