UNPKG

@hokaccha/sql-formatter

Version:

Format whitespace in a SQL query to make it more readable

35 lines 954 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * Handles placeholder replacement with given params. */ class Params { /** * @param {Object} params */ constructor(params) { this.params = params; this.index = 0; } /** * Returns param value that matches given placeholder with param key. * @param {Object} token * @param {String} token.key Placeholder key * @param {String} token.value Placeholder value * @return {String} param or token.value when params are missing */ get(token) { if (!this.params) { return token.value; } if (Array.isArray(this.params)) { return this.params[this.index++]; } if (token.key) { return this.params[token.key]; } throw new Error("Invalid params"); } } exports.default = Params; //# sourceMappingURL=Params.js.map