pg-query-config
Version:
Query Builder for PostgreSQL
11 lines (10 loc) • 415 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.wrap = void 0;
const isWrappable = (str) => !/[\!\@\#\$\%\^\&\*\)\(\+\=\.\<\>\{\}\[\]\:\;\'\"\|\~\`\_\-]/.test(str);
const wrapToDoubleQuote = (str) => str
.split('.')
.map((str) => str === '*' ? str : `"${str}"`)
.join('.');
const wrap = (str) => isWrappable(str) ? wrapToDoubleQuote(str) : str;
exports.wrap = wrap;