Skip to content

Commit 414fac6

Browse files
committed
Apply prettier to code, change lint rules
1 parent 1cdad4d commit 414fac6

13 files changed

+1699
-1937
lines changed

.eslintrc

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
{
2-
"extends": "standard",
3-
"env": {
4-
"mocha": true
5-
},
2+
"extends": "eslint:recommended",
3+
"plugins": ["prettier"],
64
"rules": {
5+
"prettier/prettier": "error",
76
"no-new-func": "off"
7+
},
8+
"env": {
9+
"es6": true,
10+
"node": true,
11+
"mocha": true
812
}
913
}

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ language: node_js
22
dist: trusty
33
sudo: false
44
node_js:
5-
- "4.2"
6-
- "6"
75
- "8"
6+
- "10"
7+
- "12"
88
env:
99
- PGUSER=postgres
1010
services:

Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
.PHONY: publish-patch test
2-
1+
.PHONY: test
32
test:
43
npm test
54

5+
.PHONY: patch
66
patch: test
77
npm version patch -m "Bump version"
88
git push origin master --tags
99
npm publish
1010

11+
.PHONY: minor
1112
minor: test
1213
npm version minor -m "Bump version"
1314
git push origin master --tags

index.js

+40-31
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const util = require('util')
66

77
var nextUniqueID = 1 // concept borrowed from org.postgresql.core.v3.QueryExecutorImpl
88

9-
function Cursor (text, values, config) {
9+
function Cursor(text, values, config) {
1010
EventEmitter.call(this)
1111

1212
this._conf = config || {}
@@ -23,25 +23,34 @@ function Cursor (text, values, config) {
2323

2424
util.inherits(Cursor, EventEmitter)
2525

26-
Cursor.prototype.submit = function (connection) {
26+
Cursor.prototype.submit = function(connection) {
2727
this.connection = connection
28-
this._portal = 'C_' + (nextUniqueID++)
28+
this._portal = 'C_' + nextUniqueID++
2929

3030
const con = connection
3131

32-
con.parse({
33-
text: this.text
34-
}, true)
35-
36-
con.bind({
37-
portal: this._portal,
38-
values: this.values
39-
}, true)
40-
41-
con.describe({
42-
type: 'P',
43-
name: this._portal // AWS Redshift requires a portal name
44-
}, true)
32+
con.parse(
33+
{
34+
text: this.text,
35+
},
36+
true
37+
)
38+
39+
con.bind(
40+
{
41+
portal: this._portal,
42+
values: this.values,
43+
},
44+
true
45+
)
46+
47+
con.describe(
48+
{
49+
type: 'P',
50+
name: this._portal, // AWS Redshift requires a portal name
51+
},
52+
true
53+
)
4554

4655
con.flush()
4756

@@ -60,25 +69,25 @@ Cursor.prototype.submit = function (connection) {
6069
})
6170
}
6271

63-
Cursor.prototype._shiftQueue = function () {
72+
Cursor.prototype._shiftQueue = function() {
6473
if (this._queue.length) {
6574
this._getRows.apply(this, this._queue.shift())
6675
}
6776
}
6877

69-
Cursor.prototype.handleRowDescription = function (msg) {
78+
Cursor.prototype.handleRowDescription = function(msg) {
7079
this._result.addFields(msg.fields)
7180
this.state = 'idle'
7281
this._shiftQueue()
7382
}
7483

75-
Cursor.prototype.handleDataRow = function (msg) {
84+
Cursor.prototype.handleDataRow = function(msg) {
7685
const row = this._result.parseRow(msg.fields)
7786
this.emit('row', row, this._result)
7887
this._rows.push(row)
7988
}
8089

81-
Cursor.prototype._sendRows = function () {
90+
Cursor.prototype._sendRows = function() {
8291
this.state = 'idle'
8392
setImmediate(() => {
8493
const cb = this._cb
@@ -94,26 +103,26 @@ Cursor.prototype._sendRows = function () {
94103
})
95104
}
96105

97-
Cursor.prototype.handleCommandComplete = function (msg) {
106+
Cursor.prototype.handleCommandComplete = function(msg) {
98107
this._result.addCommandComplete(msg)
99108
this.connection.sync()
100109
}
101110

102-
Cursor.prototype.handlePortalSuspended = function () {
111+
Cursor.prototype.handlePortalSuspended = function() {
103112
this._sendRows()
104113
}
105114

106-
Cursor.prototype.handleReadyForQuery = function () {
115+
Cursor.prototype.handleReadyForQuery = function() {
107116
this._sendRows()
108117
this.emit('end', this._result)
109118
this.state = 'done'
110119
}
111120

112-
Cursor.prototype.handleEmptyQuery = function () {
121+
Cursor.prototype.handleEmptyQuery = function() {
113122
this.connection.sync()
114123
}
115124

116-
Cursor.prototype.handleError = function (msg) {
125+
Cursor.prototype.handleError = function(msg) {
117126
this.state = 'error'
118127
this._error = msg
119128
// satisfy any waiting callback
@@ -133,41 +142,41 @@ Cursor.prototype.handleError = function (msg) {
133142
this.connection.sync()
134143
}
135144

136-
Cursor.prototype._getRows = function (rows, cb) {
145+
Cursor.prototype._getRows = function(rows, cb) {
137146
this.state = 'busy'
138147
this._cb = cb
139148
this._rows = []
140149
const msg = {
141150
portal: this._portal,
142-
rows: rows
151+
rows: rows,
143152
}
144153
this.connection.execute(msg, true)
145154
this.connection.flush()
146155
}
147156

148-
Cursor.prototype.end = function (cb) {
157+
Cursor.prototype.end = function(cb) {
149158
if (this.state !== 'initialized') {
150159
this.connection.sync()
151160
}
152161
this.connection.once('end', cb)
153162
this.connection.end()
154163
}
155164

156-
Cursor.prototype.close = function (cb) {
165+
Cursor.prototype.close = function(cb) {
157166
if (this.state === 'done') {
158167
return setImmediate(cb)
159168
}
160169
this.connection.close({ type: 'P' })
161170
this.connection.sync()
162171
this.state = 'done'
163172
if (cb) {
164-
this.connection.once('closeComplete', function () {
173+
this.connection.once('closeComplete', function() {
165174
cb()
166175
})
167176
}
168177
}
169178

170-
Cursor.prototype.read = function (rows, cb) {
179+
Cursor.prototype.read = function(rows, cb) {
171180
if (this.state === 'idle') {
172181
return this._getRows(rows, cb)
173182
}

0 commit comments

Comments
 (0)