@btc-vision/transaction 1.7.2 → 1.7.4

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,76 @@
1
+ export class Map<K, V> {
2
+ protected _keys: K[] = [];
3
+ protected _values: V[] = [];
4
+
5
+ public get size(): number {
6
+ return this._keys.length;
7
+ }
8
+
9
+ public *keys(): IterableIterator<K> {
10
+ yield* this._keys;
11
+ }
12
+
13
+ public *values(): IterableIterator<V> {
14
+ yield* this._values;
15
+ }
16
+
17
+ public *entries(): IterableIterator<[K, V]> {
18
+ for (let i: number = 0; i < this._keys.length; i++) {
19
+ yield [this._keys[i], this._values[i]];
20
+ }
21
+ }
22
+
23
+ public set(key: K, value: V): void {
24
+ const index: number = this.indexOf(key);
25
+ if (index == -1) {
26
+ this._keys.push(key);
27
+ this._values.push(value);
28
+ } else {
29
+ this._values[index] = value;
30
+ }
31
+ }
32
+
33
+ public indexOf(key: K): number {
34
+ for (let i: number = 0; i < this._keys.length; i++) {
35
+ if (this._keys[i] == key) {
36
+ return i;
37
+ }
38
+ }
39
+
40
+ return -1;
41
+ }
42
+
43
+ public get(key: K): V | undefined {
44
+ const index: number = this.indexOf(key);
45
+ if (index == -1) {
46
+ return undefined;
47
+ }
48
+ return this._values[index];
49
+ }
50
+
51
+ public has(key: K): boolean {
52
+ return this.indexOf(key) != -1;
53
+ }
54
+
55
+ public delete(key: K): boolean {
56
+ const index: number = this.indexOf(key);
57
+ if (index == -1) {
58
+ return false;
59
+ }
60
+
61
+ this._keys.splice(index, 1);
62
+ this._values.splice(index, 1);
63
+ return true;
64
+ }
65
+
66
+ public clear(): void {
67
+ this._keys = [];
68
+ this._values = [];
69
+ }
70
+
71
+ *[Symbol.iterator](): IterableIterator<[K, V]> {
72
+ for (let i: number = 0; i < this._keys.length; i++) {
73
+ yield [this._keys[i], this._values[i]];
74
+ }
75
+ }
76
+ }
package/src/opnet.ts CHANGED
@@ -125,6 +125,8 @@ 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';
129
+
128
130
  declare global {
129
131
  interface Window {
130
132
  unisat?: Unisat;