@e-mc/types 0.12.10 → 0.12.12

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 CHANGED
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## Interface
11
11
 
12
- * [View Source](https://www.unpkg.com/@e-mc/types@0.12.10/index.d.ts)
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.12.12/index.d.ts)
13
13
 
14
14
  ```typescript
15
15
  import type { LogArguments } from "./lib/logger";
@@ -56,7 +56,8 @@ function formatSize(value: number, options?: BytesOptions): string;
56
56
  function alignSize(value: unknown, kb?: number, factor?: number): number;
57
57
  function cascadeObject(data: object, query: string, fallback?: unknown): unknown;
58
58
  function cloneObject(data: unknown, deep: boolean): unknown;
59
- function cloneObject(data: unknown, deepIgnore: WeakSet<object>): unknown;
59
+ /** @deprecated WeakMap<object> */
60
+ function cloneObject<T>(data: T, deepIgnore: WeakSet<object> | WeakMap<object, object>): T;
60
61
  function cloneObject(data: unknown, options?: CloneObjectOptions<unknown>): unknown;
61
62
  function coerceObject(data: unknown, cache: boolean): unknown;
62
63
  function coerceObject(data: unknown, parseString?: (...args: [string]) => unknown, cache?: boolean): unknown;
@@ -203,10 +204,10 @@ const IMPORT_MAP: Record<string, string | undefined>;
203
204
 
204
205
  ## References
205
206
 
206
- - https://www.unpkg.com/@e-mc/types@0.12.10/index.d.ts
207
- - https://www.unpkg.com/@e-mc/types@0.12.10/lib/logger.d.ts
208
- - https://www.unpkg.com/@e-mc/types@0.12.10/lib/module.d.ts
209
- - https://www.unpkg.com/@e-mc/types@0.12.10/lib/node.d.ts
207
+ - https://www.unpkg.com/@e-mc/types@0.12.12/index.d.ts
208
+ - https://www.unpkg.com/@e-mc/types@0.12.12/lib/logger.d.ts
209
+ - https://www.unpkg.com/@e-mc/types@0.12.12/lib/module.d.ts
210
+ - https://www.unpkg.com/@e-mc/types@0.12.12/lib/node.d.ts
210
211
 
211
212
  * https://developer.mozilla.org/en-US/docs/Web/API/DOMException
212
213
  * https://www.npmjs.com/package/@types/bytes
package/constant.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export const enum INTERNAL {
2
- VERSION = '0.12.10',
2
+ VERSION = '0.12.12',
3
3
  TEMP_DIR = 'tmp',
4
4
  CJS = '__cjs__'
5
5
  }
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
- deepIgnore?: WeakSet<object>;
272
+ /** @deprecated WeakSet<object> */
273
+ deepIgnore?: WeakSet<object> | WeakMap<object, object>;
273
274
  freezeDepth?: number | boolean;
274
275
  mergeArray?: MergeArrayMethod;
275
276
  mergeDepth?: number;
@@ -324,7 +325,8 @@ declare namespace types {
324
325
  function alignSize(value: unknown, kb?: number, factor?: number): number;
325
326
  function cascadeObject<T = unknown>(data: object, query: string, fallback?: unknown): T;
326
327
  function cloneObject<T>(data: T, deep: boolean): T;
327
- function cloneObject<T>(data: T, deepIgnore: WeakSet<object>): T;
328
+ /** @deprecated WeakMap<object> */
329
+ function cloneObject<T>(data: T, deepIgnore: WeakSet<object> | WeakMap<object, object>): T;
328
330
  function cloneObject<T, U>(data: T, options?: CloneObjectOptions<U>): T;
329
331
  function coerceObject<T = unknown>(data: T, cache: boolean): T;
330
332
  function coerceObject<T = unknown>(data: T, parseString?: FunctionArgs<[string]>, cache?: boolean): T;
package/index.js CHANGED
@@ -865,7 +865,7 @@ function cloneObject(data, options) {
865
865
  if (options === true) {
866
866
  deep = true;
867
867
  }
868
- else if (options instanceof WeakSet) {
868
+ else if (options instanceof WeakSet || options instanceof WeakMap) {
869
869
  deep = true;
870
870
  structured = true;
871
871
  deepIgnore = options;
@@ -884,11 +884,13 @@ function cloneObject(data, options) {
884
884
  }
885
885
  let nested;
886
886
  if (deep || freezeDepth > 0) {
887
- deepIgnore ||= new WeakSet();
887
+ deepIgnore ||= new WeakMap();
888
888
  nested = { deep, deepIgnore, freezeDepth, mergeArray, mergeDepth, typedArray, structured, preserve };
889
889
  }
890
890
  if (Array.isArray(data)) {
891
- deepIgnore?.add(data);
891
+ if (deepIgnore instanceof WeakSet) {
892
+ deepIgnore.add(data);
893
+ }
892
894
  const length = data.length;
893
895
  if (Array.isArray(target)) {
894
896
  if (mergeArray && mergeDepth >= 0 && !(mergeArray === 'join' || Array.isArray(mergeArray) && mergeArray[0] === 'join')) {
@@ -902,18 +904,33 @@ function cloneObject(data, options) {
902
904
  else {
903
905
  target = new Array(length);
904
906
  }
905
- for (let i = 0; i < length; ++i) {
907
+ for (let i = 0, merge; i < length; ++i) {
906
908
  const value = data[i];
907
909
  if (deepIgnore) {
908
- target[i] = (Array.isArray(value) || isPlainObject(value)) && !deepIgnore.has(value) ? cloneObject(value, nested) : fromObject(value, typedArray, structured, shared);
910
+ const found = deepIgnore.has(value);
911
+ if (found && deepIgnore instanceof WeakMap) {
912
+ merge = deepIgnore.get(value);
913
+ }
914
+ else if (!found && (Array.isArray(value) || isPlainObject(value))) {
915
+ merge = cloneObject(value, nested);
916
+ if (deepIgnore instanceof WeakMap) {
917
+ deepIgnore.set(value, merge);
918
+ }
919
+ }
920
+ else {
921
+ merge = fromObject(value, typedArray, structured, shared);
922
+ }
909
923
  }
910
924
  else {
911
- target[i] = Array.isArray(value) ? value.slice(0) : value;
925
+ merge = Array.isArray(value) ? value.slice(0) : value;
912
926
  }
927
+ target[i] = merge;
913
928
  }
914
929
  }
915
930
  else if (isObject(data)) {
916
- deepIgnore?.add(data);
931
+ if (deepIgnore instanceof WeakSet) {
932
+ deepIgnore.add(data);
933
+ }
917
934
  if (!isObject(target)) {
918
935
  target = {};
919
936
  }
@@ -921,7 +938,19 @@ function cloneObject(data, options) {
921
938
  const value = data[attr];
922
939
  let merge;
923
940
  if (deepIgnore) {
924
- merge = (Array.isArray(value) || isPlainObject(value)) && !deepIgnore.has(value) ? cloneObject(value, nested) : fromObject(value, typedArray, structured, shared);
941
+ const found = deepIgnore.has(value);
942
+ if (found && deepIgnore instanceof WeakMap) {
943
+ merge = deepIgnore.get(value);
944
+ }
945
+ else if (!found && (Array.isArray(value) || isPlainObject(value))) {
946
+ merge = cloneObject(value, nested);
947
+ if (deepIgnore instanceof WeakMap) {
948
+ deepIgnore.set(value, merge);
949
+ }
950
+ }
951
+ else {
952
+ merge = fromObject(value, typedArray, structured, shared);
953
+ }
925
954
  }
926
955
  else {
927
956
  merge = Array.isArray(value) ? value.slice(0) : value;
package/lib/settings.d.ts CHANGED
@@ -350,6 +350,7 @@ export interface WatchSettings<T = WatchUserSettings> extends ClientSettings<Obj
350
350
  export interface CompressModule<U = CompressSettings> extends HandlerSettings<U> {
351
351
  gzip?: ZlibOptions;
352
352
  brotli?: BrotliOptions;
353
+ /** @deprecated */
353
354
  zopfli?: ZopfliOptions;
354
355
  }
355
356
 
@@ -358,6 +359,7 @@ export interface CompressSettings extends PlainObject {
358
359
  cache_expires?: number | string;
359
360
  gzip_level?: number | string;
360
361
  brotli_quality?: number | string;
362
+ /** @deprecated */
361
363
  zopfli_iterations?: number | string;
362
364
  chunk_size?: number | string;
363
365
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e-mc/types",
3
- "version": "0.12.10",
3
+ "version": "0.12.12",
4
4
  "description": "Type definitions for E-mc.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",