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.2 to 0.4.3

12

lib/error.js

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

var errorMessages = [
{name: "unclosedMLC", message: "Unclosed multi-line comment."},
{name: "unclosedText", message: "Unclosed text block."},
{name: "unclosedQI", message: "Unclosed quoted identifier."},
{name: "multiLineQI", message: "Multi-line quoted identifiers are not supported."}
{name: 'unclosedMLC', message: 'Unclosed multi-line comment.'},
{name: 'unclosedText', message: 'Unclosed text block.'},
{name: 'unclosedQI', message: 'Unclosed quoted identifier.'},
{name: 'multiLineQI', message: 'Multi-line quoted identifiers are not supported.'}
];

@@ -29,3 +29,3 @@

this.position = position; // Error position in the text: {line, column}
this.message = "Error parsing SQL at {line:" + position.line + ",col:" + position.column + "}: " + this.error;
this.message = 'Error parsing SQL at {line:' + position.line + ',col:' + position.column + '}: ' + this.error;
}

@@ -48,3 +48,3 @@

gap + 'error: "' + this.error + '"',
gap + 'position: {line: ' + this.position.line + ", col: " + this.position.column + '}',
gap + 'position: {line: ' + this.position.line + ', col: ' + this.position.column + '}',
messageGap(level) + '}'

@@ -51,0 +51,0 @@ ];

@@ -11,12 +11,12 @@ 'use strict';

///////////////////////////////////////////
// Parses and minifies a PostgreSQL script.
////////////////////////////////////////////
// Parses and minimizes a PostgreSQL script.
function minify(sql, options) {
if (typeof sql !== 'string') {
throw new TypeError("Input SQL must be a text string.");
throw new TypeError('Input SQL must be a text string.');
}
if (options !== undefined && typeof options !== 'object') {
throw new TypeError("Parameter 'options' must be an object.");
throw new TypeError('Parameter \'options\' must be an object.');
}

@@ -40,3 +40,3 @@

if (isGap(s)) {
while (++idx < len && isGap(sql[idx]));
while (++idx < len && isGap(sql[idx])) ;
if (idx < len) {

@@ -69,8 +69,10 @@ space = true;

var closeIdx, text;
if (s === '"') {
var closeIdx = sql.indexOf('"', idx + 1);
closeIdx = sql.indexOf('"', idx + 1);
if (closeIdx < 0) {
throwError(PEC.unclosedQI);
}
var text = sql.substr(idx, closeIdx - idx + 1);
text = sql.substr(idx, closeIdx - idx + 1);
if (text.indexOf(EOL) > 0) {

@@ -90,3 +92,3 @@ throwError(PEC.multiLineQI);

if (s === '\'') {
var closeIdx = idx;
closeIdx = idx;
do {

@@ -96,3 +98,3 @@ closeIdx = sql.indexOf('\'', closeIdx + 1);

var step = closeIdx;
while (++step < len && sql[step] === '\'');
while (++step < len && sql[step] === '\'') ;
if ((step - closeIdx) % 2) {

@@ -112,3 +114,3 @@ closeIdx = step - 1;

addSpace();
var text = sql.substr(idx, closeIdx - idx + 1);
text = sql.substr(idx, closeIdx - idx + 1);
var hasLB = text.indexOf(EOL) > 0;

@@ -181,3 +183,3 @@ if (hasLB) {

idx = text.indexOf('\n', idx);
if (idx == -1) {
if (idx === -1) {
break;

@@ -204,3 +206,3 @@ }

pos = text.indexOf(eol, pos);
if (pos == -1 || index < pos + eol.length) {
if (pos === -1 || index < pos + eol.length) {
break;

@@ -207,0 +209,0 @@ }

{
"name": "pg-minify",
"version": "0.4.2",
"version": "0.4.3",
"description": "Minifies PostgreSQL scripts.",

@@ -10,3 +10,4 @@ "main": "lib/index.js",

"coverage": "istanbul cover ./node_modules/jasmine-node/bin/jasmine-node test",
"travis": "istanbul cover ./node_modules/jasmine-node/bin/jasmine-node test --captureExceptions && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"
"travis": "npm run lint && istanbul cover ./node_modules/jasmine-node/bin/jasmine-node test --captureExceptions && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"lint": "./node_modules/.bin/eslint ./lib ./test/*.js"
},

@@ -41,2 +42,3 @@ "files": [

"devDependencies": {
"eslint": "4.3",
"coveralls": "2.x",

@@ -43,0 +45,0 @@ "istanbul": "0.4",

@@ -26,15 +26,2 @@ pg-minify

## Testing
First, clone the repository and install DEV dependencies.
```
$ npm test
```
Testing with coverage:
```
$ npm run coverage
```
## Usage

@@ -59,4 +46,6 @@

#### Error Handling
The library's distribution includes [TypeScript] declarations.
## Error Handling
[SQLParsingError] is thrown on failed SQL parsing:

@@ -87,7 +76,21 @@

## Testing
First, clone the repository and install DEV dependencies.
```
$ npm test
```
Testing with coverage:
```
$ npm run coverage
```
## License
Copyright © 2016 [Vitaly Tomilov](https://github.com/vitaly-t);
Copyright © 2017 [Vitaly Tomilov](https://github.com/vitaly-t);
Released under the MIT license.
[SQLParsingError]:https://github.com/vitaly-t/pg-minify/blob/master/lib/error.js#L21
[TypeScript]:https://github.com/vitaly-t/pg-minify/tree/master/typescript
## TypeScript for pg-minify
Complete TypeScript 2.0 declarations for the [pg-minify] module.
Complete TypeScript 2.x declarations for the [pg-minify] module.

@@ -12,5 +12,5 @@ ### Inclusion

```ts
import * as minify from "pg-minify";
import * as minify from 'pg-minify';
var sql = "SELECT 1; -- comments";
var sql = 'SELECT 1; -- comments';

@@ -17,0 +17,0 @@ minify(sql); //=> SELECT 1;

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