@e-mc/core 0.8.5 → 0.8.7
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 +8 -4
- package/README.md +173 -2
- package/index.js +28 -28
- package/package.json +4 -4
package/LICENSE
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
Copyright 2024
|
|
1
|
+
Copyright 2024 An Pham
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
6
6
|
|
|
7
|
-
|
|
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
|
+
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,7 +1,178 @@
|
|
|
1
1
|
# @e-mc/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
* NodeJS 14
|
|
4
|
+
* ES2020
|
|
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.7/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 { 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
|
+
willAbort(value: string | IModule): boolean;
|
|
38
|
+
loadModule(name: string, ...args: any[]): IModule | null;
|
|
39
|
+
retain(process: IModule): void;
|
|
40
|
+
release(process: IModule, log?: boolean): boolean;
|
|
41
|
+
restart(...args: unknown[]): void;
|
|
42
|
+
joinQueue(options?: JoinQueueOptions): boolean;
|
|
43
|
+
resumeThread?(options: ResumeThreadOptions): void;
|
|
44
|
+
set host(value);
|
|
45
|
+
get host(): null;
|
|
46
|
+
get config(): Readonly<HostInitConfig>;
|
|
47
|
+
get errorCount(): number;
|
|
48
|
+
get username(): string;
|
|
49
|
+
set done(value);
|
|
50
|
+
get done(): boolean;
|
|
51
|
+
get queued(): boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface HostConstructor extends ModuleConstructor {
|
|
55
|
+
loadSettings(settings: Settings, password?: string): boolean;
|
|
56
|
+
loadSettings(settings: Settings, permission?: PermissionReadWrite, password?: string): boolean;
|
|
57
|
+
isPermission(value: unknown): value is IPermission;
|
|
58
|
+
createPermission(all?: boolean, freeze?: boolean): IPermission;
|
|
59
|
+
kill(username: string, iv: BinaryLike, all: true): number;
|
|
60
|
+
kill(username: string, iv: BinaryLike, pid: number | number[] | boolean): number;
|
|
61
|
+
getThreadCount(full: true): ThreadCountStat;
|
|
62
|
+
getThreadCount(username: string, iv?: BinaryLike): ThreadCountStat;
|
|
63
|
+
getThreadCount(username?: string | boolean, iv?: BinaryLike): number;
|
|
64
|
+
getPermissionFromSettings(): IPermission;
|
|
65
|
+
readonly prototype: IHost;
|
|
66
|
+
new(config?: HostInitConfig): IHost;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
interface IClient extends IModule<IHost> {
|
|
70
|
+
module: ClientModule;
|
|
71
|
+
init(...args: unknown[]): this;
|
|
72
|
+
getUserSettings(): unknown;
|
|
73
|
+
get settings(): ClientSettings;
|
|
74
|
+
set cacheDir(value: string);
|
|
75
|
+
get cacheDir(): string;
|
|
76
|
+
set extensions(values: unknown[]);
|
|
77
|
+
get extensions(): ((...args: unknown[]) => unknown)[];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface ClientConstructor extends ModuleConstructor {
|
|
81
|
+
readonly prototype: IClient;
|
|
82
|
+
new(module?: ClientModule): IClient;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
interface IClientDb extends IClient<IHost, ClientModule<ClientDbSettings>> {
|
|
86
|
+
database: DataSource[];
|
|
87
|
+
cacheExpires: number;
|
|
88
|
+
add(item: DataSource, state?: number): void;
|
|
89
|
+
hasCache(source: string, sessionKey?: string, override?: DbCacheValue): boolean;
|
|
90
|
+
hasCoerce(source: string, component: keyof DbCoerceSettings, uuidKey: string | undefined): boolean;
|
|
91
|
+
hasCoerce(source: string, component: keyof DbCoerceSettings, override: DbCoerceValue | null | undefined, credential?: unknown): boolean;
|
|
92
|
+
hasCoerce(source: string, component: keyof DbCoerceSettings, credential?: unknown): boolean;
|
|
93
|
+
getQueryResult(source: string, credential: unknown, queryString: string, renewCache: boolean): QueryResult | undefined;
|
|
94
|
+
getQueryResult(source: string, credential: unknown, queryString: string, sessionKey: string, renewCache?: boolean): QueryResult | undefined;
|
|
95
|
+
getQueryResult(source: string, credential: unknown, queryString: string, options?: CacheOptions | string, renewCache?: boolean): QueryResult | undefined;
|
|
96
|
+
setQueryResult(source: string, credential: unknown, queryString: string, result: unknown, sessionKey: string | undefined): QueryResult;
|
|
97
|
+
setQueryResult(source: string, credential: unknown, queryString: string, result: unknown, options?: CacheOptions | string): QueryResult;
|
|
98
|
+
applyState(items: DataSource | DataSource[], value: number, as?: boolean): void;
|
|
99
|
+
commit(items?: DataSource[]): Promise<boolean>;
|
|
100
|
+
valueOfKey(credential: unknown, name: keyof DbSourceOptions, component?: keyof DbCoerceSettings): unknown;
|
|
101
|
+
settingsOf(source: string, name: keyof DbSourceOptions, component?: keyof DbCoerceSettings): unknown;
|
|
102
|
+
settingsKey(uuidKey: string, name: keyof DbSourceOptions, component?: keyof DbCoerceSettings): unknown;
|
|
103
|
+
get pending(): DataSource[];
|
|
104
|
+
get committed(): DataSource[];
|
|
105
|
+
get failed(): DataSource[];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
interface ClientDbConstructor extends ClientConstructor<IHost, ClientModule> {
|
|
109
|
+
STORE_RESULT_PARTITION_SIZE: number;
|
|
110
|
+
STORE_RESULT_PARTITION_MULT: number;
|
|
111
|
+
readonly TRANSACTION_ACTIVE: number;
|
|
112
|
+
readonly TRANSACTION_PARTIAL: number;
|
|
113
|
+
readonly TRANSACTION_COMMIT: number;
|
|
114
|
+
readonly TRANSACTION_TERMINATE: number;
|
|
115
|
+
readonly TRANSACTION_ABORT: number;
|
|
116
|
+
readonly TRANSACTION_FAIL: number;
|
|
117
|
+
loadSettings(settings: Pick<Settings, "process" | "memory">, password?: string) : boolean;
|
|
118
|
+
getTimeout(value: number | string | TimeoutAction | undefined): number;
|
|
119
|
+
convertTime(value: number | string): number;
|
|
120
|
+
findResult(source: string, credential: unknown, queryString: string, timeout: number, sessionKey?: string | boolean, renewCache?: boolean): QueryResult | undefined;
|
|
121
|
+
storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, options: StoreResultOptions): QueryResult;
|
|
122
|
+
storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, sessionKey: string, sessionExpires: number): QueryResult;
|
|
123
|
+
storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, cache: DbCacheValue): QueryResult;
|
|
124
|
+
storeResult(source: string, credential: unknown, queryString: string, result: QueryResult, cache: DbCacheValue | undefined, options: StoreResultOptions): QueryResult;
|
|
125
|
+
purgeResult(prefix?: string): Promise<number>;
|
|
126
|
+
extractUUID(credential: unknown): string;
|
|
127
|
+
setPoolConfig(value: unknown): void;
|
|
128
|
+
getPoolConfig(source: string): unknown;
|
|
129
|
+
keyOfResult(source: string, credential: unknown, uuidOnly?: boolean): string;
|
|
130
|
+
readonly prototype: IClientDb;
|
|
131
|
+
new(module?: ClientModule, database?: DataSource[]): IClientDb;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
interface IAbortComponent extends AbortController {
|
|
135
|
+
reset(): void;
|
|
136
|
+
get aborted(): boolean;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
interface AbortComponentConstructor {
|
|
140
|
+
attach(instance: IAbortComponent, signal: AbortSignal, options?: AddEventListenerOptions): void;
|
|
141
|
+
detach(instance: IAbortComponent, signal: AbortSignal): void;
|
|
142
|
+
readonly prototype: IAbortComponent;
|
|
143
|
+
new(): IAbortComponent;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
interface IPermission {
|
|
147
|
+
setDiskRead(pathname?: string | string[], enabled?: boolean): void;
|
|
148
|
+
setDiskWrite(pathname?: string | string[], enabled?: boolean): void;
|
|
149
|
+
setUNCRead(pathname?: string | string[], enabled?: boolean): void;
|
|
150
|
+
setUNCWrite(pathname?: string | string[], enabled?: boolean): void;
|
|
151
|
+
getDiskRead(): string | string[];
|
|
152
|
+
getDiskWrite(): string | string[];
|
|
153
|
+
getUNCRead(): string | string[];
|
|
154
|
+
getUNCWrite(): string | string[];
|
|
155
|
+
hasDiskRead(pathname: string): boolean;
|
|
156
|
+
hasDiskWrite(pathname: string): boolean;
|
|
157
|
+
hasUNCRead(pathname: string): boolean;
|
|
158
|
+
hasUNCWrite(pathname: string): boolean;
|
|
159
|
+
get diskRead(): boolean;
|
|
160
|
+
get diskWrite(): boolean;
|
|
161
|
+
get uncRead(): boolean;
|
|
162
|
+
get uncWrite(): boolean;
|
|
163
|
+
}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## References
|
|
167
|
+
|
|
168
|
+
- https://www.unpkg.com/@e-mc/types@0.8.7/lib/squared.d.ts
|
|
169
|
+
- https://www.unpkg.com/@e-mc/types@0.8.7/lib/core.d.ts
|
|
170
|
+
- https://www.unpkg.com/@e-mc/types@0.8.7/lib/db.d.ts
|
|
171
|
+
- https://www.unpkg.com/@e-mc/types@0.8.7/lib/dom.d.ts
|
|
172
|
+
- https://www.unpkg.com/@e-mc/types@0.8.7/lib/logger.d.ts
|
|
173
|
+
- https://www.unpkg.com/@e-mc/types@0.8.7/lib/node.d.ts
|
|
174
|
+
- https://www.unpkg.com/@e-mc/types@0.8.7/lib/settings.d.ts
|
|
4
175
|
|
|
5
176
|
## LICENSE
|
|
6
177
|
|
|
7
|
-
|
|
178
|
+
BSD 3-Clause
|
package/index.js
CHANGED
|
@@ -5,8 +5,8 @@ exports.Module = exports.Permission = exports.AbortComponent = exports.ClientDb
|
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const fs = require("fs");
|
|
7
7
|
const pm = require("picomatch");
|
|
8
|
-
const types_1 = require("
|
|
9
|
-
const module_1 = require("
|
|
8
|
+
const types_1 = require("@e-mc/types");
|
|
9
|
+
const module_1 = require("@e-mc/module");
|
|
10
10
|
exports.Module = module_1.default;
|
|
11
11
|
const kConfig = Symbol('config');
|
|
12
12
|
const kQueued = Symbol('queued');
|
|
@@ -26,7 +26,7 @@ const HOST = {
|
|
|
26
26
|
DONE: new Map(),
|
|
27
27
|
QUEUE: [],
|
|
28
28
|
QUEUE_LIMIT: Infinity,
|
|
29
|
-
QUEUE_EXPIRES: 86400000
|
|
29
|
+
QUEUE_EXPIRES: 86400000,
|
|
30
30
|
PID: 1,
|
|
31
31
|
CLOSED: 0,
|
|
32
32
|
QUEUED: 0,
|
|
@@ -38,7 +38,7 @@ const HOST = {
|
|
|
38
38
|
ADMIN_USERS: [],
|
|
39
39
|
ADMIN_PRIVATE: false,
|
|
40
40
|
THREAD_LIMIT: Infinity,
|
|
41
|
-
THREAD_EXPIRES: 86400000
|
|
41
|
+
THREAD_EXPIRES: 86400000,
|
|
42
42
|
PRIORITY_MIN: 0,
|
|
43
43
|
PRIORITY_MAX: 100,
|
|
44
44
|
PRIORITY_BYPASS: undefined
|
|
@@ -78,7 +78,7 @@ function callResumeThread(item, aborted) {
|
|
|
78
78
|
if (item.joined) {
|
|
79
79
|
const { instance, args = [], startTime } = item;
|
|
80
80
|
if (!aborted) {
|
|
81
|
-
instance.writeTimeElapsed('JOIN', ['Thread restarting...', HOST.THREAD_LIMIT > 1 ? 'Availability: ' + HOST.DONE.size + ' / ' + HOST.THREAD_LIMIT : ''], startTime, { type: 2
|
|
81
|
+
instance.writeTimeElapsed('JOIN', ['Thread restarting...', HOST.THREAD_LIMIT > 1 ? 'Availability: ' + HOST.DONE.size + ' / ' + HOST.THREAD_LIMIT : ''], startTime, { type: 2, ...module_1.default.LOG_STYLE_WARN });
|
|
82
82
|
}
|
|
83
83
|
queueMicrotask(() => {
|
|
84
84
|
try {
|
|
@@ -90,7 +90,7 @@ function callResumeThread(item, aborted) {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
function cancelThread(host, hint, rejected) {
|
|
93
|
-
host.writeFail(["Transaction was cancelled"
|
|
93
|
+
host.writeFail(["Transaction was cancelled", host.username], (0, types_1.errorValue)("Thread was killed", hint), { type: 2, fatal: true });
|
|
94
94
|
host.abort();
|
|
95
95
|
if (rejected) {
|
|
96
96
|
++HOST.REJECTED;
|
|
@@ -213,7 +213,7 @@ function resumeHostQueue(host) {
|
|
|
213
213
|
}
|
|
214
214
|
function updateHostQueue(host, position, priority, broadcast) {
|
|
215
215
|
if (!broadcast || host.broadcastId) {
|
|
216
|
-
host.formatMessage(2
|
|
216
|
+
host.formatMessage(2, 'QUEUE', ["Thread limit exceeded" + ` (position #${position + 1})`, host.username], 'Priority: ' + priority, { type: 2, ...module_1.default.LOG_STYLE_WARN });
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
function isInvalidRange(result, range) {
|
|
@@ -225,8 +225,8 @@ function asPosix(value) {
|
|
|
225
225
|
return PLATFORM_WIN32 ? value.replace(/(?:^\\|\\+)/g, '/') : value;
|
|
226
226
|
}
|
|
227
227
|
const readable = (value) => (0, types_1.isString)(value) || (0, types_1.isArray)(value);
|
|
228
|
-
const expireTime = (value) => Date.now() + value * 1000
|
|
229
|
-
const convertSeconds = (value) => typeof value === 'string' && Math.ceil((0, types_1.parseTime)(value) / 1000
|
|
228
|
+
const expireTime = (value) => Date.now() + value * 1000;
|
|
229
|
+
const convertSeconds = (value) => typeof value === 'string' && Math.ceil((0, types_1.parseTime)(value) / 1000) || 0;
|
|
230
230
|
class Host extends module_1.default {
|
|
231
231
|
static async purgeMemory(percent = 1, limit = 0, parent) {
|
|
232
232
|
return parent ? super.purgeMemory(percent, limit) : 0;
|
|
@@ -386,7 +386,7 @@ class Host extends module_1.default {
|
|
|
386
386
|
closeThread(host);
|
|
387
387
|
}
|
|
388
388
|
else if (host.startTime + HOST.THREAD_EXPIRES >= current) {
|
|
389
|
-
host.writeFail(["Transaction was cancelled"
|
|
389
|
+
host.writeFail(["Transaction was cancelled", host.username], (0, types_1.errorValue)("Timeout was exceeded", (0, types_1.formatTime)(HOST.THREAD_EXPIRES)), { fatal: true });
|
|
390
390
|
host.abort();
|
|
391
391
|
closeThread(host);
|
|
392
392
|
}
|
|
@@ -712,12 +712,12 @@ class Client extends module_1.default {
|
|
|
712
712
|
exports.Client = Client;
|
|
713
713
|
_c = kCacheDir;
|
|
714
714
|
class ClientDb extends Client {
|
|
715
|
-
static get TRANSACTION_ACTIVE() { return 1
|
|
716
|
-
static get TRANSACTION_PARTIAL() { return 2
|
|
717
|
-
static get TRANSACTION_COMMIT() { return 4
|
|
718
|
-
static get TRANSACTION_TERMINATE() { return 8
|
|
719
|
-
static get TRANSACTION_ABORT() { return 16
|
|
720
|
-
static get TRANSACTION_FAIL() { return 32
|
|
715
|
+
static get TRANSACTION_ACTIVE() { return 1; }
|
|
716
|
+
static get TRANSACTION_PARTIAL() { return 2; }
|
|
717
|
+
static get TRANSACTION_COMMIT() { return 4; }
|
|
718
|
+
static get TRANSACTION_TERMINATE() { return 8; }
|
|
719
|
+
static get TRANSACTION_ABORT() { return 16; }
|
|
720
|
+
static get TRANSACTION_FAIL() { return 32; }
|
|
721
721
|
static loadSettings(settings, password) {
|
|
722
722
|
if (!super.loadSettings({ process: settings.process }, password)) {
|
|
723
723
|
return false;
|
|
@@ -782,7 +782,7 @@ class ClientDb extends Client {
|
|
|
782
782
|
let result = 0;
|
|
783
783
|
switch (typeof value) {
|
|
784
784
|
case 'number':
|
|
785
|
-
result = value * 1000
|
|
785
|
+
result = value * 1000;
|
|
786
786
|
break;
|
|
787
787
|
case 'string':
|
|
788
788
|
result = (0, types_1.parseTime)(value);
|
|
@@ -901,7 +901,7 @@ class ClientDb extends Client {
|
|
|
901
901
|
else if (typeof sessionKey === 'string' && sessionExpires && sessionExpires > 0) {
|
|
902
902
|
const dbKey = userKey + sessionKey;
|
|
903
903
|
((_k = (CACHE_SESSION[source] || (CACHE_SESSION[source] = {})))[dbKey] || (_k[dbKey] = {}))[queryString] = result;
|
|
904
|
-
setTimeout(() => delete CACHE_SESSION[dbKey], sessionExpires * 1000
|
|
904
|
+
setTimeout(() => delete CACHE_SESSION[dbKey], sessionExpires * 1000);
|
|
905
905
|
}
|
|
906
906
|
}
|
|
907
907
|
return result;
|
|
@@ -971,7 +971,7 @@ class ClientDb extends Client {
|
|
|
971
971
|
constructor(data, database = []) {
|
|
972
972
|
super(data);
|
|
973
973
|
this.database = database;
|
|
974
|
-
this.cacheExpires = 600000
|
|
974
|
+
this.cacheExpires = 600000;
|
|
975
975
|
}
|
|
976
976
|
init(config) {
|
|
977
977
|
let { cache_dir, session_expires: expires } = this.settings;
|
|
@@ -1076,7 +1076,7 @@ class ClientDb extends Client {
|
|
|
1076
1076
|
}
|
|
1077
1077
|
const uuidKey = ClientDb.extractUUID(credential);
|
|
1078
1078
|
let options;
|
|
1079
|
-
if (ClientDb.enabled("memory.settings.users"
|
|
1079
|
+
if (ClientDb.enabled("memory.settings.users", this.host?.username)) {
|
|
1080
1080
|
let value, exclusiveOf;
|
|
1081
1081
|
if ((0, types_1.isObject)(sessionKey)) {
|
|
1082
1082
|
({ value, sessionKey, exclusiveOf } = sessionKey);
|
|
@@ -1102,13 +1102,13 @@ class ClientDb extends Client {
|
|
|
1102
1102
|
}
|
|
1103
1103
|
applyState(items, value, as) {
|
|
1104
1104
|
for (const item of Array.isArray(items) ? items : [items]) {
|
|
1105
|
-
if ((0, types_1.hasBit)(value, 8
|
|
1105
|
+
if ((0, types_1.hasBit)(value, 8)) {
|
|
1106
1106
|
const state = item.transactionState || (item.transactionState = 0);
|
|
1107
|
-
if ((0, types_1.hasBit)(state, 4
|
|
1107
|
+
if ((0, types_1.hasBit)(state, 4) || (0, types_1.hasBit)(state, 32)) {
|
|
1108
1108
|
item.transactionState |= value;
|
|
1109
1109
|
}
|
|
1110
1110
|
}
|
|
1111
|
-
else if ((0, types_1.hasBit)(value, 16
|
|
1111
|
+
else if ((0, types_1.hasBit)(value, 16)) {
|
|
1112
1112
|
item.transactionState || (item.transactionState = value);
|
|
1113
1113
|
}
|
|
1114
1114
|
else if (as) {
|
|
@@ -1141,19 +1141,19 @@ class ClientDb extends Client {
|
|
|
1141
1141
|
get pending() {
|
|
1142
1142
|
return this.database.filter(item => {
|
|
1143
1143
|
const state = item.transactionState || 0;
|
|
1144
|
-
return state === 0 || state === 16
|
|
1144
|
+
return state === 0 || state === 16;
|
|
1145
1145
|
});
|
|
1146
1146
|
}
|
|
1147
1147
|
get committed() {
|
|
1148
|
-
return this.database.filter(item => (item.transactionState & 4
|
|
1148
|
+
return this.database.filter(item => (item.transactionState & 4) === 4);
|
|
1149
1149
|
}
|
|
1150
1150
|
get failed() {
|
|
1151
|
-
return this.database.filter(item => (item.transactionState & 32
|
|
1151
|
+
return this.database.filter(item => (item.transactionState & 32) === 32);
|
|
1152
1152
|
}
|
|
1153
1153
|
}
|
|
1154
1154
|
exports.ClientDb = ClientDb;
|
|
1155
|
-
ClientDb.STORE_RESULT_PARTITION_SIZE = 16
|
|
1156
|
-
ClientDb.STORE_RESULT_PARTITION_MULT = 2
|
|
1155
|
+
ClientDb.STORE_RESULT_PARTITION_SIZE = 16;
|
|
1156
|
+
ClientDb.STORE_RESULT_PARTITION_MULT = 2;
|
|
1157
1157
|
class AbortComponent {
|
|
1158
1158
|
constructor() {
|
|
1159
1159
|
this[_d] = new AbortController();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/core",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.7",
|
|
4
4
|
"description": "Core modules for E-mc.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
"squared-functions"
|
|
18
18
|
],
|
|
19
19
|
"author": "An Pham <anpham6@gmail.com>",
|
|
20
|
-
"license": "
|
|
20
|
+
"license": "BSD 3-Clause",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@e-mc/module": "0.8.
|
|
24
|
-
"@e-mc/types": "0.8.
|
|
23
|
+
"@e-mc/module": "0.8.7",
|
|
24
|
+
"@e-mc/types": "0.8.7",
|
|
25
25
|
"picomatch": "^3.0.1"
|
|
26
26
|
}
|
|
27
27
|
}
|