Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pg-minify

Package Overview
Dependencies
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pg-minify - npm Package Compare versions

Comparing version 0.4.4 to 0.4.5

lib/utils.js

9

lib/error.js
'use strict';
var EOL = require('os').EOL;
var utils = require('./utils');

@@ -41,3 +42,3 @@ var parsingErrorCode = {

level = level > 0 ? parseInt(level) : 0;
var gap = messageGap(level + 1);
var gap = utils.messageGap(level + 1);
var lines = [

@@ -48,3 +49,3 @@ 'SQLParsingError {',

gap + 'position: {line: ' + this.position.line + ', col: ' + this.position.column + '}',
messageGap(level) + '}'
utils.messageGap(level) + '}'
];

@@ -54,6 +55,2 @@ return lines.join(EOL);

function messageGap(level) {
return Array(1 + level * 4).join(' ');
}
SQLParsingError.prototype.inspect = function () {

@@ -60,0 +57,0 @@ return this.toString();

@@ -6,5 +6,5 @@ 'use strict';

parser.minify.SQLParsingError = error.SQLParsingError;
parser.minify.parsingErrorCode = error.parsingErrorCode;
parser.SQLParsingError = error.SQLParsingError;
parser.parsingErrorCode = error.parsingErrorCode;
module.exports = parser.minify;
module.exports = parser;
'use strict';
var os = require('os');
var errorLib = require('./error');
var utils = require('./utils');

@@ -30,3 +30,3 @@ var PEC = errorLib.parsingErrorCode;

len = sql.length, // sql length
EOL = getEOL(sql), // end-of-line
EOL = utils.getEOL(sql), // end-of-line
space = false, // add a space on the next step

@@ -167,3 +167,3 @@ compress = options && options.compress; // option 'compress'

function throwError(code) {
var position = getIndexPos(sql, idx, EOL);
var position = utils.getIndexPos(sql, idx, EOL);
throw new errorLib.SQLParsingError(code, position);

@@ -173,43 +173,2 @@ }

//////////////////////////////////////
// Returns the End-Of-Line from text.
function getEOL(text) {
var idx = 0, unix = 0, windows = 0;
while (idx < text.length) {
idx = text.indexOf('\n', idx);
if (idx === -1) {
break;
}
if (idx > 0 && text[idx - 1] === '\r') {
windows++;
} else {
unix++;
}
idx++;
}
if (unix === windows) {
return os.EOL;
}
return unix > windows ? '\n' : '\r\n';
}
///////////////////////////////////////////////////////
// Returns {line, column} of an index within the text.
function getIndexPos(text, index, eol) {
var lineIdx = 0, colIdx = index, pos = 0;
do {
pos = text.indexOf(eol, pos);
if (pos === -1 || index < pos + eol.length) {
break;
}
lineIdx++;
pos += eol.length;
colIdx = index - pos;
} while (pos < index);
return {
line: lineIdx + 1,
column: colIdx + 1
};
}
////////////////////////////////////

@@ -221,8 +180,2 @@ // Identifies a gap / empty symbol.

module.exports = {
minify: minify,
// these are exported only for testing:
getEOL: getEOL,
getIndexPos: getIndexPos
};
module.exports = minify;
{
"name": "pg-minify",
"version": "0.4.4",
"version": "0.4.5",
"description": "Minifies PostgreSQL scripts.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

pg-minify
=========
Minifies PostgreSQL scripts.

@@ -10,3 +11,3 @@

Features:
**Features:**

@@ -21,2 +22,9 @@ * Removes both `/*multi-line*/` and `--single-line` comments

This library is originally for PostgreSQL, though it works for MS-SQL and MySQL also.
**Limitations:**
* Multi-line quoted identifiers are not supported, throwing an error when encountered.
* Nested multi-line comments are not supported - `/* /* nested */ */`.
## Installing

@@ -23,0 +31,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc