import { Transaction } from './Transaction'; export class GenericTransactions extends Array { constructor() { super(); Object.setPrototypeOf(this, Object.create(GenericTransactions.prototype)); } /** * Group GenericTransactions by recipient addresses * Result is a map that key is address and value is transaction array */ public groupByRecipients(): Map> { const result = new Map>(); this.forEach(tx => { const addresses = tx.extractRecipientAddresses(); addresses.forEach(address => { if (!result.get(address)) { result.set(address, new GenericTransactions()); } result.get(address).push(tx); }); }); return result; } } export default GenericTransactions;