@e-mc/types 0.13.3 → 0.13.5
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/README.md +7 -6
- package/constant.d.ts +1 -1
- package/index.d.ts +4 -2
- package/index.js +37 -8
- package/lib/http.d.ts +4 -4
- package/lib/index.d.ts +1 -1
- package/lib/request.d.ts +3 -1
- package/lib/settings.d.ts +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
## Interface
|
|
11
11
|
|
|
12
|
-
* [View Source](https://www.unpkg.com/@e-mc/types@0.13.
|
|
12
|
+
* [View Source](https://www.unpkg.com/@e-mc/types@0.13.5/index.d.ts)
|
|
13
13
|
|
|
14
14
|
```typescript
|
|
15
15
|
import type { LogArguments } from "./lib/logger";
|
|
@@ -60,7 +60,8 @@ function formatSize(value: number, options?: BytesOptions): string;
|
|
|
60
60
|
function alignSize(value: unknown, kb?: number, factor?: number): number;
|
|
61
61
|
function cascadeObject(data: object, query: string, fallback?: unknown): unknown;
|
|
62
62
|
function cloneObject(data: unknown, deep: boolean): unknown;
|
|
63
|
-
|
|
63
|
+
/** @deprecated WeakMap<object> */
|
|
64
|
+
function cloneObject<T>(data: T, deepIgnore: WeakSet<object> | WeakMap<object, object>): T;
|
|
64
65
|
function cloneObject(data: unknown, options?: CloneObjectOptions<unknown>): unknown;
|
|
65
66
|
function coerceObject(data: unknown, cache: boolean): unknown;
|
|
66
67
|
function coerceObject(data: unknown, parseString?: (...args: [string]) => unknown, cache?: boolean): unknown;
|
|
@@ -207,10 +208,10 @@ const IMPORT_MAP: Record<string, string | undefined>;
|
|
|
207
208
|
|
|
208
209
|
## References
|
|
209
210
|
|
|
210
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
211
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
212
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
213
|
-
- https://www.unpkg.com/@e-mc/types@0.13.
|
|
211
|
+
- https://www.unpkg.com/@e-mc/types@0.13.5/index.d.ts
|
|
212
|
+
- https://www.unpkg.com/@e-mc/types@0.13.5/lib/logger.d.ts
|
|
213
|
+
- https://www.unpkg.com/@e-mc/types@0.13.5/lib/module.d.ts
|
|
214
|
+
- https://www.unpkg.com/@e-mc/types@0.13.5/lib/node.d.ts
|
|
214
215
|
|
|
215
216
|
* https://developer.mozilla.org/en-US/docs/Web/API/DOMException
|
|
216
217
|
* https://www.npmjs.com/package/@types/bytes
|
package/constant.d.ts
CHANGED
package/index.d.ts
CHANGED
|
@@ -269,7 +269,8 @@ declare namespace types {
|
|
|
269
269
|
interface CloneObjectOptions<T = unknown> {
|
|
270
270
|
target?: T;
|
|
271
271
|
deep?: boolean;
|
|
272
|
-
|
|
272
|
+
/** @deprecated WeakSet<object> */
|
|
273
|
+
deepIgnore?: WeakSet<object> | WeakMap<object, object>;
|
|
273
274
|
freezeDepth?: number | boolean;
|
|
274
275
|
mergeArray?: MergeArrayMethod;
|
|
275
276
|
mergeDepth?: number;
|
|
@@ -328,7 +329,8 @@ declare namespace types {
|
|
|
328
329
|
function alignSize(value: unknown, kb?: number, factor?: number): number;
|
|
329
330
|
function cascadeObject<T = unknown>(data: object, query: string, fallback?: unknown): T;
|
|
330
331
|
function cloneObject<T>(data: T, deep: boolean): T;
|
|
331
|
-
|
|
332
|
+
/** @deprecated WeakMap<object> */
|
|
333
|
+
function cloneObject<T>(data: T, deepIgnore: WeakSet<object> | WeakMap<object, object>): T;
|
|
332
334
|
function cloneObject<T, U>(data: T, options?: CloneObjectOptions<U>): T;
|
|
333
335
|
function coerceObject<T = unknown>(data: T, cache: boolean): T;
|
|
334
336
|
function coerceObject<T = unknown>(data: T, parseString?: FunctionArgs<[string]>, cache?: boolean): T;
|
package/index.js
CHANGED
|
@@ -888,7 +888,7 @@ function cloneObject(data, options) {
|
|
|
888
888
|
if (options === true) {
|
|
889
889
|
deep = true;
|
|
890
890
|
}
|
|
891
|
-
else if (options instanceof WeakSet) {
|
|
891
|
+
else if (options instanceof WeakSet || options instanceof WeakMap) {
|
|
892
892
|
deep = true;
|
|
893
893
|
structured = true;
|
|
894
894
|
deepIgnore = options;
|
|
@@ -907,11 +907,13 @@ function cloneObject(data, options) {
|
|
|
907
907
|
}
|
|
908
908
|
let nested;
|
|
909
909
|
if (deep || freezeDepth > 0) {
|
|
910
|
-
deepIgnore ||= new
|
|
910
|
+
deepIgnore ||= new WeakMap();
|
|
911
911
|
nested = { deep, deepIgnore, freezeDepth, mergeArray, mergeDepth, typedArray, structured, preserve };
|
|
912
912
|
}
|
|
913
913
|
if (Array.isArray(data)) {
|
|
914
|
-
deepIgnore
|
|
914
|
+
if (deepIgnore instanceof WeakSet) {
|
|
915
|
+
deepIgnore.add(data);
|
|
916
|
+
}
|
|
915
917
|
const length = data.length;
|
|
916
918
|
if (Array.isArray(target)) {
|
|
917
919
|
if (mergeArray && mergeDepth >= 0 && !(mergeArray === 'join' || Array.isArray(mergeArray) && mergeArray[0] === 'join')) {
|
|
@@ -925,18 +927,33 @@ function cloneObject(data, options) {
|
|
|
925
927
|
else {
|
|
926
928
|
target = new Array(length);
|
|
927
929
|
}
|
|
928
|
-
for (let i = 0; i < length; ++i) {
|
|
930
|
+
for (let i = 0, merge; i < length; ++i) {
|
|
929
931
|
const value = data[i];
|
|
930
932
|
if (deepIgnore) {
|
|
931
|
-
|
|
933
|
+
const found = deepIgnore.has(value);
|
|
934
|
+
if (found && deepIgnore instanceof WeakMap) {
|
|
935
|
+
merge = deepIgnore.get(value);
|
|
936
|
+
}
|
|
937
|
+
else if (!found && (Array.isArray(value) || isPlainObject(value))) {
|
|
938
|
+
merge = cloneObject(value, nested);
|
|
939
|
+
if (deepIgnore instanceof WeakMap) {
|
|
940
|
+
deepIgnore.set(value, merge);
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
else {
|
|
944
|
+
merge = fromObject(value, typedArray, structured, shared);
|
|
945
|
+
}
|
|
932
946
|
}
|
|
933
947
|
else {
|
|
934
|
-
|
|
948
|
+
merge = Array.isArray(value) ? value.slice(0) : value;
|
|
935
949
|
}
|
|
950
|
+
target[i] = merge;
|
|
936
951
|
}
|
|
937
952
|
}
|
|
938
953
|
else if (isObject(data)) {
|
|
939
|
-
deepIgnore
|
|
954
|
+
if (deepIgnore instanceof WeakSet) {
|
|
955
|
+
deepIgnore.add(data);
|
|
956
|
+
}
|
|
940
957
|
if (!isObject(target)) {
|
|
941
958
|
target = {};
|
|
942
959
|
}
|
|
@@ -944,7 +961,19 @@ function cloneObject(data, options) {
|
|
|
944
961
|
const value = data[attr];
|
|
945
962
|
let merge;
|
|
946
963
|
if (deepIgnore) {
|
|
947
|
-
|
|
964
|
+
const found = deepIgnore.has(value);
|
|
965
|
+
if (found && deepIgnore instanceof WeakMap) {
|
|
966
|
+
merge = deepIgnore.get(value);
|
|
967
|
+
}
|
|
968
|
+
else if (!found && (Array.isArray(value) || isPlainObject(value))) {
|
|
969
|
+
merge = cloneObject(value, nested);
|
|
970
|
+
if (deepIgnore instanceof WeakMap) {
|
|
971
|
+
deepIgnore.set(value, merge);
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
else {
|
|
975
|
+
merge = fromObject(value, typedArray, structured, shared);
|
|
976
|
+
}
|
|
948
977
|
}
|
|
949
978
|
else {
|
|
950
979
|
merge = Array.isArray(value) ? value.slice(0) : value;
|
package/lib/http.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LookupAddress } from 'node:dns';
|
|
2
|
-
import type { ClientRequest, Agent as HttpAgent, OutgoingHttpHeaders } from 'node:http';
|
|
2
|
+
import type { AgentOptions, ClientRequest, Agent as HttpAgent, OutgoingHttpHeaders } from 'node:http';
|
|
3
3
|
import type { Agent as HttpsAgent } from 'node:https';
|
|
4
4
|
import type { ClientHttp2Stream } from 'node:http2';
|
|
5
5
|
import type { SecureVersion } from 'node:tls';
|
|
@@ -85,11 +85,10 @@ export interface HeadersAction {
|
|
|
85
85
|
headers?: OutgoingHttpHeaders | Headers;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
export interface HttpAgentSettings {
|
|
88
|
+
export interface HttpAgentSettings extends HttpAgentOptions {
|
|
89
89
|
http?: HttpAgent;
|
|
90
90
|
https?: HttpsAgent;
|
|
91
91
|
keepAlive?: boolean;
|
|
92
|
-
timeout?: number;
|
|
93
92
|
}
|
|
94
93
|
|
|
95
94
|
export interface SecureConfig<T = string, U = T> {
|
|
@@ -114,6 +113,7 @@ export interface AuthValue {
|
|
|
114
113
|
|
|
115
114
|
export type HttpRequestClient = ClientRequest | ClientHttp2Stream;
|
|
116
115
|
export type HttpOutgoingHeaders = ObjectMap<OutgoingHttpHeaders>;
|
|
116
|
+
export type HttpAgentOptions = Pick<AgentOptions, "timeout" | "maxSockets" | "maxTotalSockets" | "keepAliveMsecs" | "maxFreeSockets" | "proxyEnv">;
|
|
117
117
|
export type HttpProtocolVersion = 1 | 2 | 3;
|
|
118
118
|
export type InternetProtocolVersion = 0 | 4 | 6;
|
|
119
|
-
export type LookupCallback = (err: NodeJS.ErrnoException | null, address: string | LookupAddress[], family?: number) => void;
|
|
119
|
+
export type LookupCallback = (err: NodeJS.ErrnoException | null, address: string | LookupAddress[], family?: number) => void;
|
package/lib/index.d.ts
CHANGED
|
@@ -680,7 +680,7 @@ declare namespace functions {
|
|
|
680
680
|
getThreadCount(username: string, iv?: BinaryLike): ThreadCountStat;
|
|
681
681
|
getThreadCount(username?: string | boolean, iv?: BinaryLike): number;
|
|
682
682
|
getLogDelayed(): FormatMessageArgs[];
|
|
683
|
-
getPermissionFromSettings(): IPermission;
|
|
683
|
+
getPermissionFromSettings(freeze?: boolean): IPermission;
|
|
684
684
|
readonly prototype: IHost;
|
|
685
685
|
new(config?: HostInitConfig): IHost;
|
|
686
686
|
}
|
package/lib/request.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { EncodingAction } from './squared';
|
|
|
2
2
|
|
|
3
3
|
import type { IRequest } from './index';
|
|
4
4
|
import type { BinaryAction } from './asset';
|
|
5
|
-
import type { HeadersAction, HttpProtocolVersion, HttpRequestClient, InternetProtocolVersion } from './http';
|
|
5
|
+
import type { HeadersAction, HttpAgentOptions, HttpProtocolVersion, HttpRequestClient, InternetProtocolVersion } from './http';
|
|
6
6
|
import type { IncludeAction } from './module';
|
|
7
7
|
import type { ErrorCode } from './node';
|
|
8
8
|
import type { HttpHostSettings, RequestModule } from './settings';
|
|
@@ -12,7 +12,9 @@ import type { Readable, Writable } from 'node:stream';
|
|
|
12
12
|
|
|
13
13
|
interface KeepAliveAction {
|
|
14
14
|
keepAlive?: boolean;
|
|
15
|
+
/** @deprecated */
|
|
15
16
|
agentTimeout?: number;
|
|
17
|
+
agentOptions?: HttpAgentOptions;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
interface SilentAction {
|
package/lib/settings.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type { ExecAction, IncludeAction } from './module';
|
|
|
11
11
|
import type { SpawnOptions } from 'node:child_process';
|
|
12
12
|
import type { BinaryLike, CipherGCMTypes } from 'node:crypto';
|
|
13
13
|
import type { LookupAddress } from 'node:dns';
|
|
14
|
+
import type { AgentOptions } from 'node:http';
|
|
14
15
|
import type { BrotliOptions, ZlibOptions } from 'node:zlib';
|
|
15
16
|
// @ts-ignore
|
|
16
17
|
import type { BackgroundColor as IBackgroundColor } from 'chalk';
|
|
@@ -314,7 +315,9 @@ export interface RequestModule<T = RequestSettings> extends HandlerSettings<T>,
|
|
|
314
315
|
read_timeout?: number | string;
|
|
315
316
|
agent?: {
|
|
316
317
|
keep_alive?: boolean;
|
|
318
|
+
keep_alive_interval?: number | string;
|
|
317
319
|
timeout?: number | string;
|
|
320
|
+
proxy_env?: AgentOptions["proxyEnv"];
|
|
318
321
|
};
|
|
319
322
|
disk?: HttpDiskSettings;
|
|
320
323
|
buffer?: HttpMemorySettings;
|
|
@@ -335,6 +338,7 @@ export interface HttpProxySettings extends AuthValue, IncludeAction {
|
|
|
335
338
|
port?: number | string;
|
|
336
339
|
origin?: string;
|
|
337
340
|
keep_alive?: boolean;
|
|
341
|
+
keep_alive_interval?: number | string;
|
|
338
342
|
}
|
|
339
343
|
|
|
340
344
|
export interface HttpHostSettings {
|
|
@@ -360,6 +364,7 @@ export interface WatchSettings<T = WatchUserSettings> extends ClientSettings<Obj
|
|
|
360
364
|
export interface CompressModule<U = CompressSettings> extends HandlerSettings<U> {
|
|
361
365
|
gzip?: ZlibOptions;
|
|
362
366
|
brotli?: BrotliOptions;
|
|
367
|
+
/** @deprecated */
|
|
363
368
|
zopfli?: ZopfliOptions;
|
|
364
369
|
}
|
|
365
370
|
|
|
@@ -369,6 +374,7 @@ export interface CompressSettings extends PlainObject {
|
|
|
369
374
|
cache_expires?: number | string;
|
|
370
375
|
gzip_level?: number | string;
|
|
371
376
|
brotli_quality?: number | string;
|
|
377
|
+
/** @deprecated */
|
|
372
378
|
zopfli_iterations?: number | string;
|
|
373
379
|
chunk_size?: number | string;
|
|
374
380
|
}
|