@e-mc/types 0.6.0 → 0.6.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 +7 -11
- package/README.md +5 -3
- package/constant.d.ts +2 -2
- package/index.d.ts +1 -1
- package/index.js +29 -29
- package/lib/core.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/logger.d.ts +2 -3
- package/lib/request.d.ts +2 -1
- package/lib/settings.d.ts +2 -2
- package/package.json +3 -3
package/LICENSE
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
Copyright 2023
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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.
|
|
1
|
+
Copyright 2023 Ninja Scroll
|
|
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
|
+
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
package/constant.d.ts
CHANGED
package/index.d.ts
CHANGED
|
@@ -269,7 +269,7 @@ declare namespace types {
|
|
|
269
269
|
function cloneObject<T>(data: T, deepIgnore: WeakSet<object>): T;
|
|
270
270
|
function cloneObject<T, U>(data: T, options?: CloneObjectOptions<U>): T;
|
|
271
271
|
function coerceObject<T = unknown>(data: T, cache: boolean): T;
|
|
272
|
-
function coerceObject<T = unknown>(data: T, parseString?: FunctionArgs<[string]
|
|
272
|
+
function coerceObject<T = unknown>(data: T, parseString?: FunctionArgs<[string]>, cache?: boolean): T;
|
|
273
273
|
function getEncoding(value: unknown, fallback?: BufferEncoding): BufferEncoding;
|
|
274
274
|
function encryptUTF8(algorithm: CipherGCMTypes, key: BinaryLike, iv: BinaryLike, data: string, encoding?: Encoding): Undef<string>;
|
|
275
275
|
function decryptUTF8(algorithm: CipherGCMTypes, key: BinaryLike, iv: BinaryLike, data: string, encoding?: Encoding): Undef<string>;
|
package/index.js
CHANGED
|
@@ -9,7 +9,7 @@ const uuid = require("uuid");
|
|
|
9
9
|
const bytes = require("bytes");
|
|
10
10
|
class AbortError extends Error {
|
|
11
11
|
constructor() {
|
|
12
|
-
super("The operation was aborted"
|
|
12
|
+
super("The operation was aborted");
|
|
13
13
|
this.code = 'ABORT_ERR';
|
|
14
14
|
this.name = 'AbortError';
|
|
15
15
|
}
|
|
@@ -19,7 +19,7 @@ const REGEXP_FUNCTION = /^(async\s+)?(function(?:\b|\s+)([\w_$]*)\s*\(([^)]*)\)\
|
|
|
19
19
|
const ASYNC_FUNCTION = Object.getPrototypeOf(async () => { }).constructor;
|
|
20
20
|
let CACHE_COERCED = new WeakSet();
|
|
21
21
|
let LOG_CURRENT = null;
|
|
22
|
-
let TEMP_DIR = path.join(process.cwd(), "tmp"
|
|
22
|
+
let TEMP_DIR = path.join(process.cwd(), "tmp");
|
|
23
23
|
function fromObject(value, typedArray) {
|
|
24
24
|
if (isObject(value)) {
|
|
25
25
|
if (value instanceof Map) {
|
|
@@ -336,35 +336,35 @@ function hasBit(value, flags) {
|
|
|
336
336
|
}
|
|
337
337
|
exports.hasBit = hasBit;
|
|
338
338
|
function ignoreFlag(value) {
|
|
339
|
-
return typeof value === 'number' && (value & 1
|
|
339
|
+
return typeof value === 'number' && (value & 1) === 1;
|
|
340
340
|
}
|
|
341
341
|
exports.ignoreFlag = ignoreFlag;
|
|
342
342
|
function cloneFlag(value) {
|
|
343
|
-
return typeof value === 'number' && (value & 2
|
|
343
|
+
return typeof value === 'number' && (value & 2) === 2;
|
|
344
344
|
}
|
|
345
345
|
exports.cloneFlag = cloneFlag;
|
|
346
346
|
function usingFlag(value) {
|
|
347
|
-
return typeof value === 'number' && (value & 4
|
|
347
|
+
return typeof value === 'number' && (value & 4) === 4;
|
|
348
348
|
}
|
|
349
349
|
exports.usingFlag = usingFlag;
|
|
350
350
|
function watchFlag(value) {
|
|
351
|
-
return typeof value === 'number' && (value & 8
|
|
351
|
+
return typeof value === 'number' && (value & 8) === 8;
|
|
352
352
|
}
|
|
353
353
|
exports.watchFlag = watchFlag;
|
|
354
354
|
function modifiedFlag(value) {
|
|
355
|
-
return typeof value === 'number' && (value & 16
|
|
355
|
+
return typeof value === 'number' && (value & 16) === 16;
|
|
356
356
|
}
|
|
357
357
|
exports.modifiedFlag = modifiedFlag;
|
|
358
358
|
function processFlag(value) {
|
|
359
|
-
return typeof value === 'number' && (value & 32
|
|
359
|
+
return typeof value === 'number' && (value & 32) === 32;
|
|
360
360
|
}
|
|
361
361
|
exports.processFlag = processFlag;
|
|
362
362
|
function mainFlag(value) {
|
|
363
|
-
return typeof value === 'number' && (value & 64
|
|
363
|
+
return typeof value === 'number' && (value & 64) === 64;
|
|
364
364
|
}
|
|
365
365
|
exports.mainFlag = mainFlag;
|
|
366
366
|
function existsFlag(value) {
|
|
367
|
-
return typeof value === 'number' && (value & 128
|
|
367
|
+
return typeof value === 'number' && (value & 128) === 128;
|
|
368
368
|
}
|
|
369
369
|
exports.existsFlag = existsFlag;
|
|
370
370
|
function getLogCurrent() {
|
|
@@ -423,25 +423,25 @@ function parseTime(value, start = 0) {
|
|
|
423
423
|
}
|
|
424
424
|
switch (match[2]) {
|
|
425
425
|
case 'y':
|
|
426
|
-
result += n * 31449600000
|
|
426
|
+
result += n * 31449600000;
|
|
427
427
|
break;
|
|
428
428
|
case 'M':
|
|
429
|
-
result += n * 2592000000
|
|
429
|
+
result += n * 2592000000;
|
|
430
430
|
break;
|
|
431
431
|
case 'w':
|
|
432
|
-
result += n * 604800000
|
|
432
|
+
result += n * 604800000;
|
|
433
433
|
break;
|
|
434
434
|
case 'd':
|
|
435
|
-
result += n * 86400000
|
|
435
|
+
result += n * 86400000;
|
|
436
436
|
break;
|
|
437
437
|
case 'h':
|
|
438
|
-
result += n * 3600000
|
|
438
|
+
result += n * 3600000;
|
|
439
439
|
break;
|
|
440
440
|
case 'm':
|
|
441
|
-
result += n * 60000
|
|
441
|
+
result += n * 60000;
|
|
442
442
|
break;
|
|
443
443
|
case 's':
|
|
444
|
-
result += n * 1000
|
|
444
|
+
result += n * 1000;
|
|
445
445
|
break;
|
|
446
446
|
case 'ms':
|
|
447
447
|
result += Math.ceil(n);
|
|
@@ -453,7 +453,7 @@ function parseTime(value, start = 0) {
|
|
|
453
453
|
}
|
|
454
454
|
}
|
|
455
455
|
else if (seconds > 0) {
|
|
456
|
-
return Math.ceil(seconds * 1000
|
|
456
|
+
return Math.ceil(seconds * 1000) + start;
|
|
457
457
|
}
|
|
458
458
|
return 0;
|
|
459
459
|
}
|
|
@@ -476,18 +476,18 @@ function formatTime(value, elapsed, char = ' ') {
|
|
|
476
476
|
if (value < 1000) {
|
|
477
477
|
return value + 'ms';
|
|
478
478
|
}
|
|
479
|
-
const h = Math.floor(value / 3600000
|
|
479
|
+
const h = Math.floor(value / 3600000);
|
|
480
480
|
if (h > 0) {
|
|
481
|
-
value -= h * 3600000
|
|
481
|
+
value -= h * 3600000;
|
|
482
482
|
result.push(h + 'h');
|
|
483
483
|
}
|
|
484
|
-
const m = Math.floor(value / 60000
|
|
484
|
+
const m = Math.floor(value / 60000);
|
|
485
485
|
if (m > 0) {
|
|
486
|
-
value -= m * 60000
|
|
486
|
+
value -= m * 60000;
|
|
487
487
|
result.push(m + 'm');
|
|
488
488
|
}
|
|
489
489
|
if (value > 0) {
|
|
490
|
-
result.push(value < 100 ? value + 'ms' : (value / 1000
|
|
490
|
+
result.push(value < 100 ? value + 'ms' : (value / 1000).toPrecision(value <= 9950 ? 2 : 3).replace(/\.?0+$/, '') + 's');
|
|
491
491
|
}
|
|
492
492
|
return result.join(char);
|
|
493
493
|
}
|
|
@@ -543,10 +543,10 @@ function escapePattern(value, lookBehind) {
|
|
|
543
543
|
}
|
|
544
544
|
exports.escapePattern = escapePattern;
|
|
545
545
|
function renameExt(value, ext, when) {
|
|
546
|
-
if (ext
|
|
546
|
+
if (!ext.startsWith('.')) {
|
|
547
547
|
ext = '.' + ext;
|
|
548
548
|
}
|
|
549
|
-
if (when && when
|
|
549
|
+
if (when && !when.startsWith('.')) {
|
|
550
550
|
when = '.' + when;
|
|
551
551
|
}
|
|
552
552
|
const index = value.lastIndexOf('.');
|
|
@@ -568,7 +568,7 @@ function formatSize(value, options) {
|
|
|
568
568
|
exports.formatSize = formatSize;
|
|
569
569
|
function cascadeObject(data, query, fallback) {
|
|
570
570
|
if (isObject(data) && isString(query)) {
|
|
571
|
-
const names = query.trim().split(/(?<!\\)\./).map(item => item.
|
|
571
|
+
const names = query.trim().split(/(?<!\\)\./).map(item => item.includes('.') ? item.replace(/\\(?=\.)/g, '') : item);
|
|
572
572
|
for (let i = 0, length = names.length, match, current = data; i < length; ++i) {
|
|
573
573
|
if (!(match = /^(.+?)(?:\[(.+)\])?$/.exec(names[i]))) {
|
|
574
574
|
break;
|
|
@@ -723,8 +723,8 @@ function coerceObject(data, parseString, cache) {
|
|
|
723
723
|
}
|
|
724
724
|
default: {
|
|
725
725
|
const text = match[2].trim();
|
|
726
|
-
let values = [];
|
|
727
|
-
if (text
|
|
726
|
+
let values = [];
|
|
727
|
+
if (text.startsWith('[') && text.endsWith(']')) {
|
|
728
728
|
values = JSON.parse(text);
|
|
729
729
|
}
|
|
730
730
|
else if (text) {
|
|
@@ -849,7 +849,7 @@ function randomString(format, dictionary) {
|
|
|
849
849
|
dictionary || (dictionary = '0123456789abcdef');
|
|
850
850
|
const result = format.match(/(\d+|[^\d[]+|\[[^\]]+\]|\[)/g).reduce((a, b) => {
|
|
851
851
|
let length, available;
|
|
852
|
-
if (b
|
|
852
|
+
if (b.startsWith('[') && b.endsWith(']')) {
|
|
853
853
|
length = 1;
|
|
854
854
|
available = b.substring(1, b.length - 1);
|
|
855
855
|
}
|
package/lib/core.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface IdentifierAction {
|
|
|
12
12
|
uuidKey?: string;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export interface IClient<T extends IHost, U extends ClientModule, V extends FunctionType = FunctionType> extends IModule<T>, IExternalConfig<U, U extends ClientModule<infer W> ? W : unknown>, IExternalFunction<V> {
|
|
15
|
+
export interface IClient<T extends IHost, U extends ClientModule, V extends FunctionType<any, any> = FunctionType> extends IModule<T>, IExternalConfig<U, U extends ClientModule<infer W> ? W : unknown>, IExternalFunction<V> {
|
|
16
16
|
init(...args: unknown[]): this;
|
|
17
17
|
set cacheDir(value: string);
|
|
18
18
|
get cacheDir(): string;
|
package/lib/index.d.ts
CHANGED
|
@@ -83,7 +83,7 @@ declare namespace functions {
|
|
|
83
83
|
new(module?: U): ICompress<T, U>;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
interface IImage<T extends IHost = IHost, U extends ImageModule = ImageModule> extends IClient<T, U
|
|
86
|
+
interface IImage<T extends IHost = IHost, U extends ImageModule = ImageModule> extends IClient<T, U> {
|
|
87
87
|
resizeData?: ResizeData;
|
|
88
88
|
cropData?: CropData;
|
|
89
89
|
rotateData?: RotateData;
|
package/lib/logger.d.ts
CHANGED
|
@@ -93,10 +93,9 @@ export interface LogTypeValue {
|
|
|
93
93
|
sessionId?: string;
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
export interface LogArguments {
|
|
97
|
-
type?: LogType;
|
|
98
|
-
value?: LogValue;
|
|
96
|
+
export interface LogArguments extends Pick<LogBaseOptions, "type" | "sessionId"> {
|
|
99
97
|
title?: string;
|
|
98
|
+
value?: LogValue;
|
|
100
99
|
message?: unknown;
|
|
101
100
|
}
|
|
102
101
|
|
package/lib/request.d.ts
CHANGED
|
@@ -65,7 +65,6 @@ export interface OpenOptions extends KeepAliveAction, SilentAction {
|
|
|
65
65
|
postData?: unknown;
|
|
66
66
|
connected?: (headers: IncomingHttpHeaders) => Void<boolean>;
|
|
67
67
|
statusMessage?: string;
|
|
68
|
-
silent?: boolean;
|
|
69
68
|
outFormat?: { out: BufferFormat; parser?: PlainObject };
|
|
70
69
|
outFilename?: Null<string>;
|
|
71
70
|
outHeaders?: Null<IncomingHttpHeaders>;
|
|
@@ -105,7 +104,9 @@ export interface ProxySettings extends KeepAliveAction {
|
|
|
105
104
|
|
|
106
105
|
export interface RequestInit extends ProtocolAction {
|
|
107
106
|
headers?: unknown;
|
|
107
|
+
/* @deprecated - readTimeout */
|
|
108
108
|
requestTimeout?: number;
|
|
109
|
+
readTimeout?: number;
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
export interface ClientConfig {
|
package/lib/settings.d.ts
CHANGED
|
@@ -81,8 +81,8 @@ export interface PermissionModule<T = PermissionSettings> extends PermittedDirec
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
export interface PermissionSettings extends PlainObject {
|
|
84
|
-
picomatch?: PicomatchOptions
|
|
85
|
-
minimatch?: MinimatchOptions
|
|
84
|
+
picomatch?: Null<PicomatchOptions>;
|
|
85
|
+
minimatch?: Null<MinimatchOptions>;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
export interface DownloadModule<T = PlainObject> extends HandlerSettings<T> {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e-mc/types",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Type definitions 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": "MIT",
|
|
21
21
|
"homepage": "https://github.com/anpham6/e-mc#readme",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"bytes": "^3.1.2",
|
|
24
|
-
"uuid": "^9.0.
|
|
24
|
+
"uuid": "^9.0.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"typescript": "5.1.6"
|