UNPKG

bxgateway

Version:

Package for connecting to Bloxroute's gateways

56 lines (55 loc) 1.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Filter = void 0; class Filter { constructor() { this._filter = ''; this._valid = false; } build() { if (!this._valid) throw new Error('Invalid filter'); return this._filter; } to(address, eq = true) { if (eq) { this._filter += `({to} == '${address}')`; } else { this._filter += `({to} IN ${address})`; } this._valid = true; return this; } from(address, eq = true) { if (eq) { this._filter += `({from} == '${address}')`; } else { this._filter += `({from} IN ${address})`; } this._valid = true; return this; } method(methodId, eq = true) { if (eq) { this._filter += `({method_id} == '${methodId}')`; } else { this._filter += `({method_id} IN ${methodId})`; } this._valid = true; return this; } get and() { this._filter += ` AND `; this._valid = false; return this; } get or() { this._filter += ` OR `; this._valid = false; return this; } } exports.Filter = Filter;