UNPKG

sql-formatter-plus

Version:

Formats whitespace in a SQL query to make it more readable

60 lines (47 loc) 1.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } /** * Handles placeholder replacement with given params. */ var Params = /*#__PURE__*/ function () { /** * @param {Object} params */ function Params(params) { _classCallCheck(this, 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 */ _createClass(Params, [{ key: "get", value: function get(_ref) { var key = _ref.key, value = _ref.value; if (!this.params) { return value; } if (key) { return this.params[key]; } return this.params[this.index++]; } }]); return Params; }(); exports["default"] = Params; module.exports = exports.default;