UNPKG

@btc-vision/transaction

Version:

OPNet transaction library allows you to create and sign transactions for the OPNet network.

68 lines 1.74 kB
import { Address } from '../keypair/Address.js'; import { FastMap } from './FastMap.js'; export class AddressMap { items; constructor(iterable) { this.items = new FastMap(); if (iterable) { for (const [key, value] of iterable) { this.set(key, value); } } } get size() { return this.items.size; } set(key, value) { const keyBigInt = key.toBigInt(); this.items.set(keyBigInt, value); return this; } get(key) { return this.items.get(key.toBigInt()); } has(key) { return this.items.has(key.toBigInt()); } delete(key) { const keyBigInt = key.toBigInt(); return this.items.delete(keyBigInt); } clear() { this.items.clear(); } [Symbol.dispose]() { this.clear(); } indexOf(address) { return this.items.indexOf(address.toBigInt()); } /** * WARNING, THIS RETURN NEW COPY OF THE KEYS */ *entries() { for (const [keyBigInt, value] of this.items.entries()) { yield [Address.fromBigInt(keyBigInt), value]; } } *keys() { for (const keyBigInt of this.items.keys()) { yield Address.fromBigInt(keyBigInt); } } *values() { for (const value of this.items.values()) { yield value; } } forEach(callback, thisArg) { for (const [keyBigInt, value] of this.items.entries()) { const key = Address.fromBigInt(keyBigInt); callback.call(thisArg, value, key, this); } } *[Symbol.iterator]() { yield* this.entries(); } } //# sourceMappingURL=AddressMap.js.map