JSPM

  • Created
  • Published
  • Downloads 773136
  • Score
    100M100P100Q193350F
  • License MIT

Minifies PostgreSQL scripts.

Package Exports

  • pg-minify

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pg-minify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

pg-minify

Build Status Coverage Status

Minifies a PostgreSQL script into a single-line SQL command:

  1. Removes both /*multi-line*/ and --single-line comments
  2. Concatenates multi-line strings into single-line with \n
  3. Removes redundant line gaps: line breaks, tabs and spaces
  4. Flattens the resulting script into a single line

It also provides basic parsing and error reporting for invalid SQL.

Installing

$ npm install pg-minify

Testing

$ npm test

Testing with coverage:

$ npm run coverage

Usage

var minify = require('pg-minify');

var sql = "SELECT 1; -- comments";

minify(sql); //=> SELECT 1;

Error Handling

SQLParsingError is thrown on failed SQL parsing:

try {
    minify("SELECT '1");
} catch (error) {
    // error is minify.SQLParsingError instance
    // error.message:
    // Error parsing SQL at {line:1,col:7}: Unclosed text block.
}

License

Copyright © 2016 Vitaly Tomilov; Released under the MIT license.