@e-mc/core 0.10.1 → 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.
Files changed (4) hide show
  1. package/LICENSE +10 -10
  2. package/README.md +242 -242
  3. package/index.js +10 -13
  4. package/package.json +27 -27
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,243 +1,243 @@
1
- # @e-mc/core
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.1/lib/index.d.ts)
13
-
14
- ```typescript
15
- import type { DataSource, LogStatus } from "./squared";
16
-
17
- import type { IHost, IModule, ModuleConstructor } from "./index";
18
- import type { CacheOptions, HostInitConfig, JoinQueueOptions, PermissionReadWrite, ResumeThreadOptions, StoreResultOptions, ThreadCountStat } from "./core";
19
- import type { QueryResult, TimeoutAction } from "./db";
20
- import type { AddEventListenerOptions } from "./dom";
21
- import type { LogState, StatusType } from "./logger";
22
- import type { Settings } from "./node";
23
- import type { ClientDbSettings, ClientModule, ClientSettings, DbCacheValue, DbCoerceSettings, DbCoerceValue, DbSourceOptions } from "./settings";
24
-
25
- interface IHost extends IModule {
26
- restartable: boolean;
27
- readonly modules: Set<IModule>;
28
- readonly subProcesses: Set<IModule>;
29
- readonly startTime: number;
30
- using(...items: unknown[] | [boolean, ...unknown[]]): this;
31
- contains(item: unknown, condition?: (...args: any[]) => boolean): boolean;
32
- find(name: string): IModule | undefined;
33
- findAll(name: string): IModule[];
34
- willLog(name: string): boolean;
35
- ignoreLog(values: boolean | string | string[]): void;
36
- collectLog(level?: boolean): LogStatus<StatusType>[];
37
- pauseLog(type?: string): void;
38
- resumeLog(type?: string): void;
39
- hasLog(type: string): boolean;
40
- delayMessage(...args: unknown[]): void;
41
- willAbort(value: string | IModule): boolean;
42
- loadModule(name: string, ...args: any[]): IModule | null;
43
- retain(process: IModule): void;
44
- release(process: IModule, log?: boolean): boolean;
45
- restart(...args: unknown[]): void;
46
- joinQueue(options?: JoinQueueOptions): boolean;
47
- updateProgress(name: string, ...args: unknown[]): void;
48
- resumeThread?(options: ResumeThreadOptions): void;
49
- set host(value);
50
- get host(): null;
51
- get config(): Readonly<HostInitConfig>;
52
- get username(): string;
53
- set done(value);
54
- get done(): boolean;
55
- get queued(): boolean;
56
- get logState(): LogState;
57
- get errorCount(): number;
58
- }
59
-
60
- interface HostConstructor extends ModuleConstructor {
61
- loadSettings(settings: Settings, password?: string): boolean;
62
- loadSettings(settings: Settings, permission?: PermissionReadWrite, password?: string): boolean;
63
- isPermission(value: unknown): value is IPermission;
64
- createPermission(all?: boolean, freeze?: boolean): IPermission;
65
- kill(username: string, iv: BinaryLike, all: true): number;
66
- kill(username: string, iv: BinaryLike, pid: number | number[]): number;
67
- getThreadCount(full: true): ThreadCountStat;
68
- getThreadCount(username: string, iv?: BinaryLike): ThreadCountStat;
69
- getThreadCount(username?: string | boolean, iv?: BinaryLike): number;
70
- getPermissionFromSettings(): IPermission;
71
- readonly prototype: IHost;
72
- new(config?: HostInitConfig): IHost;
73
- }
74
-
75
- interface IClient extends IModule<IHost> {
76
- module: ClientModule;
77
- init(...args: unknown[]): this;
78
- getUserSettings(): unknown;
79
- get settings(): ClientSettings;
80
- set cacheDir(value: string);
81
- get cacheDir(): string;
82
- set extensions(values: unknown[]);
83
- get extensions(): ((...args: unknown[]) => unknown)[];
84
- }
85
-
86
- interface ClientConstructor extends ModuleConstructor {
87
- readonly prototype: IClient;
88
- new(module?: ClientModule): IClient;
89
- }
90
-
91
- interface IClientDb extends IClient<IHost, ClientModule<ClientDbSettings>> {
92
- database: DataSource[];
93
- cacheExpires: number;
94
- add(item: DataSource, state?: number): void;
95
- hasCache(source: string, sessionKey?: string): boolean;
96
- hasCoerce(source: string, component: keyof DbCoerceSettings, uuidKey: Undef<string>): boolean;
97
- hasCoerce(source: string, component: keyof DbCoerceSettings, credential?: unknown): boolean;
98
- getQueryResult(source: string, credential: unknown, queryString: string, renewCache: boolean): QueryResult | undefined;
99
- getQueryResult(source: string, credential: unknown, queryString: string, sessionKey?: string, renewCache?: boolean): QueryResult | undefined;
100
- getQueryResult(source: string, credential: unknown, queryString: string, options?: CacheOptions, renewCache?: boolean): QueryResult | undefined;
101
- setQueryResult(source: string, credential: unknown, queryString: string, result: unknown, sessionKey?: string): QueryResult;
102
- setQueryResult(source: string, credential: unknown, queryString: string, result: unknown, options?: CacheOptions): QueryResult;
103
- getCacheResult(source: string, credential: unknown, queryString: string, cacheValue: CacheOptions, ignoreCache?: unknown): QueryResult | undefined;
104
- applyState(items: DataSource | DataSource[], value: number, as?: boolean): void;
105
- commit(items?: DataSource[]): Promise<boolean>;
106
- valueOfKey(credential: unknown, name: keyof DbSourceOptions, component?: keyof DbCoerceSettings): unknown;
107
- settingsOf(source: string, name: keyof DbSourceOptions, component?: keyof DbCoerceSettings): unknown;
108
- settingsKey(uuidKey: string, name: keyof DbSourceOptions, component?: keyof DbCoerceSettings): unknown;
109
- get pending(): DataSource[];
110
- get committed(): DataSource[];
111
- get failed(): DataSource[];
112
- }
113
-
114
- interface ClientDbConstructor extends ClientConstructor<IHost, ClientModule> {
115
- STORE_RESULT_PARTITION_SIZE: number;
116
- STORE_RESULT_PARTITION_MULT: number;
117
- readonly TRANSACTION_ACTIVE: number;
118
- readonly TRANSACTION_PARTIAL: number;
119
- readonly TRANSACTION_COMMIT: number;
120
- readonly TRANSACTION_TERMINATE: number;
121
- readonly TRANSACTION_ABORT: number;
122
- readonly TRANSACTION_FAIL: number;
123
- loadSettings(settings: Pick<Settings, "process" | "memory">, password?: string): boolean;
124
- getTimeout(value: number | string | TimeoutAction | undefined): number;
125
- convertTime(value: number | string): number;
126
- findResult(source: string, credential: unknown, queryString: string, timeout: number, sessionKey?: string | boolean, renewCache?: boolean): QueryResult | undefined;
127
- storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, options: StoreResultOptions): QueryResult;
128
- storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, sessionKey: string, sessionExpires: number): QueryResult;
129
- storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, cache: DbCacheValue): QueryResult;
130
- storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, cache: DbCacheValue | undefined, options: StoreResultOptions): QueryResult;
131
- purgeResult(prefix?: string): Promise<number>;
132
- extractUUID(credential: unknown): string;
133
- setPoolConfig(value: unknown): void;
134
- getPoolConfig(source: string): unknown;
135
- keyOfResult(source: string, credential: unknown, uuidOnly?: boolean): string;
136
- readonly prototype: IClientDb;
137
- new(module?: ClientModule, database?: DataSource[]): IClientDb;
138
- }
139
-
140
- interface IAbortComponent extends AbortController {
141
- reset(): void;
142
- get aborted(): boolean;
143
- }
144
-
145
- interface AbortComponentConstructor {
146
- attach(instance: IAbortComponent, signal: AbortSignal, options?: AddEventListenerOptions): void;
147
- detach(instance: IAbortComponent, signal: AbortSignal): void;
148
- readonly prototype: IAbortComponent;
149
- new(): IAbortComponent;
150
- }
151
-
152
- interface IPermission {
153
- setDiskRead(pathname?: string | string[], enabled?: boolean): void;
154
- setDiskWrite(pathname?: string | string[], enabled?: boolean): void;
155
- setUNCRead(pathname?: string | string[], enabled?: boolean): void;
156
- setUNCWrite(pathname?: string | string[], enabled?: boolean): void;
157
- getDiskRead(): string | string[];
158
- getDiskWrite(): string | string[];
159
- getUNCRead(): string | string[];
160
- getUNCWrite(): string | string[];
161
- hasDiskRead(pathname: string): boolean;
162
- hasDiskWrite(pathname: string): boolean;
163
- hasUNCRead(pathname: string): boolean;
164
- hasUNCWrite(pathname: string): boolean;
165
- get diskRead(): boolean;
166
- get diskWrite(): boolean;
167
- get uncRead(): boolean;
168
- get uncWrite(): boolean;
169
- }
170
- ```
171
-
172
- ## Settings
173
-
174
- ```typescript
175
- import type { ExecOptions } from "./settings";
176
-
177
- import type { MinimatchOptions } from "minimatch";
178
- import type { PicomatchOptions } from "picomatch";
179
-
180
- interface ProcessModule {
181
- thread?: {
182
- admin: {
183
- users?: string[];
184
- private?: boolean;
185
- };
186
- queue?: {
187
- limit?: number;
188
- expires?: number | string;
189
- priority: {
190
- bypass?: number;
191
- min?: number;
192
- max?: number;
193
- };
194
- };
195
- limit?: number;
196
- expires?: number | string;
197
- };
198
- }
199
-
200
- interface PermissionModule {
201
- disk_read?: string | string[];
202
- disk_write?: string | string[];
203
- unc_read?: string | string[];
204
- unc_write?: string | string[];
205
- settings?: {
206
- broadcast_id?: string | string[];
207
- picomatch?: PicomatchOptions | null;
208
- minimatch?: MinimatchOptions | null;
209
- };
210
- }
211
- ```
212
-
213
- ### Example usage
214
-
215
- ```javascript
216
- const { Host } = require("@e-mc/core");
217
-
218
- Host.loadSettings({ // Global
219
- process: {
220
- thread: { limit: 8 }
221
- },
222
- permission: {
223
- disk_read: ["**/*"],
224
- disk_write: ["/tmp/**"]
225
- }
226
- });
227
- ```
228
-
229
- NOTE: **@e-mc/core** is mostly a collection of abstract base classes which cannot be instantiated. **Host** is more commonly called through [@e-mc/file-manager](https://www.npmjs.com/package/@e-mc/file-manager).
230
-
231
- ## References
232
-
233
- - https://www.unpkg.com/@e-mc/types@0.10.1/lib/squared.d.ts
234
- - https://www.unpkg.com/@e-mc/types@0.10.1/lib/core.d.ts
235
- - https://www.unpkg.com/@e-mc/types@0.10.1/lib/db.d.ts
236
- - https://www.unpkg.com/@e-mc/types@0.10.1/lib/dom.d.ts
237
- - https://www.unpkg.com/@e-mc/types@0.10.1/lib/logger.d.ts
238
- - https://www.unpkg.com/@e-mc/types@0.10.1/lib/node.d.ts
239
- - https://www.unpkg.com/@e-mc/types@0.10.1/lib/settings.d.ts
240
-
241
- ## LICENSE
242
-
1
+ # @e-mc/core
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 { DataSource, LogStatus } from "./squared";
16
+
17
+ import type { IHost, IModule, ModuleConstructor } from "./index";
18
+ import type { CacheOptions, HostInitConfig, JoinQueueOptions, PermissionReadWrite, ResumeThreadOptions, StoreResultOptions, ThreadCountStat } from "./core";
19
+ import type { QueryResult, TimeoutAction } from "./db";
20
+ import type { AddEventListenerOptions } from "./dom";
21
+ import type { LogState, StatusType } from "./logger";
22
+ import type { Settings } from "./node";
23
+ import type { ClientDbSettings, ClientModule, ClientSettings, DbCacheValue, DbCoerceSettings, DbCoerceValue, DbSourceOptions } from "./settings";
24
+
25
+ interface IHost extends IModule {
26
+ restartable: boolean;
27
+ readonly modules: Set<IModule>;
28
+ readonly subProcesses: Set<IModule>;
29
+ readonly startTime: number;
30
+ using(...items: unknown[] | [boolean, ...unknown[]]): this;
31
+ contains(item: unknown, condition?: (...args: any[]) => boolean): boolean;
32
+ find(name: string): IModule | undefined;
33
+ findAll(name: string): IModule[];
34
+ willLog(name: string): boolean;
35
+ ignoreLog(values: boolean | string | string[]): void;
36
+ collectLog(level?: boolean): LogStatus<StatusType>[];
37
+ pauseLog(type?: string): void;
38
+ resumeLog(type?: string): void;
39
+ hasLog(type: string): boolean;
40
+ delayMessage(...args: unknown[]): void;
41
+ willAbort(value: string | IModule): boolean;
42
+ loadModule(name: string, ...args: any[]): IModule | null;
43
+ retain(process: IModule): void;
44
+ release(process: IModule, log?: boolean): boolean;
45
+ restart(...args: unknown[]): void;
46
+ joinQueue(options?: JoinQueueOptions): boolean;
47
+ updateProgress(name: string, ...args: unknown[]): void;
48
+ resumeThread?(options: ResumeThreadOptions): void;
49
+ set host(value);
50
+ get host(): null;
51
+ get config(): Readonly<HostInitConfig>;
52
+ get username(): string;
53
+ set done(value);
54
+ get done(): boolean;
55
+ get queued(): boolean;
56
+ get logState(): LogState;
57
+ get errorCount(): number;
58
+ }
59
+
60
+ interface HostConstructor extends ModuleConstructor {
61
+ loadSettings(settings: Settings, password?: string): boolean;
62
+ loadSettings(settings: Settings, permission?: PermissionReadWrite, password?: string): boolean;
63
+ isPermission(value: unknown): value is IPermission;
64
+ createPermission(all?: boolean, freeze?: boolean): IPermission;
65
+ kill(username: string, iv: BinaryLike, all: true): number;
66
+ kill(username: string, iv: BinaryLike, pid: number | number[]): number;
67
+ getThreadCount(full: true): ThreadCountStat;
68
+ getThreadCount(username: string, iv?: BinaryLike): ThreadCountStat;
69
+ getThreadCount(username?: string | boolean, iv?: BinaryLike): number;
70
+ getPermissionFromSettings(): IPermission;
71
+ readonly prototype: IHost;
72
+ new(config?: HostInitConfig): IHost;
73
+ }
74
+
75
+ interface IClient extends IModule<IHost> {
76
+ module: ClientModule;
77
+ init(...args: unknown[]): this;
78
+ getUserSettings(): unknown;
79
+ get settings(): ClientSettings;
80
+ set cacheDir(value: string);
81
+ get cacheDir(): string;
82
+ set extensions(values: unknown[]);
83
+ get extensions(): ((...args: unknown[]) => unknown)[];
84
+ }
85
+
86
+ interface ClientConstructor extends ModuleConstructor {
87
+ readonly prototype: IClient;
88
+ new(module?: ClientModule): IClient;
89
+ }
90
+
91
+ interface IClientDb extends IClient<IHost, ClientModule<ClientDbSettings>> {
92
+ database: DataSource[];
93
+ cacheExpires: number;
94
+ add(item: DataSource, state?: number): void;
95
+ hasCache(source: string, sessionKey?: string): boolean;
96
+ hasCoerce(source: string, component: keyof DbCoerceSettings, uuidKey: Undef<string>): boolean;
97
+ hasCoerce(source: string, component: keyof DbCoerceSettings, credential?: unknown): boolean;
98
+ getQueryResult(source: string, credential: unknown, queryString: string, renewCache: boolean): QueryResult | undefined;
99
+ getQueryResult(source: string, credential: unknown, queryString: string, sessionKey?: string, renewCache?: boolean): QueryResult | undefined;
100
+ getQueryResult(source: string, credential: unknown, queryString: string, options?: CacheOptions, renewCache?: boolean): QueryResult | undefined;
101
+ setQueryResult(source: string, credential: unknown, queryString: string, result: unknown, sessionKey?: string): QueryResult;
102
+ setQueryResult(source: string, credential: unknown, queryString: string, result: unknown, options?: CacheOptions): QueryResult;
103
+ getCacheResult(source: string, credential: unknown, queryString: string, cacheValue: CacheOptions, ignoreCache?: unknown): QueryResult | undefined;
104
+ applyState(items: DataSource | DataSource[], value: number, as?: boolean): void;
105
+ commit(items?: DataSource[]): Promise<boolean>;
106
+ valueOfKey(credential: unknown, name: keyof DbSourceOptions, component?: keyof DbCoerceSettings): unknown;
107
+ settingsOf(source: string, name: keyof DbSourceOptions, component?: keyof DbCoerceSettings): unknown;
108
+ settingsKey(uuidKey: string, name: keyof DbSourceOptions, component?: keyof DbCoerceSettings): unknown;
109
+ get pending(): DataSource[];
110
+ get committed(): DataSource[];
111
+ get failed(): DataSource[];
112
+ }
113
+
114
+ interface ClientDbConstructor extends ClientConstructor<IHost, ClientModule> {
115
+ STORE_RESULT_PARTITION_SIZE: number;
116
+ STORE_RESULT_PARTITION_MULT: number;
117
+ readonly TRANSACTION_ACTIVE: number;
118
+ readonly TRANSACTION_PARTIAL: number;
119
+ readonly TRANSACTION_COMMIT: number;
120
+ readonly TRANSACTION_TERMINATE: number;
121
+ readonly TRANSACTION_ABORT: number;
122
+ readonly TRANSACTION_FAIL: number;
123
+ loadSettings(settings: Pick<Settings, "process" | "memory">, password?: string): boolean;
124
+ getTimeout(value: number | string | TimeoutAction | undefined): number;
125
+ convertTime(value: number | string): number;
126
+ findResult(source: string, credential: unknown, queryString: string, timeout: number, sessionKey?: string | boolean, renewCache?: boolean): QueryResult | undefined;
127
+ storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, options: StoreResultOptions): QueryResult;
128
+ storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, sessionKey: string, sessionExpires: number): QueryResult;
129
+ storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, cache: DbCacheValue): QueryResult;
130
+ storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, cache: DbCacheValue | undefined, options: StoreResultOptions): QueryResult;
131
+ purgeResult(prefix?: string): Promise<number>;
132
+ extractUUID(credential: unknown): string;
133
+ setPoolConfig(value: unknown): void;
134
+ getPoolConfig(source: string): unknown;
135
+ keyOfResult(source: string, credential: unknown, uuidOnly?: boolean): string;
136
+ readonly prototype: IClientDb;
137
+ new(module?: ClientModule, database?: DataSource[]): IClientDb;
138
+ }
139
+
140
+ interface IAbortComponent extends AbortController {
141
+ reset(): void;
142
+ get aborted(): boolean;
143
+ }
144
+
145
+ interface AbortComponentConstructor {
146
+ attach(instance: IAbortComponent, signal: AbortSignal, options?: AddEventListenerOptions): void;
147
+ detach(instance: IAbortComponent, signal: AbortSignal): void;
148
+ readonly prototype: IAbortComponent;
149
+ new(): IAbortComponent;
150
+ }
151
+
152
+ interface IPermission {
153
+ setDiskRead(pathname?: string | string[], enabled?: boolean): void;
154
+ setDiskWrite(pathname?: string | string[], enabled?: boolean): void;
155
+ setUNCRead(pathname?: string | string[], enabled?: boolean): void;
156
+ setUNCWrite(pathname?: string | string[], enabled?: boolean): void;
157
+ getDiskRead(): string | string[];
158
+ getDiskWrite(): string | string[];
159
+ getUNCRead(): string | string[];
160
+ getUNCWrite(): string | string[];
161
+ hasDiskRead(pathname: string): boolean;
162
+ hasDiskWrite(pathname: string): boolean;
163
+ hasUNCRead(pathname: string): boolean;
164
+ hasUNCWrite(pathname: string): boolean;
165
+ get diskRead(): boolean;
166
+ get diskWrite(): boolean;
167
+ get uncRead(): boolean;
168
+ get uncWrite(): boolean;
169
+ }
170
+ ```
171
+
172
+ ## Settings
173
+
174
+ ```typescript
175
+ import type { ExecOptions } from "./settings";
176
+
177
+ import type { MinimatchOptions } from "minimatch";
178
+ import type { PicomatchOptions } from "picomatch";
179
+
180
+ interface ProcessModule {
181
+ thread?: {
182
+ admin: {
183
+ users?: string[];
184
+ private?: boolean;
185
+ };
186
+ queue?: {
187
+ limit?: number;
188
+ expires?: number | string;
189
+ priority: {
190
+ bypass?: number;
191
+ min?: number;
192
+ max?: number;
193
+ };
194
+ };
195
+ limit?: number;
196
+ expires?: number | string;
197
+ };
198
+ }
199
+
200
+ interface PermissionModule {
201
+ disk_read?: string | string[];
202
+ disk_write?: string | string[];
203
+ unc_read?: string | string[];
204
+ unc_write?: string | string[];
205
+ settings?: {
206
+ broadcast_id?: string | string[];
207
+ picomatch?: PicomatchOptions | null;
208
+ minimatch?: MinimatchOptions | null;
209
+ };
210
+ }
211
+ ```
212
+
213
+ ### Example usage
214
+
215
+ ```javascript
216
+ const { Host } = require("@e-mc/core");
217
+
218
+ Host.loadSettings({ // Global
219
+ process: {
220
+ thread: { limit: 8 }
221
+ },
222
+ permission: {
223
+ disk_read: ["**/*"],
224
+ disk_write: ["/tmp/**"]
225
+ }
226
+ });
227
+ ```
228
+
229
+ NOTE: **@e-mc/core** is mostly a collection of abstract base classes which cannot be instantiated. **Host** is more commonly called through [@e-mc/file-manager](https://www.npmjs.com/package/@e-mc/file-manager).
230
+
231
+ ## References
232
+
233
+ - https://www.unpkg.com/@e-mc/types@0.10.2/lib/squared.d.ts
234
+ - https://www.unpkg.com/@e-mc/types@0.10.2/lib/core.d.ts
235
+ - https://www.unpkg.com/@e-mc/types@0.10.2/lib/db.d.ts
236
+ - https://www.unpkg.com/@e-mc/types@0.10.2/lib/dom.d.ts
237
+ - https://www.unpkg.com/@e-mc/types@0.10.2/lib/logger.d.ts
238
+ - https://www.unpkg.com/@e-mc/types@0.10.2/lib/node.d.ts
239
+ - https://www.unpkg.com/@e-mc/types@0.10.2/lib/settings.d.ts
240
+
241
+ ## LICENSE
242
+
243
243
  BSD 3-Clause
package/index.js CHANGED
@@ -185,7 +185,7 @@ function clearSourceResult(data) {
185
185
  }
186
186
  }
187
187
  function addSourceResult(source, data) {
188
- const { items, config } = CACHE_SOURCE[source] || (CACHE_SOURCE[source] = { items: [] });
188
+ const { items, config } = CACHE_SOURCE[source] ||= { items: [] };
189
189
  if (config && items.length >= config.limit) {
190
190
  const { percent, min } = config;
191
191
  if (percent === 1) {
@@ -623,20 +623,19 @@ class Host extends module_1 {
623
623
  }
624
624
  pauseLog(type) {
625
625
  if (type === 'progress') {
626
- this._logDelayed || (this._logDelayed = []);
626
+ this._logDelayed ||= [];
627
627
  HOST.LOG_PROGRESS_PAUSED.add(this);
628
628
  }
629
629
  this[kLogState] = 0;
630
630
  }
631
631
  resumeLog(type) {
632
- var _k;
633
632
  if (!type || this.hasLog(type) || type === 'progress' && !HOST.LOG_PROGRESS) {
634
633
  this[kLogState] = 1;
635
634
  const log = this._logDelayed;
636
635
  if (log?.length) {
637
636
  const trailing = {};
638
637
  for (const args of log) {
639
- (_k = args[4]).statusType && (_k.statusType = 0);
638
+ args[4].statusType &&= 0;
640
639
  if (typeof args[4].progressBar === 'boolean') {
641
640
  trailing[args[1]] = args;
642
641
  }
@@ -760,7 +759,7 @@ class Client extends module_1 {
760
759
  }
761
760
  }
762
761
  if ((0, types_1.isArray)(extensions)) {
763
- this._extensions || (this._extensions = extensions.slice(0));
762
+ this._extensions ||= extensions.slice(0);
764
763
  }
765
764
  if (cache_dir) {
766
765
  this.cacheDir = cache_dir;
@@ -800,8 +799,7 @@ class Client extends module_1 {
800
799
  return this[kCacheDir];
801
800
  }
802
801
  get settings() {
803
- var _k;
804
- return ((_k = this.module).settings || (_k.settings = {}));
802
+ return (this.module.settings ||= {});
805
803
  }
806
804
  set extensions(values) {
807
805
  if (Array.isArray(values)) {
@@ -950,7 +948,6 @@ class ClientDb extends Client {
950
948
  }
951
949
  }
952
950
  static storeResult(source, credential, queryString, result, options, sessionKey, sessionExpires) {
953
- var _k, _l;
954
951
  let cache, cacheDir;
955
952
  if ((0, types_1.isObject)(sessionKey)) {
956
953
  ({ cacheDir, sessionKey, sessionExpires } = sessionKey);
@@ -993,7 +990,7 @@ class ClientDb extends Client {
993
990
  queryString = (0, types_1.hashKey)(queryString);
994
991
  if (timeout > 0) {
995
992
  const item = [expireTime(timeout), result, Date.now(), 0];
996
- ((_k = (CACHE_USER[source] || (CACHE_USER[source] = {})))[userKey] || (_k[userKey] = {}))[queryString] = item;
993
+ ((CACHE_USER[source] ||= {})[userKey] ||= {})[queryString] = item;
997
994
  addSourceResult(source, item);
998
995
  if (cacheDir) {
999
996
  if (partition) {
@@ -1015,7 +1012,7 @@ class ClientDb extends Client {
1015
1012
  }
1016
1013
  else if (typeof sessionKey === 'string' && sessionExpires && sessionExpires > 0) {
1017
1014
  const dbKey = userKey + sessionKey;
1018
- ((_l = (CACHE_SESSION[source] || (CACHE_SESSION[source] = {})))[dbKey] || (_l[dbKey] = {}))[queryString] = result;
1015
+ ((CACHE_SESSION[source] ||= {})[dbKey] ||= {})[queryString] = result;
1019
1016
  setTimeout(() => delete CACHE_SESSION[dbKey], sessionExpires * 1000);
1020
1017
  }
1021
1018
  }
@@ -1151,7 +1148,7 @@ class ClientDb extends Client {
1151
1148
  if (ignoreCache === 1) {
1152
1149
  return;
1153
1150
  }
1154
- renewCache || (renewCache = ignoreCache === 0);
1151
+ renewCache ||= ignoreCache === 0;
1155
1152
  queryString += '_' + exclusiveOf.toString();
1156
1153
  }
1157
1154
  }
@@ -1211,13 +1208,13 @@ class ClientDb extends Client {
1211
1208
  applyState(items, value, as) {
1212
1209
  for (const item of Array.isArray(items) ? items : [items]) {
1213
1210
  if ((0, types_1.hasBit)(value, 8)) {
1214
- const state = item.transactionState || (item.transactionState = 0);
1211
+ const state = item.transactionState ||= 0;
1215
1212
  if ((0, types_1.hasBit)(state, 4) || (0, types_1.hasBit)(state, 32)) {
1216
1213
  item.transactionState |= value;
1217
1214
  }
1218
1215
  }
1219
1216
  else if ((0, types_1.hasBit)(value, 16)) {
1220
- item.transactionState || (item.transactionState = value);
1217
+ item.transactionState ||= value;
1221
1218
  }
1222
1219
  else if (as) {
1223
1220
  item.transactionState = value;
package/package.json CHANGED
@@ -1,27 +1,27 @@
1
- {
2
- "name": "@e-mc/core",
3
- "version": "0.10.1",
4
- "description": "Core modules 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/core"
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/module": "0.10.1",
24
- "@e-mc/types": "0.10.1",
25
- "picomatch": "^4.0.2"
26
- }
27
- }
1
+ {
2
+ "name": "@e-mc/core",
3
+ "version": "0.10.2",
4
+ "description": "Core modules 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/core"
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/module": "0.10.2",
24
+ "@e-mc/types": "0.10.2",
25
+ "picomatch": "^4.0.2"
26
+ }
27
+ }