@btc-vision/transaction 1.7.6 → 1.7.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.
@@ -1 +1 @@
1
- export declare const version = "1.7.1";
1
+ export declare const version = "1.7.7";
@@ -1,11 +1,11 @@
1
- import { Map } from './Map.js';
2
- export declare class DeterministicMap<K, V> {
1
+ import { FastMap, PropertyExtendedKey } from './FastMap.js';
2
+ export declare class DeterministicMap<K extends PropertyExtendedKey, V> {
3
3
  #private;
4
4
  private compareFn;
5
5
  private map;
6
6
  constructor(compareFn: (a: K, b: K) => number);
7
7
  get size(): number;
8
- static fromMap<K, V>(map: Map<K, V>, compareFn: (a: K, b: K) => number): DeterministicMap<K, V>;
8
+ static fromMap<K extends PropertyExtendedKey, V>(map: FastMap<K, V>, compareFn: (a: K, b: K) => number): DeterministicMap<K, V>;
9
9
  set(key: K, value: V): void;
10
10
  get(key: K): V | undefined;
11
11
  entries(): IterableIterator<[K, V]>;
@@ -0,0 +1,24 @@
1
+ export type PropertyExtendedKey = PropertyKey | bigint;
2
+ export type FastRecord<V> = {
3
+ [key: string]: V;
4
+ };
5
+ export type IndexKey = string | number;
6
+ export declare class FastMap<K extends PropertyExtendedKey, V> {
7
+ protected _keys: K[];
8
+ protected _values: FastRecord<V>;
9
+ constructor(iterable?: ReadonlyArray<readonly [K, V]> | null | FastMap<K, V>);
10
+ get size(): number;
11
+ setAll(map: FastMap<K, V>): void;
12
+ addAll(map: FastMap<K, V>): void;
13
+ keys(): IterableIterator<K>;
14
+ values(): IterableIterator<V>;
15
+ entries(): IterableIterator<[K, V]>;
16
+ set(key: K, value: V): this;
17
+ indexOf(key: K): number;
18
+ get(key: K): V | undefined;
19
+ has(key: K): boolean;
20
+ delete(key: K): boolean;
21
+ clear(): void;
22
+ forEach(callback: (value: V, key: K, map: FastMap<K, V>) => void, thisArg?: unknown): void;
23
+ [Symbol.iterator](): IterableIterator<[K, V]>;
24
+ }
@@ -75,7 +75,7 @@ export * from './metadata/tokens.js';
75
75
  export * from './transaction/browser/Web3Provider.js';
76
76
  export * from './keypair/Secp256k1PointDeriver.js';
77
77
  export * from './transaction/ContractAddress.js';
78
- export * from './deterministic/Map.js';
78
+ export * from './deterministic/FastMap.js';
79
79
  export * from './deterministic/CustomMap.js';
80
80
  declare global {
81
81
  interface Window {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ export declare class FastBigIntMap {
2
+ private items;
3
+ private keyOrder;
4
+ constructor(iterable?: ReadonlyArray<readonly [bigint, bigint]> | null | FastBigIntMap);
5
+ get size(): number;
6
+ setAll(map: FastBigIntMap): void;
7
+ addAll(map: FastBigIntMap): void;
8
+ set(key: bigint, value: bigint): this;
9
+ get(key: bigint): bigint | undefined;
10
+ has(key: bigint): boolean;
11
+ delete(key: bigint): boolean;
12
+ clear(): void;
13
+ entries(): IterableIterator<[bigint, bigint]>;
14
+ keys(): IterableIterator<bigint>;
15
+ values(): IterableIterator<bigint>;
16
+ forEach(callback: (value: bigint, key: bigint, map: FastBigIntMap) => void, thisArg?: unknown): void;
17
+ [Symbol.iterator](): IterableIterator<[bigint, bigint]>;
18
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- export declare const version = "1.7.1";
1
+ export declare const version = "1.7.7";
package/build/_version.js CHANGED
@@ -1 +1 @@
1
- export const version = '1.7.1';
1
+ export const version = '1.7.7';
@@ -1,8 +1,8 @@
1
1
  import { Address } from '../keypair/Address.js';
2
- import { Map } from './Map.js';
2
+ import { FastMap } from './FastMap.js';
3
3
  export class AddressMap {
4
4
  constructor(iterable) {
5
- this.items = new Map();
5
+ this.items = new FastMap();
6
6
  if (iterable) {
7
7
  for (const [key, value] of iterable) {
8
8
  this.set(key, value);
@@ -1,11 +1,11 @@
1
- import { Map } from './Map.js';
2
- export declare class DeterministicMap<K, V> {
1
+ import { FastMap, PropertyExtendedKey } from './FastMap.js';
2
+ export declare class DeterministicMap<K extends PropertyExtendedKey, V> {
3
3
  #private;
4
4
  private compareFn;
5
5
  private map;
6
6
  constructor(compareFn: (a: K, b: K) => number);
7
7
  get size(): number;
8
- static fromMap<K, V>(map: Map<K, V>, compareFn: (a: K, b: K) => number): DeterministicMap<K, V>;
8
+ static fromMap<K extends PropertyExtendedKey, V>(map: FastMap<K, V>, compareFn: (a: K, b: K) => number): DeterministicMap<K, V>;
9
9
  set(key: K, value: V): void;
10
10
  get(key: K): V | undefined;
11
11
  entries(): IterableIterator<[K, V]>;
@@ -10,12 +10,12 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
12
  var _DeterministicMap_keys;
13
- import { Map } from './Map.js';
13
+ import { FastMap } from './FastMap.js';
14
14
  export class DeterministicMap {
15
15
  constructor(compareFn) {
16
16
  this.compareFn = compareFn;
17
17
  _DeterministicMap_keys.set(this, void 0);
18
- this.map = new Map();
18
+ this.map = new FastMap();
19
19
  __classPrivateFieldSet(this, _DeterministicMap_keys, [], "f");
20
20
  }
21
21
  get size() {
@@ -0,0 +1,24 @@
1
+ export type PropertyExtendedKey = PropertyKey | bigint;
2
+ export type FastRecord<V> = {
3
+ [key: string]: V;
4
+ };
5
+ export type IndexKey = string | number;
6
+ export declare class FastMap<K extends PropertyExtendedKey, V> {
7
+ protected _keys: K[];
8
+ protected _values: FastRecord<V>;
9
+ constructor(iterable?: ReadonlyArray<readonly [K, V]> | null | FastMap<K, V>);
10
+ get size(): number;
11
+ setAll(map: FastMap<K, V>): void;
12
+ addAll(map: FastMap<K, V>): void;
13
+ keys(): IterableIterator<K>;
14
+ values(): IterableIterator<V>;
15
+ entries(): IterableIterator<[K, V]>;
16
+ set(key: K, value: V): this;
17
+ indexOf(key: K): number;
18
+ get(key: K): V | undefined;
19
+ has(key: K): boolean;
20
+ delete(key: K): boolean;
21
+ clear(): void;
22
+ forEach(callback: (value: V, key: K, map: FastMap<K, V>) => void, thisArg?: unknown): void;
23
+ [Symbol.iterator](): IterableIterator<[K, V]>;
24
+ }
@@ -1,8 +1,8 @@
1
- export class Map {
1
+ export class FastMap {
2
2
  constructor(iterable) {
3
3
  this._keys = [];
4
4
  this._values = {};
5
- if (iterable instanceof Map) {
5
+ if (iterable instanceof FastMap) {
6
6
  this.setAll(iterable);
7
7
  }
8
8
  else {
@@ -17,9 +17,8 @@ export class Map {
17
17
  return this._keys.length;
18
18
  }
19
19
  setAll(map) {
20
- for (const [key, value] of map) {
21
- this.set(key, value);
22
- }
20
+ this._keys = [...map._keys];
21
+ this._values = { ...map._values };
23
22
  }
24
23
  addAll(map) {
25
24
  for (const [key, value] of map.entries()) {
@@ -31,64 +30,59 @@ export class Map {
31
30
  }
32
31
  *values() {
33
32
  for (const key of this._keys) {
34
- yield this._values[this.keyToString(key)];
33
+ yield this._values[key];
35
34
  }
36
35
  }
37
36
  *entries() {
38
37
  for (const key of this._keys) {
39
- yield [key, this._values[this.keyToString(key)]];
38
+ yield [key, this._values[key]];
40
39
  }
41
40
  }
42
41
  set(key, value) {
43
- const keyStr = this.keyToString(key);
44
42
  if (!this.has(key)) {
45
43
  this._keys.push(key);
46
44
  }
47
- this._values[keyStr] = value;
45
+ this._values[key] = value;
46
+ return this;
48
47
  }
49
48
  indexOf(key) {
49
+ if (!this.has(key)) {
50
+ return -1;
51
+ }
50
52
  for (let i = 0; i < this._keys.length; i++) {
51
53
  if (this._keys[i] === key) {
52
54
  return i;
53
55
  }
54
56
  }
55
- return -1;
57
+ throw new Error('Key not found, this should not happen.');
56
58
  }
57
59
  get(key) {
58
- return this._values[this.keyToString(key)];
60
+ return this._values[key];
59
61
  }
60
62
  has(key) {
61
- return Object.prototype.hasOwnProperty.call(this._values, this.keyToString(key));
63
+ return Object.prototype.hasOwnProperty.call(this._values, key);
62
64
  }
63
65
  delete(key) {
64
- const index = this.indexOf(key);
65
- if (index === -1) {
66
+ if (!this.has(key)) {
66
67
  return false;
67
68
  }
68
- const keyStr = this.keyToString(key);
69
+ const index = this.indexOf(key);
69
70
  this._keys.splice(index, 1);
70
- delete this._values[keyStr];
71
+ delete this._values[key];
71
72
  return true;
72
73
  }
73
74
  clear() {
74
75
  this._keys = [];
75
76
  this._values = {};
76
77
  }
77
- *[Symbol.iterator]() {
78
+ forEach(callback, thisArg) {
78
79
  for (const key of this._keys) {
79
- yield [key, this._values[this.keyToString(key)]];
80
+ callback.call(thisArg, this._values[key], key, this);
80
81
  }
81
82
  }
82
- keyToString(key) {
83
- if (typeof key === 'string') {
84
- return key;
85
- }
86
- if (typeof key === 'number' || typeof key === 'boolean') {
87
- return String(key);
88
- }
89
- if (typeof key === 'object' && key !== null) {
90
- return JSON.stringify(key);
83
+ *[Symbol.iterator]() {
84
+ for (const key of this._keys) {
85
+ yield [key, this._values[key]];
91
86
  }
92
- return String(key);
93
87
  }
94
88
  }
package/build/opnet.d.ts CHANGED
@@ -75,7 +75,7 @@ export * from './metadata/tokens.js';
75
75
  export * from './transaction/browser/Web3Provider.js';
76
76
  export * from './keypair/Secp256k1PointDeriver.js';
77
77
  export * from './transaction/ContractAddress.js';
78
- export * from './deterministic/Map.js';
78
+ export * from './deterministic/FastMap.js';
79
79
  export * from './deterministic/CustomMap.js';
80
80
  declare global {
81
81
  interface Window {
package/build/opnet.js CHANGED
@@ -74,5 +74,5 @@ export * from './metadata/tokens.js';
74
74
  export * from './transaction/browser/Web3Provider.js';
75
75
  export * from './keypair/Secp256k1PointDeriver.js';
76
76
  export * from './transaction/ContractAddress.js';
77
- export * from './deterministic/Map.js';
77
+ export * from './deterministic/FastMap.js';
78
78
  export * from './deterministic/CustomMap.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@btc-vision/transaction",
3
3
  "type": "module",
4
- "version": "1.7.6",
4
+ "version": "1.7.7",
5
5
  "author": "BlobMaster41",
6
6
  "description": "OPNet transaction library allows you to create and sign transactions for the OPNet network.",
7
7
  "engines": {
package/src/_version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '1.7.1';
1
+ export const version = '1.7.7';
@@ -1,11 +1,11 @@
1
1
  import { Address } from '../keypair/Address.js';
2
- import { Map } from './Map.js';
2
+ import { FastMap } from './FastMap.js';
3
3
 
4
4
  export class AddressMap<V> {
5
- private items: Map<bigint, V>;
5
+ private items: FastMap<bigint, V>;
6
6
 
7
7
  constructor(iterable?: ReadonlyArray<readonly [Address, V]> | null) {
8
- this.items = new Map();
8
+ this.items = new FastMap();
9
9
 
10
10
  if (iterable) {
11
11
  for (const [key, value] of iterable) {
@@ -1,11 +1,11 @@
1
- import { Map } from './Map.js';
1
+ import { FastMap, PropertyExtendedKey } from './FastMap.js';
2
2
 
3
- export class DeterministicMap<K, V> {
4
- private map: Map<K, V>;
3
+ export class DeterministicMap<K extends PropertyExtendedKey, V> {
4
+ private map: FastMap<K, V>;
5
5
  #keys: K[];
6
6
 
7
7
  constructor(private compareFn: (a: K, b: K) => number) {
8
- this.map = new Map<K, V>();
8
+ this.map = new FastMap<K, V>();
9
9
  this.#keys = [];
10
10
  }
11
11
 
@@ -13,8 +13,8 @@ export class DeterministicMap<K, V> {
13
13
  return this.map.size;
14
14
  }
15
15
 
16
- public static fromMap<K, V>(
17
- map: Map<K, V>,
16
+ public static fromMap<K extends PropertyExtendedKey, V>(
17
+ map: FastMap<K, V>,
18
18
  compareFn: (a: K, b: K) => number,
19
19
  ): DeterministicMap<K, V> {
20
20
  const deterministicMap = new DeterministicMap<K, V>(compareFn);
@@ -29,6 +29,7 @@ export class DeterministicMap<K, V> {
29
29
  // Binary search for insertion position
30
30
  let left = 0,
31
31
  right = this.#keys.length;
32
+
32
33
  while (left < right) {
33
34
  const mid = Math.floor((left + right) / 2);
34
35
  if (this.compareFn(this.#keys[mid], key) < 0) {
@@ -39,6 +40,7 @@ export class DeterministicMap<K, V> {
39
40
  }
40
41
  this.#keys.splice(left, 0, key);
41
42
  }
43
+
42
44
  this.map.set(key, value);
43
45
  }
44
46
 
@@ -78,6 +80,7 @@ export class DeterministicMap<K, V> {
78
80
  // Binary search to find the key's index
79
81
  let left = 0,
80
82
  right = this.#keys.length - 1;
83
+
81
84
  while (left <= right) {
82
85
  const mid = Math.floor((left + right) / 2);
83
86
  const cmp = this.compareFn(this.#keys[mid], key);
@@ -1,9 +1,21 @@
1
- export class Map<K, V> {
1
+ export type PropertyExtendedKey = PropertyKey | bigint;
2
+
3
+ /**
4
+ * Like Record, but supports bigint keys (which JS auto-converts to strings).
5
+ * Reflects actual JavaScript behavior where obj[123n] becomes obj["123"].
6
+ */
7
+ export type FastRecord<V> = {
8
+ [key: string]: V;
9
+ };
10
+
11
+ export type IndexKey = string | number;
12
+
13
+ export class FastMap<K extends PropertyExtendedKey, V> {
2
14
  protected _keys: K[] = [];
3
- protected _values: Record<string, V> = {};
15
+ protected _values: FastRecord<V> = {};
4
16
 
5
- constructor(iterable?: ReadonlyArray<readonly [K, V]> | null | Map<K, V>) {
6
- if (iterable instanceof Map) {
17
+ constructor(iterable?: ReadonlyArray<readonly [K, V]> | null | FastMap<K, V>) {
18
+ if (iterable instanceof FastMap) {
7
19
  this.setAll(iterable);
8
20
  } else {
9
21
  if (iterable) {
@@ -18,13 +30,12 @@ export class Map<K, V> {
18
30
  return this._keys.length;
19
31
  }
20
32
 
21
- public setAll(map: Map<K, V>): void {
22
- for (const [key, value] of map) {
23
- this.set(key, value);
24
- }
33
+ public setAll(map: FastMap<K, V>): void {
34
+ this._keys = [...map._keys];
35
+ this._values = { ...map._values };
25
36
  }
26
37
 
27
- public addAll(map: Map<K, V>): void {
38
+ public addAll(map: FastMap<K, V>): void {
28
39
  for (const [key, value] of map.entries()) {
29
40
  this.set(key, value);
30
41
  }
@@ -36,52 +47,58 @@ export class Map<K, V> {
36
47
 
37
48
  public *values(): IterableIterator<V> {
38
49
  for (const key of this._keys) {
39
- yield this._values[this.keyToString(key)];
50
+ yield this._values[key as IndexKey];
40
51
  }
41
52
  }
42
53
 
43
54
  public *entries(): IterableIterator<[K, V]> {
44
55
  for (const key of this._keys) {
45
- yield [key, this._values[this.keyToString(key)]];
56
+ yield [key, this._values[key as IndexKey]];
46
57
  }
47
58
  }
48
59
 
49
- public set(key: K, value: V): void {
50
- const keyStr = this.keyToString(key);
60
+ public set(key: K, value: V): this {
51
61
  if (!this.has(key)) {
52
62
  this._keys.push(key);
53
63
  }
54
64
 
55
- this._values[keyStr] = value;
65
+ this._values[key as IndexKey] = value;
66
+
67
+ return this;
56
68
  }
57
69
 
58
70
  public indexOf(key: K): number {
71
+ if (!this.has(key)) {
72
+ return -1;
73
+ }
74
+
59
75
  for (let i = 0; i < this._keys.length; i++) {
60
76
  if (this._keys[i] === key) {
61
77
  return i;
62
78
  }
63
79
  }
64
- return -1;
80
+
81
+ throw new Error('Key not found, this should not happen.');
65
82
  }
66
83
 
67
84
  public get(key: K): V | undefined {
68
- return this._values[this.keyToString(key)];
85
+ return this._values[key as IndexKey];
69
86
  }
70
87
 
71
88
  public has(key: K): boolean {
72
- return Object.prototype.hasOwnProperty.call(this._values, this.keyToString(key));
89
+ return Object.prototype.hasOwnProperty.call(this._values, key as IndexKey);
73
90
  }
74
91
 
75
92
  public delete(key: K): boolean {
76
- const index = this.indexOf(key);
77
- if (index === -1) {
93
+ if (!this.has(key)) {
78
94
  return false;
79
95
  }
80
96
 
81
- const keyStr = this.keyToString(key);
97
+ const index = this.indexOf(key);
82
98
  this._keys.splice(index, 1);
99
+
83
100
  // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
84
- delete this._values[keyStr];
101
+ delete this._values[key as IndexKey];
85
102
  return true;
86
103
  }
87
104
 
@@ -90,22 +107,18 @@ export class Map<K, V> {
90
107
  this._values = {};
91
108
  }
92
109
 
93
- *[Symbol.iterator](): IterableIterator<[K, V]> {
110
+ public forEach(
111
+ callback: (value: V, key: K, map: FastMap<K, V>) => void,
112
+ thisArg?: unknown,
113
+ ): void {
94
114
  for (const key of this._keys) {
95
- yield [key, this._values[this.keyToString(key)]];
115
+ callback.call(thisArg, this._values[key as IndexKey], key, this);
96
116
  }
97
117
  }
98
118
 
99
- private keyToString(key: K): string {
100
- if (typeof key === 'string') {
101
- return key;
102
- }
103
- if (typeof key === 'number' || typeof key === 'boolean') {
104
- return String(key);
105
- }
106
- if (typeof key === 'object' && key !== null) {
107
- return JSON.stringify(key);
119
+ *[Symbol.iterator](): IterableIterator<[K, V]> {
120
+ for (const key of this._keys) {
121
+ yield [key, this._values[key as IndexKey]];
108
122
  }
109
- return String(key);
110
123
  }
111
124
  }
package/src/opnet.ts CHANGED
@@ -125,7 +125,7 @@ export * from './transaction/browser/Web3Provider.js';
125
125
  export * from './keypair/Secp256k1PointDeriver.js';
126
126
  export * from './transaction/ContractAddress.js';
127
127
 
128
- export * from './deterministic/Map.js';
128
+ export * from './deterministic/FastMap.js';
129
129
  export * from './deterministic/CustomMap.js';
130
130
 
131
131
  declare global {
@@ -0,0 +1,143 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { FastBigIntMap } from './old/FastBigIntMap.js';
3
+ import { FastMap } from '../src';
4
+
5
+ describe('setAll bug', () => {
6
+ describe('FastBigIntMap (original - correct behavior)', () => {
7
+ it('should replace all entries, not merge', () => {
8
+ const map1 = new FastBigIntMap([
9
+ [1n, 100n],
10
+ [2n, 200n],
11
+ ]);
12
+
13
+ const map2 = new FastBigIntMap([
14
+ [3n, 300n],
15
+ [4n, 400n],
16
+ ]);
17
+
18
+ // setAll should REPLACE, not merge
19
+ map2.setAll(map1);
20
+
21
+ // Should have entries from map1 only
22
+ expect(map2.size).toBe(2);
23
+ expect(map2.get(1n)).toBe(100n);
24
+ expect(map2.get(2n)).toBe(200n);
25
+
26
+ // Old entries should be GONE
27
+ expect(map2.has(3n)).toBe(false);
28
+ expect(map2.has(4n)).toBe(false);
29
+ expect(map2.get(3n)).toBeUndefined();
30
+ expect(map2.get(4n)).toBeUndefined();
31
+ });
32
+ });
33
+
34
+ describe('FastMap (replacement - should match original behavior)', () => {
35
+ it('should replace all entries, not merge', () => {
36
+ const map1 = new FastMap<bigint, bigint>([
37
+ [1n, 100n],
38
+ [2n, 200n],
39
+ ]);
40
+
41
+ const map2 = new FastMap<bigint, bigint>([
42
+ [3n, 300n],
43
+ [4n, 400n],
44
+ ]);
45
+
46
+ // setAll should REPLACE, not merge
47
+ map2.setAll(map1);
48
+
49
+ // Should have entries from map1 only
50
+ expect(map2.size).toBe(2);
51
+ expect(map2.get(1n)).toBe(100n);
52
+ expect(map2.get(2n)).toBe(200n);
53
+
54
+ // Old entries should be GONE
55
+ expect(map2.has(3n)).toBe(false);
56
+ expect(map2.has(4n)).toBe(false);
57
+ expect(map2.get(3n)).toBeUndefined();
58
+ expect(map2.get(4n)).toBeUndefined();
59
+ });
60
+
61
+ it('should not leak old keys in iteration', () => {
62
+ const map1 = new FastMap<bigint, bigint>([[1n, 100n]]);
63
+
64
+ const map2 = new FastMap<bigint, bigint>([
65
+ [2n, 200n],
66
+ [3n, 300n],
67
+ ]);
68
+
69
+ map2.setAll(map1);
70
+
71
+ const keys = [...map2.keys()];
72
+ const values = [...map2.values()];
73
+ const entries = [...map2.entries()];
74
+
75
+ expect(keys).toEqual([1n]);
76
+ expect(values).toEqual([100n]);
77
+ expect(entries).toEqual([[1n, 100n]]);
78
+ });
79
+
80
+ it('should handle overlapping keys correctly', () => {
81
+ const map1 = new FastMap<bigint, bigint>([
82
+ [1n, 100n],
83
+ [2n, 200n],
84
+ ]);
85
+
86
+ const map2 = new FastMap<bigint, bigint>([
87
+ [2n, 999n], // overlapping key
88
+ [3n, 300n],
89
+ ]);
90
+
91
+ map2.setAll(map1);
92
+
93
+ // Should have map1's values, including overwriting the overlapping key
94
+ expect(map2.size).toBe(2);
95
+ expect(map2.get(1n)).toBe(100n);
96
+ expect(map2.get(2n)).toBe(200n); // map1's value, not 999n
97
+
98
+ // 3n should be gone
99
+ expect(map2.has(3n)).toBe(false);
100
+ });
101
+ });
102
+
103
+ describe('behavior parity', () => {
104
+ it('FastMap.setAll should behave identically to FastBigIntMap.setAll', () => {
105
+ // Setup identical scenarios
106
+ const oldMap1 = new FastBigIntMap([
107
+ [1n, 10n],
108
+ [2n, 20n],
109
+ ]);
110
+ const oldMap2 = new FastBigIntMap([
111
+ [3n, 30n],
112
+ [4n, 40n],
113
+ [5n, 50n],
114
+ ]);
115
+
116
+ const newMap1 = new FastMap<bigint, bigint>([
117
+ [1n, 10n],
118
+ [2n, 20n],
119
+ ]);
120
+ const newMap2 = new FastMap<bigint, bigint>([
121
+ [3n, 30n],
122
+ [4n, 40n],
123
+ [5n, 50n],
124
+ ]);
125
+
126
+ // Perform setAll on both
127
+ oldMap2.setAll(oldMap1);
128
+ newMap2.setAll(newMap1);
129
+
130
+ // Compare sizes
131
+ expect(newMap2.size).toBe(oldMap2.size);
132
+
133
+ // Compare keys
134
+ expect([...newMap2.keys()]).toEqual([...oldMap2.keys()]);
135
+
136
+ // Compare values
137
+ expect([...newMap2.values()]).toEqual([...oldMap2.values()]);
138
+
139
+ // Compare entries
140
+ expect([...newMap2.entries()]).toEqual([...oldMap2.entries()]);
141
+ });
142
+ });
143
+ });