@btc-vision/transaction 1.7.5 → 1.7.6

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,7 +1,10 @@
1
1
  export declare class Map<K, V> {
2
2
  protected _keys: K[];
3
3
  protected _values: Record<string, V>;
4
+ constructor(iterable?: ReadonlyArray<readonly [K, V]> | null | Map<K, V>);
4
5
  get size(): number;
6
+ setAll(map: Map<K, V>): void;
7
+ addAll(map: Map<K, V>): void;
5
8
  keys(): IterableIterator<K>;
6
9
  values(): IterableIterator<V>;
7
10
  entries(): IterableIterator<[K, V]>;
@@ -1,7 +1,10 @@
1
1
  export declare class Map<K, V> {
2
2
  protected _keys: K[];
3
3
  protected _values: Record<string, V>;
4
+ constructor(iterable?: ReadonlyArray<readonly [K, V]> | null | Map<K, V>);
4
5
  get size(): number;
6
+ setAll(map: Map<K, V>): void;
7
+ addAll(map: Map<K, V>): void;
5
8
  keys(): IterableIterator<K>;
6
9
  values(): IterableIterator<V>;
7
10
  entries(): IterableIterator<[K, V]>;
@@ -1,11 +1,31 @@
1
1
  export class Map {
2
- constructor() {
2
+ constructor(iterable) {
3
3
  this._keys = [];
4
4
  this._values = {};
5
+ if (iterable instanceof Map) {
6
+ this.setAll(iterable);
7
+ }
8
+ else {
9
+ if (iterable) {
10
+ for (const [key, value] of iterable) {
11
+ this.set(key, value);
12
+ }
13
+ }
14
+ }
5
15
  }
6
16
  get size() {
7
17
  return this._keys.length;
8
18
  }
19
+ setAll(map) {
20
+ for (const [key, value] of map) {
21
+ this.set(key, value);
22
+ }
23
+ }
24
+ addAll(map) {
25
+ for (const [key, value] of map.entries()) {
26
+ this.set(key, value);
27
+ }
28
+ }
9
29
  *keys() {
10
30
  yield* this._keys;
11
31
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@btc-vision/transaction",
3
3
  "type": "module",
4
- "version": "1.7.5",
4
+ "version": "1.7.6",
5
5
  "author": "BlobMaster41",
6
6
  "description": "OPNet transaction library allows you to create and sign transactions for the OPNet network.",
7
7
  "engines": {
@@ -2,10 +2,34 @@ export class Map<K, V> {
2
2
  protected _keys: K[] = [];
3
3
  protected _values: Record<string, V> = {};
4
4
 
5
+ constructor(iterable?: ReadonlyArray<readonly [K, V]> | null | Map<K, V>) {
6
+ if (iterable instanceof Map) {
7
+ this.setAll(iterable);
8
+ } else {
9
+ if (iterable) {
10
+ for (const [key, value] of iterable) {
11
+ this.set(key, value);
12
+ }
13
+ }
14
+ }
15
+ }
16
+
5
17
  public get size(): number {
6
18
  return this._keys.length;
7
19
  }
8
20
 
21
+ public setAll(map: Map<K, V>): void {
22
+ for (const [key, value] of map) {
23
+ this.set(key, value);
24
+ }
25
+ }
26
+
27
+ public addAll(map: Map<K, V>): void {
28
+ for (const [key, value] of map.entries()) {
29
+ this.set(key, value);
30
+ }
31
+ }
32
+
9
33
  public *keys(): IterableIterator<K> {
10
34
  yield* this._keys;
11
35
  }