Skip to content

Commit a33901b

Browse files
committed
Use standard code style
1 parent 3ad2ad4 commit a33901b

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
[![Build Status](https://secure.travis-ci.org/grncdr/node-any-db-postgres.png)](http://travis-ci.org/grncdr/node-any-db-postgres)
44

5+
[![js-standard-style](https://raw.githubusercontent.com/feross/standard/master/badge.png)](https://github.com/feross/standard)
6+
57
This is the postgres adapter for Any-DB. It relies on the [pg.js][] database
68
driver to create [Connection][] and [Query][] objects that conform to the
79
[Any-DB API][]. The API is practically identical to that of `require('pg')`

index.js

+13-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1+
'use strict'
2+
13
var pg = require('pg')
2-
, QueryStream = require('pg-query-stream')
3-
, inherits = require('inherits')
4+
var QueryStream = require('pg-query-stream')
5+
var inherits = require('inherits')
46

57
var adapter = exports
68

79
adapter.name = 'postgres'
810

911
adapter.createQuery = function (text, params, callback) {
10-
if (typeof text === 'string')
12+
if (typeof text === 'string') {
1113
return new PostgresQuery(text, params, callback)
14+
}
1215
return text
1316
}
1417

@@ -29,19 +32,20 @@ PostgresConnection.prototype.adapter = adapter
2932
PostgresConnection.prototype.query = function (text, params, callback) {
3033
var query = this.adapter.createQuery(text, params, callback)
3134
this.emit('query', query)
32-
return pg.Client.prototype.query.call(this, query);
35+
return pg.Client.prototype.query.call(this, query)
3336
}
3437

3538
inherits(PostgresQuery, QueryStream)
3639
function PostgresQuery (text, params, callback) {
37-
if (typeof params == 'function') {
40+
if (typeof params === 'function') {
3841
callback = params
3942
params = []
4043
}
41-
if (!params) params = [];
44+
if (!params) params = []
4245
this.constructor.super_.call(this, text, params)
4346
this.super_ = this.constructor.super_.prototype
44-
if (this.callback = callback) {
47+
if (callback) {
48+
this.callback = callback
4549
var errored = false
4650
this
4751
.on('error', function (err) {
@@ -54,6 +58,8 @@ function PostgresQuery (text, params, callback) {
5458
.on('end', function () {
5559
if (!errored) this.callback(null, this._result)
5660
})
61+
} else {
62+
this.callback = null
5763
}
5864
}
5965

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "The postgres adapter for any-db",
55
"main": "index.js",
66
"scripts": {
7-
"test": "test-any-db-adapter",
7+
"test": "standard && test-any-db-adapter",
88
"debug": "node debug `which test-any-db-adapter`"
99
},
1010
"repository": {
@@ -32,6 +32,7 @@
3232
"any-db": "~2.1.0"
3333
},
3434
"devDependencies": {
35-
"any-db-adapter-spec": "~2.1.0"
35+
"any-db-adapter-spec": "~2.1.0",
36+
"standard": "*"
3637
}
3738
}

0 commit comments

Comments
 (0)