UNPKG

@btc-vision/transaction

Version:

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

64 lines (63 loc) 1.4 kB
export class Map { constructor() { this._keys = []; this._values = []; } get size() { return this._keys.length; } keys() { return this._keys; } values() { return this._values; } entries() { const result = []; for (let i = 0; i < this._keys.length; i++) { result.push([this._keys[i], this._values[i]]); } return result; } set(key, value) { const index = this.indexOf(key); if (index == -1) { this._keys.push(key); this._values.push(value); } else { this._values[index] = value; } } indexOf(key) { for (let i = 0; i < this._keys.length; i++) { if (this._keys[i] == key) { return i; } } return -1; } get(key) { const index = this.indexOf(key); if (index == -1) { return undefined; } return this._values[index]; } has(key) { return this.indexOf(key) != -1; } delete(key) { const index = this.indexOf(key); if (index == -1) { return false; } this._keys.splice(index, 1); this._values.splice(index, 1); return true; } clear() { this._keys = []; this._values = []; } }