@e-mc/module 0.8.17 → 0.8.18
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 +6 -6
- package/README.md +240 -241
- package/index.js +1 -1
- package/package.json +33 -33
package/LICENSE
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
Copyright 2024 An Pham
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
-
|
|
5
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
-
|
|
1
|
+
Copyright 2024 An Pham
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
7
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,242 +1,241 @@
|
|
|
1
|
-
# @e-mc/module
|
|
2
|
-
|
|
3
|
-
* NodeJS 14
|
|
4
|
-
* ES2019
|
|
5
|
-
|
|
6
|
-
## General Usage
|
|
7
|
-
|
|
8
|
-
* [Read the Docs](https://e-mc.readthedocs.io)
|
|
9
|
-
|
|
10
|
-
## Interface
|
|
11
|
-
|
|
12
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
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, StatusType } from "./logger";
|
|
20
|
-
import type { AsHashOptions, CheckSemVerOptions, CopyDirOptions, CopyDirResult, CopyFileOptions, CreateDirOptions, DeleteFileOptions, GetTempDirOptions, MoveFileOptions, NormalizeFlags, ParseFunctionOptions, PermissionOptions, ProtocolType, ReadBufferOptions, ReadFileCallback, ReadFileOptions, ReadHashOptions, ReadTextOptions, RemoveDirOptions, WriteFileOptions } from "./module";
|
|
21
|
-
import type { Settings } from "./node";
|
|
22
|
-
|
|
23
|
-
import type { SpawnOptions } from "child_process";
|
|
24
|
-
import type { BinaryLike } from "crypto";
|
|
25
|
-
import type { FileTypeResult } from "file-type";
|
|
26
|
-
import type { NoParamCallback } from "fs";
|
|
27
|
-
|
|
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
|
-
supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
|
|
37
|
-
supports(name: string, value?: boolean): boolean;
|
|
38
|
-
getTempDir(options: GetTempDirOptions): string;
|
|
39
|
-
getTempDir(uuidDir: boolean, createDir?: boolean): string;
|
|
40
|
-
getTempDir(pathname: string, createDir?: boolean): string;
|
|
41
|
-
getTempDir(uuidDir: boolean, filename: string, createDir?: boolean): string;
|
|
42
|
-
getTempDir(pathname?: string, filename?: string, createDir?: boolean): string;
|
|
43
|
-
canRead(uri: string, options?: PermissionOptions): boolean;
|
|
44
|
-
canWrite(uri: string, options?: PermissionOptions): boolean;
|
|
45
|
-
readFile(src: string): Buffer | undefined;
|
|
46
|
-
readFile(src: string, options?: ReadFileOptions): Promise<Buffer | string> | Buffer | string | undefined;
|
|
47
|
-
readFile(src: string, promises: true): Promise<Buffer | undefined>;
|
|
48
|
-
readFile(src: string, options: ReadFileOptions, promises: true): Promise<Buffer | string | undefined>;
|
|
49
|
-
readFile(src: string, callback: ReadFileCallback<Buffer>): Buffer | undefined;
|
|
50
|
-
readFile(src: string, options: ReadFileOptions, callback: ReadFileCallback<Buffer | string>): Buffer | string | undefined;
|
|
51
|
-
writeFile(src: string, data: BufferView, options?: WriteFileOptions): boolean;
|
|
52
|
-
writeFile(src: string, data: BufferView, promises: true): Promise<boolean>;
|
|
53
|
-
writeFile(src: string, data: BufferView, options: WriteFileOptions, promises: true): Promise<boolean>;
|
|
54
|
-
writeFile(src: string, data: BufferView, callback: NoParamCallback): void;
|
|
55
|
-
writeFile(src: string, data: BufferView, options: WriteFileOptions, callback: NoParamCallback): void;
|
|
56
|
-
deleteFile(src: string, options?: DeleteFileOptions): boolean;
|
|
57
|
-
deleteFile(src: string, promises: true): Promise<boolean>;
|
|
58
|
-
deleteFile(src: string, options: DeleteFileOptions, promises: true): Promise<boolean>;
|
|
59
|
-
deleteFile(src: string, callback: NoParamCallback): void;
|
|
60
|
-
deleteFile(src: string, options: DeleteFileOptions, callback: NoParamCallback): void;
|
|
61
|
-
copyFile(src: string, dest: string, options?: CopyFileOptions): boolean;
|
|
62
|
-
copyFile(src: string, dest: string, promises: true): Promise<boolean>;
|
|
63
|
-
copyFile(src: string, dest: string, options: CopyFileOptions, promises: true): Promise<boolean>;
|
|
64
|
-
copyFile(src: string, dest: string, callback: NoParamCallback): void;
|
|
65
|
-
copyFile(src: string, dest: string, options: CopyFileOptions, callback: NoParamCallback): void;
|
|
66
|
-
moveFile(src: string, dest: string, options?: MoveFileOptions): boolean;
|
|
67
|
-
moveFile(src: string, dest: string, promises: true): Promise<boolean>;
|
|
68
|
-
moveFile(src: string, dest: string, options: MoveFileOptions, promises: true): Promise<boolean>;
|
|
69
|
-
moveFile(src: string, dest: string, callback: NoParamCallback): void;
|
|
70
|
-
moveFile(src: string, dest: string, options: MoveFileOptions, callback: NoParamCallback): void;
|
|
71
|
-
createDir(src: string, options?: CreateDirOptions): boolean;
|
|
72
|
-
createDir(src: string, promises: true): Promise<boolean>;
|
|
73
|
-
createDir(src: string, options: CreateDirOptions, promises: true): Promise<boolean>;
|
|
74
|
-
createDir(src: string, callback: NoParamCallback): void;
|
|
75
|
-
createDir(src: string, options: CreateDirOptions, callback: NoParamCallback): void;
|
|
76
|
-
removeDir(src: string, options?: RemoveDirOptions): boolean;
|
|
77
|
-
removeDir(src: string, promises: true): Promise<boolean>;
|
|
78
|
-
removeDir(src: string, options: RemoveDirOptions, promises: true): Promise<boolean>;
|
|
79
|
-
removeDir(src: string, callback: NoParamCallback): void;
|
|
80
|
-
removeDir(src: string, options: RemoveDirOptions, callback: NoParamCallback): void;
|
|
81
|
-
allSettled(values: readonly PromiseLike<unknown>[], rejected?: LogValue, options?: LogFailOptions | LogType): Promise<PromiseFulfilledResult<unknown>[]>;
|
|
82
|
-
formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void;
|
|
83
|
-
formatFail(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogFailOptions): void;
|
|
84
|
-
writeFail(value: LogValue, message?: unknown, options?: LogFailOptions | LogType): void;
|
|
85
|
-
writeTimeProcess(title: string, value: string, startTime: LogTime, options?: LogProcessOptions): void;
|
|
86
|
-
writeTimeElapsed(title: string, value: LogValue, startTime: LogTime, options?: LogMessageOptions): void;
|
|
87
|
-
checkPackage(err: unknown, name: string | undefined, options?: LogFailOptions | LogType): boolean;
|
|
88
|
-
checkPackage(err: unknown, name: string | undefined, value?: LogValue, options?: LogFailOptions | LogType): boolean;
|
|
89
|
-
checkFail(message: unknown, options: LogFailOptions): LogArguments | false | undefined;
|
|
90
|
-
writeLog(component: LogComponent, queue?: boolean): void;
|
|
91
|
-
writeLog(type: StatusType, value: unknown, options?: LogOptions): void;
|
|
92
|
-
writeLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number): void;
|
|
93
|
-
addLog(component: LogComponent, queue?: boolean): void;
|
|
94
|
-
addLog(type: StatusType, value: unknown, from: string, source?: string): void;
|
|
95
|
-
addLog(type: StatusType, value: unknown, options?: LogOptions): void;
|
|
96
|
-
addLog(type: StatusType, value: unknown, timeStamp?: LogDate, from?: string, source?: string): void;
|
|
97
|
-
addLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number, from?: string, source?: string): void;
|
|
98
|
-
getLog(...type: StatusType[]): LogStatus<StatusType>[];
|
|
99
|
-
flushLog(): void;
|
|
100
|
-
willAbort(value: unknown): boolean;
|
|
101
|
-
hasOwnPermission(): boolean;
|
|
102
|
-
isFatal(err?: unknown): boolean;
|
|
103
|
-
detach(): void;
|
|
104
|
-
reset(): void;
|
|
105
|
-
get moduleName(): string;
|
|
106
|
-
set host(value);
|
|
107
|
-
get host(): IHost | null;
|
|
108
|
-
set permission(value);
|
|
109
|
-
get permission(): IPermission | null;
|
|
110
|
-
get aborted(): boolean;
|
|
111
|
-
set abortable(value);
|
|
112
|
-
get abortable(): boolean;
|
|
113
|
-
get threadable(): boolean;
|
|
114
|
-
set sessionId(value);
|
|
115
|
-
get sessionId(): string;
|
|
116
|
-
set broadcastId(value);
|
|
117
|
-
get broadcastId(): string | string[];
|
|
118
|
-
get logType(): LOG_TYPE;
|
|
119
|
-
set logLevel(value: number | string);
|
|
120
|
-
get logLevel(): number;
|
|
121
|
-
get statusType(): STATUS_TYPE;
|
|
122
|
-
set tempDir(value);
|
|
123
|
-
get tempDir(): string;
|
|
124
|
-
|
|
125
|
-
/* EventEmitter */
|
|
126
|
-
on(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
|
|
127
|
-
on(event: "error", listener: (err: Error) => void): this;
|
|
128
|
-
on(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
|
|
129
|
-
on(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
|
|
130
|
-
on(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
|
|
131
|
-
on(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
|
|
132
|
-
on(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
|
|
133
|
-
on(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
|
|
134
|
-
on(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
|
|
135
|
-
once(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
|
|
136
|
-
once(event: "error", listener: (err: Error) => void): this;
|
|
137
|
-
once(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
|
|
138
|
-
once(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
|
|
139
|
-
once(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
|
|
140
|
-
once(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
|
|
141
|
-
once(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
|
|
142
|
-
once(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
|
|
143
|
-
once(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
|
|
144
|
-
emit(event: "exec", command: ExecCommand, options?: SpawnOptions): boolean;
|
|
145
|
-
emit(event: "error", err: Error): boolean;
|
|
146
|
-
emit(event: "file:read", src: string, data: Buffer | string, options?: ReadFileOptions): boolean;
|
|
147
|
-
emit(event: "file:write", src: string, options?: WriteFileOptions): boolean;
|
|
148
|
-
emit(event: "file:delete", src: string, options?: DeleteFileOptions): boolean;
|
|
149
|
-
emit(event: "file:copy", dest: string, options?: CopyFileOptions): boolean;
|
|
150
|
-
emit(event: "file:move", dest: string, options?: MoveFileOptions): boolean;
|
|
151
|
-
emit(event: "dir:create", src: string, options?: CreateDirOptions): boolean;
|
|
152
|
-
emit(event: "dir:remove", src: string, options?: RemoveDirOptions): boolean;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
interface ModuleConstructor {
|
|
156
|
-
PROCESS_TIMEOUT: number;
|
|
157
|
-
LOG_STYLE_FAIL: LogMessageOptions;
|
|
158
|
-
LOG_STYLE_SUCCESS: LogMessageOptions;
|
|
159
|
-
LOG_STYLE_INFO: LogMessageOptions;
|
|
160
|
-
LOG_STYLE_WARN: LogMessageOptions;
|
|
161
|
-
LOG_STYLE_NOTICE: LogMessageOptions;
|
|
162
|
-
LOG_STYLE_REVERSE: LogMessageOptions;
|
|
163
|
-
readonly VERSION: string;
|
|
164
|
-
readonly LOG_TYPE: LOG_TYPE;
|
|
165
|
-
readonly STATUS_TYPE: STATUS_TYPE;
|
|
166
|
-
readonly MAX_TIMEOUT: number;
|
|
167
|
-
readonly TEMP_DIR: string;
|
|
168
|
-
supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
|
|
169
|
-
formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void;
|
|
170
|
-
writeFail(value: LogValue, message?: unknown, options?: LogFailOptions | LogType): void;
|
|
171
|
-
enabled(key: string, username?: string): boolean;
|
|
172
|
-
parseFunction(value: unknown, options?: ParseFunctionOptions): ((...args: unknown[]) => Promise<unknown> | unknown) | null;
|
|
173
|
-
parseFunction(value: unknown, absolute: boolean, sync?: boolean): ((...args: unknown[]) => Promise<unknown> | unknown) | null;
|
|
174
|
-
asString(value: unknown, cacheKey?: boolean | "throws"): string;
|
|
175
|
-
asHash(data: BinaryLike, options: AsHashOptions): string;
|
|
176
|
-
asHash(data: BinaryLike, digest
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
toPosix(value: unknown, normalize
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
isPath(value: string | URL,
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
joinPath(...values:
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
removeDir(value: string | URL,
|
|
196
|
-
|
|
197
|
-
copyDir(src: string | URL, dest: string | URL,
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
streamFile(src: string,
|
|
201
|
-
streamFile(src: string, options
|
|
202
|
-
|
|
203
|
-
readText(value: string | URL,
|
|
204
|
-
readText(value: string | URL,
|
|
205
|
-
|
|
206
|
-
readBuffer(value: string | URL,
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
getCpuUsage(start: CpuUsage, format
|
|
212
|
-
|
|
213
|
-
getMemUsage(format
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
getPackageVersion(name: string | [string, string], startDir
|
|
217
|
-
|
|
218
|
-
checkSemVer(name: string | [string, string], options: CheckSemVerOptions): boolean;
|
|
219
|
-
checkSemVer(name: string | [string, string], min: number | string, max
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
sanitizeArgs(
|
|
223
|
-
|
|
224
|
-
purgeMemory(percent
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
236
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
237
|
-
- https://www.unpkg.com/@e-mc/types@0.8.
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
1
|
+
# @e-mc/module
|
|
2
|
+
|
|
3
|
+
* NodeJS 14
|
|
4
|
+
* ES2019
|
|
5
|
+
|
|
6
|
+
## General Usage
|
|
7
|
+
|
|
8
|
+
* [Read the Docs](https://e-mc.readthedocs.io)
|
|
9
|
+
|
|
10
|
+
## Interface
|
|
11
|
+
|
|
12
|
+
- https://www.unpkg.com/@e-mc/types@0.8.18/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, StatusType } from "./logger";
|
|
20
|
+
import type { AsHashOptions, CheckSemVerOptions, CopyDirOptions, CopyDirResult, CopyFileOptions, CreateDirOptions, DeleteFileOptions, GetTempDirOptions, MoveFileOptions, NormalizeFlags, ParseFunctionOptions, PermissionOptions, ProtocolType, ReadBufferOptions, ReadFileCallback, ReadFileOptions, ReadHashOptions, ReadTextOptions, RemoveDirOptions, WriteFileOptions } from "./module";
|
|
21
|
+
import type { Settings } from "./node";
|
|
22
|
+
|
|
23
|
+
import type { SpawnOptions } from "child_process";
|
|
24
|
+
import type { BinaryLike } from "crypto";
|
|
25
|
+
import type { FileTypeResult } from "file-type";
|
|
26
|
+
import type { NoParamCallback } from "fs";
|
|
27
|
+
|
|
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
|
+
supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
|
|
37
|
+
supports(name: string, value?: boolean): boolean;
|
|
38
|
+
getTempDir(options: GetTempDirOptions): string;
|
|
39
|
+
getTempDir(uuidDir: boolean, createDir?: boolean): string;
|
|
40
|
+
getTempDir(pathname: string, createDir?: boolean): string;
|
|
41
|
+
getTempDir(uuidDir: boolean, filename: string, createDir?: boolean): string;
|
|
42
|
+
getTempDir(pathname?: string, filename?: string, createDir?: boolean): string;
|
|
43
|
+
canRead(uri: string, options?: PermissionOptions): boolean;
|
|
44
|
+
canWrite(uri: string, options?: PermissionOptions): boolean;
|
|
45
|
+
readFile(src: string): Buffer | undefined;
|
|
46
|
+
readFile(src: string, options?: ReadFileOptions): Promise<Buffer | string> | Buffer | string | undefined;
|
|
47
|
+
readFile(src: string, promises: true): Promise<Buffer | undefined>;
|
|
48
|
+
readFile(src: string, options: ReadFileOptions, promises: true): Promise<Buffer | string | undefined>;
|
|
49
|
+
readFile(src: string, callback: ReadFileCallback<Buffer>): Buffer | undefined;
|
|
50
|
+
readFile(src: string, options: ReadFileOptions, callback: ReadFileCallback<Buffer | string>): Buffer | string | undefined;
|
|
51
|
+
writeFile(src: string, data: BufferView, options?: WriteFileOptions): boolean;
|
|
52
|
+
writeFile(src: string, data: BufferView, promises: true): Promise<boolean>;
|
|
53
|
+
writeFile(src: string, data: BufferView, options: WriteFileOptions, promises: true): Promise<boolean>;
|
|
54
|
+
writeFile(src: string, data: BufferView, callback: NoParamCallback): void;
|
|
55
|
+
writeFile(src: string, data: BufferView, options: WriteFileOptions, callback: NoParamCallback): void;
|
|
56
|
+
deleteFile(src: string, options?: DeleteFileOptions): boolean;
|
|
57
|
+
deleteFile(src: string, promises: true): Promise<boolean>;
|
|
58
|
+
deleteFile(src: string, options: DeleteFileOptions, promises: true): Promise<boolean>;
|
|
59
|
+
deleteFile(src: string, callback: NoParamCallback): void;
|
|
60
|
+
deleteFile(src: string, options: DeleteFileOptions, callback: NoParamCallback): void;
|
|
61
|
+
copyFile(src: string, dest: string, options?: CopyFileOptions): boolean;
|
|
62
|
+
copyFile(src: string, dest: string, promises: true): Promise<boolean>;
|
|
63
|
+
copyFile(src: string, dest: string, options: CopyFileOptions, promises: true): Promise<boolean>;
|
|
64
|
+
copyFile(src: string, dest: string, callback: NoParamCallback): void;
|
|
65
|
+
copyFile(src: string, dest: string, options: CopyFileOptions, callback: NoParamCallback): void;
|
|
66
|
+
moveFile(src: string, dest: string, options?: MoveFileOptions): boolean;
|
|
67
|
+
moveFile(src: string, dest: string, promises: true): Promise<boolean>;
|
|
68
|
+
moveFile(src: string, dest: string, options: MoveFileOptions, promises: true): Promise<boolean>;
|
|
69
|
+
moveFile(src: string, dest: string, callback: NoParamCallback): void;
|
|
70
|
+
moveFile(src: string, dest: string, options: MoveFileOptions, callback: NoParamCallback): void;
|
|
71
|
+
createDir(src: string, options?: CreateDirOptions): boolean;
|
|
72
|
+
createDir(src: string, promises: true): Promise<boolean>;
|
|
73
|
+
createDir(src: string, options: CreateDirOptions, promises: true): Promise<boolean>;
|
|
74
|
+
createDir(src: string, callback: NoParamCallback): void;
|
|
75
|
+
createDir(src: string, options: CreateDirOptions, callback: NoParamCallback): void;
|
|
76
|
+
removeDir(src: string, options?: RemoveDirOptions): boolean;
|
|
77
|
+
removeDir(src: string, promises: true): Promise<boolean>;
|
|
78
|
+
removeDir(src: string, options: RemoveDirOptions, promises: true): Promise<boolean>;
|
|
79
|
+
removeDir(src: string, callback: NoParamCallback): void;
|
|
80
|
+
removeDir(src: string, options: RemoveDirOptions, callback: NoParamCallback): void;
|
|
81
|
+
allSettled(values: readonly PromiseLike<unknown>[], rejected?: LogValue, options?: LogFailOptions | LogType): Promise<PromiseFulfilledResult<unknown>[]>;
|
|
82
|
+
formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void;
|
|
83
|
+
formatFail(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogFailOptions): void;
|
|
84
|
+
writeFail(value: LogValue, message?: unknown, options?: LogFailOptions | LogType): void;
|
|
85
|
+
writeTimeProcess(title: string, value: string, startTime: LogTime, options?: LogProcessOptions): void;
|
|
86
|
+
writeTimeElapsed(title: string, value: LogValue, startTime: LogTime, options?: LogMessageOptions): void;
|
|
87
|
+
checkPackage(err: unknown, name: string | undefined, options?: LogFailOptions | LogType): boolean;
|
|
88
|
+
checkPackage(err: unknown, name: string | undefined, value?: LogValue, options?: LogFailOptions | LogType): boolean;
|
|
89
|
+
checkFail(message: unknown, options: LogFailOptions): LogArguments | false | undefined;
|
|
90
|
+
writeLog(component: LogComponent, queue?: boolean): void;
|
|
91
|
+
writeLog(type: StatusType, value: unknown, options?: LogOptions): void;
|
|
92
|
+
writeLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number): void;
|
|
93
|
+
addLog(component: LogComponent, queue?: boolean): void;
|
|
94
|
+
addLog(type: StatusType, value: unknown, from: string, source?: string): void;
|
|
95
|
+
addLog(type: StatusType, value: unknown, options?: LogOptions): void;
|
|
96
|
+
addLog(type: StatusType, value: unknown, timeStamp?: LogDate, from?: string, source?: string): void;
|
|
97
|
+
addLog(type: StatusType, value: unknown, timeStamp?: LogDate, duration?: number, from?: string, source?: string): void;
|
|
98
|
+
getLog(...type: StatusType[]): LogStatus<StatusType>[];
|
|
99
|
+
flushLog(): void;
|
|
100
|
+
willAbort(value: unknown): boolean;
|
|
101
|
+
hasOwnPermission(): boolean;
|
|
102
|
+
isFatal(err?: unknown): boolean;
|
|
103
|
+
detach(): void;
|
|
104
|
+
reset(): void;
|
|
105
|
+
get moduleName(): string;
|
|
106
|
+
set host(value);
|
|
107
|
+
get host(): IHost | null;
|
|
108
|
+
set permission(value);
|
|
109
|
+
get permission(): IPermission | null;
|
|
110
|
+
get aborted(): boolean;
|
|
111
|
+
set abortable(value);
|
|
112
|
+
get abortable(): boolean;
|
|
113
|
+
get threadable(): boolean;
|
|
114
|
+
set sessionId(value);
|
|
115
|
+
get sessionId(): string;
|
|
116
|
+
set broadcastId(value);
|
|
117
|
+
get broadcastId(): string | string[];
|
|
118
|
+
get logType(): LOG_TYPE;
|
|
119
|
+
set logLevel(value: number | string);
|
|
120
|
+
get logLevel(): number;
|
|
121
|
+
get statusType(): STATUS_TYPE;
|
|
122
|
+
set tempDir(value);
|
|
123
|
+
get tempDir(): string;
|
|
124
|
+
|
|
125
|
+
/* EventEmitter */
|
|
126
|
+
on(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
|
|
127
|
+
on(event: "error", listener: (err: Error) => void): this;
|
|
128
|
+
on(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
|
|
129
|
+
on(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
|
|
130
|
+
on(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
|
|
131
|
+
on(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
|
|
132
|
+
on(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
|
|
133
|
+
on(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
|
|
134
|
+
on(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
|
|
135
|
+
once(event: "exec", listener: (command: ExecCommand, options?: SpawnOptions) => void): this;
|
|
136
|
+
once(event: "error", listener: (err: Error) => void): this;
|
|
137
|
+
once(event: "file:read", listener: (src: string, data: Buffer | string, options?: ReadFileOptions) => void): this;
|
|
138
|
+
once(event: "file:write", listener: (src: string, options?: WriteFileOptions) => void): this;
|
|
139
|
+
once(event: "file:delete", listener: (src: string, options?: DeleteFileOptions) => void): this;
|
|
140
|
+
once(event: "file:copy", listener: (dest: string, options?: CopyFileOptions) => void): this;
|
|
141
|
+
once(event: "file:move", listener: (dest: string, options?: MoveFileOptions) => void): this;
|
|
142
|
+
once(event: "dir:create", listener: (src: string, options?: CreateDirOptions) => void): this;
|
|
143
|
+
once(event: "dir:remove", listener: (src: string, options?: RemoveDirOptions) => void): this;
|
|
144
|
+
emit(event: "exec", command: ExecCommand, options?: SpawnOptions): boolean;
|
|
145
|
+
emit(event: "error", err: Error): boolean;
|
|
146
|
+
emit(event: "file:read", src: string, data: Buffer | string, options?: ReadFileOptions): boolean;
|
|
147
|
+
emit(event: "file:write", src: string, options?: WriteFileOptions): boolean;
|
|
148
|
+
emit(event: "file:delete", src: string, options?: DeleteFileOptions): boolean;
|
|
149
|
+
emit(event: "file:copy", dest: string, options?: CopyFileOptions): boolean;
|
|
150
|
+
emit(event: "file:move", dest: string, options?: MoveFileOptions): boolean;
|
|
151
|
+
emit(event: "dir:create", src: string, options?: CreateDirOptions): boolean;
|
|
152
|
+
emit(event: "dir:remove", src: string, options?: RemoveDirOptions): boolean;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
interface ModuleConstructor {
|
|
156
|
+
PROCESS_TIMEOUT: number;
|
|
157
|
+
LOG_STYLE_FAIL: LogMessageOptions;
|
|
158
|
+
LOG_STYLE_SUCCESS: LogMessageOptions;
|
|
159
|
+
LOG_STYLE_INFO: LogMessageOptions;
|
|
160
|
+
LOG_STYLE_WARN: LogMessageOptions;
|
|
161
|
+
LOG_STYLE_NOTICE: LogMessageOptions;
|
|
162
|
+
LOG_STYLE_REVERSE: LogMessageOptions;
|
|
163
|
+
readonly VERSION: string;
|
|
164
|
+
readonly LOG_TYPE: LOG_TYPE;
|
|
165
|
+
readonly STATUS_TYPE: STATUS_TYPE;
|
|
166
|
+
readonly MAX_TIMEOUT: number;
|
|
167
|
+
readonly TEMP_DIR: string;
|
|
168
|
+
supported(major: number, minor?: number, patch?: number, lts?: boolean): boolean;
|
|
169
|
+
formatMessage(type: LogType, title: string, value: LogValue, message?: unknown, options?: LogMessageOptions): void;
|
|
170
|
+
writeFail(value: LogValue, message?: unknown, options?: LogFailOptions | LogType): void;
|
|
171
|
+
enabled(key: string, username?: string): boolean;
|
|
172
|
+
parseFunction(value: unknown, options?: ParseFunctionOptions): ((...args: unknown[]) => Promise<unknown> | unknown) | null;
|
|
173
|
+
parseFunction(value: unknown, absolute: boolean, sync?: boolean): ((...args: unknown[]) => Promise<unknown> | unknown) | null;
|
|
174
|
+
asString(value: unknown, cacheKey?: boolean | "throws"): string;
|
|
175
|
+
asHash(data: BinaryLike, options: AsHashOptions): string;
|
|
176
|
+
asHash(data: BinaryLike, algorithm?: unknown, digest?: unknown): string;
|
|
177
|
+
readHash(value: string | URL, options?: ReadHashOptions): Promise<string>;
|
|
178
|
+
toPosix(value: unknown, normalize: boolean): string;
|
|
179
|
+
toPosix(value: unknown, filename?: string, normalize?: boolean): string;
|
|
180
|
+
hasLogType(value: LogType): boolean;
|
|
181
|
+
isURL(value: string, ...exclude: string[]): boolean;
|
|
182
|
+
isFile(value: string | URL, type?: ProtocolType): boolean;
|
|
183
|
+
isDir(value: string | URL): boolean;
|
|
184
|
+
isPath(value: string | URL, type?: "unc" | "unc-exists"): boolean;
|
|
185
|
+
isPath(value: string | URL, isFile?: boolean): boolean;
|
|
186
|
+
isErrorCode(err: unknown, ...code: string[]): boolean;
|
|
187
|
+
fromLocalPath(value: string): string;
|
|
188
|
+
resolveFile(value: string): string;
|
|
189
|
+
resolvePath(value: string, base: string | URL): string;
|
|
190
|
+
joinPath(...values: [...paths: unknown[], normalize: boolean][]): string;
|
|
191
|
+
joinPath(...values: unknown[]): string;
|
|
192
|
+
normalizePath(value: unknown, flags?: boolean | NormalizeFlags): string;
|
|
193
|
+
createDir(value: string | URL, overwrite?: boolean): boolean;
|
|
194
|
+
removeDir(value: string | URL, sinceCreated: number, recursive?: boolean): boolean;
|
|
195
|
+
removeDir(value: string | URL, empty?: boolean, recursive?: boolean): boolean;
|
|
196
|
+
copyDir(src: string | URL, dest: string | URL, options: CopyDirOptions): Promise<CopyDirResult>;
|
|
197
|
+
copyDir(src: string | URL, dest: string | URL, move?: boolean, recursive?: boolean): Promise<CopyDirResult>;
|
|
198
|
+
renameFile(src: string | URL, dest: string | URL, throws?: boolean): boolean;
|
|
199
|
+
streamFile(src: string, cache: boolean): Promise<Buffer | string>;
|
|
200
|
+
streamFile(src: string, options: ReadBufferOptions): Promise<Buffer | string>;
|
|
201
|
+
streamFile(src: string, cache?: boolean | ReadBufferOptions, options?: ReadBufferOptions): Promise<Buffer | string>;
|
|
202
|
+
readText(value: string | URL, cache: boolean): string;
|
|
203
|
+
readText(value: string | URL, options: ReadTextOptions): Promise<string> | string;
|
|
204
|
+
readText(value: string | URL, encoding?: BufferEncoding | boolean | ReadTextOptions, cache?: boolean): string;
|
|
205
|
+
readBuffer(value: string | URL, options: ReadBufferOptions): Promise<Buffer | null> | Buffer | null;
|
|
206
|
+
readBuffer(value: string | URL, cache?: boolean): Buffer | null;
|
|
207
|
+
resolveMime(data: string | Buffer | Uint8Array | ArrayBuffer): Promise<FileTypeResult | undefined>;
|
|
208
|
+
lookupMime(value: string, extension?: boolean): string;
|
|
209
|
+
initCpuUsage(instance?: IModule): CpuUsage;
|
|
210
|
+
getCpuUsage(start: CpuUsage, format: true): string;
|
|
211
|
+
getCpuUsage(start: CpuUsage, format?: boolean): number;
|
|
212
|
+
getMemUsage(format: true): string;
|
|
213
|
+
getMemUsage(format?: boolean): number;
|
|
214
|
+
formatCpuMem(start: CpuUsage, all?: boolean): string;
|
|
215
|
+
getPackageVersion(name: string | [string, string], startDir: string, baseDir?: string): string;
|
|
216
|
+
getPackageVersion(name: string | [string, string], unstable?: boolean, startDir?: string, baseDir?: string): string;
|
|
217
|
+
checkSemVer(name: string | [string, string], options: CheckSemVerOptions): boolean;
|
|
218
|
+
checkSemVer(name: string | [string, string], min: number | string, max: number | string, options: CheckSemVerOptions): boolean;
|
|
219
|
+
checkSemVer(name: string | [string, string], min: number | string, max?: number | string, unstable?: boolean, startDir?: string): boolean;
|
|
220
|
+
sanitizeCmd(value: string): string;
|
|
221
|
+
sanitizeArgs(value: string, doubleQuote?: boolean): string;
|
|
222
|
+
sanitizeArgs(values: string[], doubleQuote?: boolean): string[];
|
|
223
|
+
purgeMemory(percent: number, parent: boolean | number): Promise<number>;
|
|
224
|
+
purgeMemory(percent?: number, limit?: number, parent?: boolean | number): Promise<number>;
|
|
225
|
+
canWrite(name: "temp" | "home"): boolean;
|
|
226
|
+
loadSettings(settings: Settings, password?: string): boolean;
|
|
227
|
+
readonly prototype: IModule<IHost>;
|
|
228
|
+
new(): IModule<IHost>;
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## References
|
|
233
|
+
|
|
234
|
+
- https://www.unpkg.com/@e-mc/types@0.8.18/lib/core.d.ts
|
|
235
|
+
- https://www.unpkg.com/@e-mc/types@0.8.18/lib/logger.d.ts
|
|
236
|
+
- https://www.unpkg.com/@e-mc/types@0.8.18/lib/module.d.ts
|
|
237
|
+
- https://www.unpkg.com/@e-mc/types@0.8.18/lib/node.d.ts
|
|
238
|
+
|
|
239
|
+
## LICENSE
|
|
240
|
+
|
|
242
241
|
MIT
|
package/index.js
CHANGED
|
@@ -714,7 +714,7 @@ class Module extends EventEmitter {
|
|
|
714
714
|
this[_f] = new AbortController();
|
|
715
715
|
this[_g] = null;
|
|
716
716
|
}
|
|
717
|
-
static get VERSION() { return "0.8.
|
|
717
|
+
static get VERSION() { return "0.8.18"; }
|
|
718
718
|
static get LOG_TYPE() { return types_1.LOG_TYPE; }
|
|
719
719
|
static get STATUS_TYPE() { return types_1.STATUS_TYPE; }
|
|
720
720
|
static get MAX_TIMEOUT() { return 2147483647; }
|
package/package.json
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@e-mc/module",
|
|
3
|
-
"version": "0.8.
|
|
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": "MIT",
|
|
21
|
-
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
|
-
"dependencies": {
|
|
23
|
-
"@e-mc/types": "0.8.
|
|
24
|
-
"abort-controller": "^3.0.0",
|
|
25
|
-
"chalk": "4.1.2",
|
|
26
|
-
"event-target-shim": "^5.0.1",
|
|
27
|
-
"file-type": "16.5.4",
|
|
28
|
-
"js-yaml": "^4.1.0",
|
|
29
|
-
"mime-types": "^2.1.35",
|
|
30
|
-
"picomatch": "^3.0.1",
|
|
31
|
-
"strip-ansi": "6.0.1"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@e-mc/module",
|
|
3
|
+
"version": "0.8.18",
|
|
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": "MIT",
|
|
21
|
+
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@e-mc/types": "0.8.18",
|
|
24
|
+
"abort-controller": "^3.0.0",
|
|
25
|
+
"chalk": "4.1.2",
|
|
26
|
+
"event-target-shim": "^5.0.1",
|
|
27
|
+
"file-type": "16.5.4",
|
|
28
|
+
"js-yaml": "^4.1.0",
|
|
29
|
+
"mime-types": "^2.1.35",
|
|
30
|
+
"picomatch": "^3.0.1",
|
|
31
|
+
"strip-ansi": "6.0.1"
|
|
32
|
+
}
|
|
33
|
+
}
|