Comparing version 1.0.0 to 1.1.0
@@ -19,6 +19,2 @@ 'use strict'; | ||
if (options !== undefined && typeof options !== 'object') { | ||
throw new TypeError('Parameter \'options\' must be an object.'); | ||
} | ||
if (!sql.length) { | ||
@@ -28,2 +24,4 @@ return ''; | ||
options = options || {}; | ||
let idx = 0, // current index | ||
@@ -34,4 +32,3 @@ result = '', // resulting sql | ||
const len = sql.length, // sql length | ||
EOL = utils.getEOL(sql), // end-of-line | ||
compress = options && options.compress; // option 'compress' | ||
EOL = utils.getEOL(sql); // end-of-line | ||
@@ -91,3 +88,3 @@ do { | ||
} | ||
if (compress) { | ||
if (options.compress) { | ||
space = false; | ||
@@ -107,9 +104,13 @@ } | ||
if (closeIdx > 0) { | ||
let step = closeIdx; | ||
while (++step < len && sql[step] === '\'') ; | ||
if ((step - closeIdx) % 2) { | ||
closeIdx = step - 1; | ||
break; | ||
let i = closeIdx; | ||
while (sql[--i] === '\\') ; | ||
if ((closeIdx - i) % 2) { | ||
let step = closeIdx; | ||
while (++step < len && sql[step] === '\'') ; | ||
if ((step - closeIdx) % 2) { | ||
closeIdx = step - 1; | ||
break; | ||
} | ||
closeIdx = step === len ? -1 : step; | ||
} | ||
closeIdx = step === len ? -1 : step; | ||
} | ||
@@ -120,3 +121,3 @@ } while (closeIdx > 0); | ||
} | ||
if (compress) { | ||
if (options.compress) { | ||
space = false; | ||
@@ -152,3 +153,3 @@ } | ||
if (compress && compressors.indexOf(s) >= 0) { | ||
if (options.compress && compressors.indexOf(s) >= 0) { | ||
space = false; | ||
@@ -166,3 +167,3 @@ skipGaps(); | ||
function skipGaps() { | ||
if (compress) { | ||
if (options.compress) { | ||
while (idx < len - 1 && isGap(sql[idx + 1])) { | ||
@@ -169,0 +170,0 @@ idx++; |
{ | ||
"name": "pg-minify", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Minifies PostgreSQL scripts.", | ||
@@ -50,4 +50,4 @@ "main": "lib/index.js", | ||
"jasmine-node": "1.16.2", | ||
"typescript": "3.4.3" | ||
"typescript": "3.4.5" | ||
} | ||
} |
@@ -22,3 +22,3 @@ pg-minify | ||
This library is originally for PostgreSQL, though it works for MS-SQL and MySQL also. | ||
This library is originally for PostgreSQL, though it works for most of MS-SQL and MySQL. | ||
@@ -25,0 +25,0 @@ **Limitations:** |
//////////////////////////////////////// | ||
// For pg-minify v1.0.0 or later. | ||
// For pg-minify v1.1.0 or later. | ||
//////////////////////////////////////// | ||
@@ -4,0 +4,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14840
300