flatpack-json 9.6.4 → 9.8.0

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.
@@ -0,0 +1,10 @@
1
+ import type { Flatpacked, FlatpackOptions, Serializable } from './types.mjs';
2
+ export interface CompactStorageApi {
3
+ toJSON<V extends Serializable>(json: V): Flatpacked;
4
+ }
5
+ export declare abstract class CompactStorage implements CompactStorageApi {
6
+ readonly options?: FlatpackOptions | undefined;
7
+ constructor(options?: FlatpackOptions | undefined);
8
+ abstract toJSON<V extends Serializable>(json: V): Flatpacked;
9
+ }
10
+ //# sourceMappingURL=CompactStorage.d.mts.map
@@ -0,0 +1,7 @@
1
+ export class CompactStorage {
2
+ options;
3
+ constructor(options) {
4
+ this.options = options;
5
+ }
6
+ }
7
+ //# sourceMappingURL=CompactStorage.mjs.map
@@ -1,99 +1,15 @@
1
1
  import { FlatpackedWrapper } from './flatpackUtil.mjs';
2
- import type { Flatpacked, FlatpackOptions, Serializable, Unpacked } from './types.mjs';
3
- export declare class FlatpackStore {
2
+ import type { FlatpackApi, Flatpacked, FlatpackOptions, Serializable, Unpacked } from './types.mjs';
3
+ export declare class FlatpackStore implements FlatpackApi {
4
4
  #private;
5
5
  readonly options?: FlatpackOptions | undefined;
6
- private knownElements;
7
- private assignedElements;
8
- private elements;
9
- private root;
10
- private dedupe;
11
- private sortKeys;
12
- private emptyObjIdx;
13
- private ids;
14
- /**
15
- * Cache of primitives and objects that have been added to the data.
16
- */
17
- private cache;
18
- /**
19
- * Set of elements that have been referenced by other indexes.
20
- */
21
- private referenced;
22
- /**
23
- * Cache of arrays that have been deduped.
24
- * The key is a hash of the array elements as a function of the index of the element.
25
- */
26
- private cachedArrays;
27
- private cachedObjects;
28
- private cachedSets;
29
- private cachedMaps;
30
- private cachedProxies;
31
- /**
32
- * Cache of strings that have been deduped and stored in the data array.
33
- */
34
- private knownStrings;
35
- /**
36
- * Cache of reversed strings that have been deduped and stored in the data array.
37
- * This is used to find matching suffixes.
38
- */
39
- private knownStringsRev;
40
- private refUndefined;
41
6
  constructor(value: Serializable | FlatpackedWrapper, options?: FlatpackOptions | undefined);
42
7
  setValue(value: Serializable): void;
43
- private nextId;
44
- private addElement;
45
- private addValueAndElement;
46
- private primitiveToRef;
47
- private createSubStringRef;
48
- private addKnownString;
49
- private addStringPrimitive;
50
- private addStringElement;
51
- private stringPrefix;
52
- private stringSuffix;
53
- private stringToRef;
54
- private cvtSetToRef;
55
- private dedupeSetRefs;
56
- private proxySetRef;
57
- private createUniqueKeys;
58
- private cvtMapToRef;
59
- private dedupeMapRefs;
60
- private proxyMapRef;
61
- private cvtRegExpToRef;
62
- private cvtDateToRef;
63
- private proxyDateRef;
64
- private cvtBigintToRef;
65
- private cvtObjToRef;
66
- private dedupeObject;
67
- private proxyObjectRef;
68
- private proxyObjectWrapperRef;
69
- /**
70
- *
71
- * @param value - The array converted to an ArrayRefElement.
72
- * @param element - the element to dedupe.
73
- * @param cacheValue - Whether to cache the value. It is false when it is a dynamic array, like object keys,
74
- * in that case, we want to dedupe the keys and values.
75
- * @returns the element to use.
76
- */
77
- private dedupeArray;
78
- /**
79
- * Convert an array to an index.
80
- * @param value - The array to convert to an index.
81
- * @param cacheValue - Whether to cache the value.
82
- * @returns the index of the array.
83
- */
84
- private arrToRef;
85
- private proxyArrayRef;
86
- private valueToRef;
87
- /**
88
- * Reset things in a way that allows for reuse.
89
- */
90
- private softReset;
91
8
  toJSON(): Flatpacked;
92
9
  static fromJSON(data: Flatpacked): FlatpackStore;
93
10
  static parse(content: string): FlatpackStore;
94
11
  stringify(): string;
95
12
  toValue(): Unpacked;
96
- _toValueProxy(): Unpacked;
97
13
  }
98
14
  export declare function toJSON<V extends Serializable>(json: V, options?: FlatpackOptions): Flatpacked;
99
15
  export declare function stringify(data: Unpacked, pretty?: boolean): string;