pg 8.0.0 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/utils.js CHANGED
@@ -11,10 +11,8 @@ const crypto = require('crypto')
11
11
 
12
12
  const defaults = require('./defaults')
13
13
 
14
- function escapeElement (elementRepresentation) {
15
- var escaped = elementRepresentation
16
- .replace(/\\/g, '\\\\')
17
- .replace(/"/g, '\\"')
14
+ function escapeElement(elementRepresentation) {
15
+ var escaped = elementRepresentation.replace(/\\/g, '\\\\').replace(/"/g, '\\"')
18
16
 
19
17
  return '"' + escaped + '"'
20
18
  }
@@ -22,7 +20,7 @@ function escapeElement (elementRepresentation) {
22
20
  // convert a JS array to a postgres array literal
23
21
  // uses comma separator so won't work for types like box that use
24
22
  // a different array separator.
25
- function arrayString (val) {
23
+ function arrayString(val) {
26
24
  var result = '{'
27
25
  for (var i = 0; i < val.length; i++) {
28
26
  if (i > 0) {
@@ -76,7 +74,7 @@ var prepareValue = function (val, seen) {
76
74
  return val.toString()
77
75
  }
78
76
 
79
- function prepareObject (val, seen) {
77
+ function prepareObject(val, seen) {
80
78
  if (val && typeof val.toPostgres === 'function') {
81
79
  seen = seen || []
82
80
  if (seen.indexOf(val) !== -1) {
@@ -89,48 +87,66 @@ function prepareObject (val, seen) {
89
87
  return JSON.stringify(val)
90
88
  }
91
89
 
92
- function pad (number, digits) {
90
+ function pad(number, digits) {
93
91
  number = '' + number
94
- while (number.length < digits) { number = '0' + number }
92
+ while (number.length < digits) {
93
+ number = '0' + number
94
+ }
95
95
  return number
96
96
  }
97
97
 
98
- function dateToString (date) {
98
+ function dateToString(date) {
99
99
  var offset = -date.getTimezoneOffset()
100
100
 
101
101
  var year = date.getFullYear()
102
102
  var isBCYear = year < 1
103
103
  if (isBCYear) year = Math.abs(year) + 1 // negative years are 1 off their BC representation
104
104
 
105
- var ret = pad(year, 4) + '-' +
106
- pad(date.getMonth() + 1, 2) + '-' +
107
- pad(date.getDate(), 2) + 'T' +
108
- pad(date.getHours(), 2) + ':' +
109
- pad(date.getMinutes(), 2) + ':' +
110
- pad(date.getSeconds(), 2) + '.' +
105
+ var ret =
106
+ pad(year, 4) +
107
+ '-' +
108
+ pad(date.getMonth() + 1, 2) +
109
+ '-' +
110
+ pad(date.getDate(), 2) +
111
+ 'T' +
112
+ pad(date.getHours(), 2) +
113
+ ':' +
114
+ pad(date.getMinutes(), 2) +
115
+ ':' +
116
+ pad(date.getSeconds(), 2) +
117
+ '.' +
111
118
  pad(date.getMilliseconds(), 3)
112
119
 
113
120
  if (offset < 0) {
114
121
  ret += '-'
115
122
  offset *= -1
116
- } else { ret += '+' }
123
+ } else {
124
+ ret += '+'
125
+ }
117
126
 
118
127
  ret += pad(Math.floor(offset / 60), 2) + ':' + pad(offset % 60, 2)
119
128
  if (isBCYear) ret += ' BC'
120
129
  return ret
121
130
  }
122
131
 
123
- function dateToStringUTC (date) {
132
+ function dateToStringUTC(date) {
124
133
  var year = date.getUTCFullYear()
125
134
  var isBCYear = year < 1
126
135
  if (isBCYear) year = Math.abs(year) + 1 // negative years are 1 off their BC representation
127
136
 
128
- var ret = pad(year, 4) + '-' +
129
- pad(date.getUTCMonth() + 1, 2) + '-' +
130
- pad(date.getUTCDate(), 2) + 'T' +
131
- pad(date.getUTCHours(), 2) + ':' +
132
- pad(date.getUTCMinutes(), 2) + ':' +
133
- pad(date.getUTCSeconds(), 2) + '.' +
137
+ var ret =
138
+ pad(year, 4) +
139
+ '-' +
140
+ pad(date.getUTCMonth() + 1, 2) +
141
+ '-' +
142
+ pad(date.getUTCDate(), 2) +
143
+ 'T' +
144
+ pad(date.getUTCHours(), 2) +
145
+ ':' +
146
+ pad(date.getUTCMinutes(), 2) +
147
+ ':' +
148
+ pad(date.getUTCSeconds(), 2) +
149
+ '.' +
134
150
  pad(date.getUTCMilliseconds(), 3)
135
151
 
136
152
  ret += '+00:00'
@@ -138,9 +154,9 @@ function dateToStringUTC (date) {
138
154
  return ret
139
155
  }
140
156
 
141
- function normalizeQueryConfig (config, values, callback) {
157
+ function normalizeQueryConfig(config, values, callback) {
142
158
  // can take in strings or config objects
143
- config = (typeof (config) === 'string') ? { text: config } : config
159
+ config = typeof config === 'string' ? { text: config } : config
144
160
  if (values) {
145
161
  if (typeof values === 'function') {
146
162
  config.callback = values
@@ -166,12 +182,12 @@ const postgresMd5PasswordHash = function (user, password, salt) {
166
182
  }
167
183
 
168
184
  module.exports = {
169
- prepareValue: function prepareValueWrapper (value) {
185
+ prepareValue: function prepareValueWrapper(value) {
170
186
  // this ensures that extra arguments do not get passed into prepareValue
171
187
  // by accident, eg: from calling values.map(utils.prepareValue)
172
188
  return prepareValue(value)
173
189
  },
174
190
  normalizeQueryConfig,
175
191
  postgresMd5PasswordHash,
176
- md5
192
+ md5,
177
193
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg",
3
- "version": "8.0.0",
3
+ "version": "8.1.0",
4
4
  "description": "PostgreSQL client - pure javascript & libpq with the same API",
5
5
  "keywords": [
6
6
  "database",
@@ -21,9 +21,9 @@
21
21
  "dependencies": {
22
22
  "buffer-writer": "2.0.0",
23
23
  "packet-reader": "1.0.0",
24
- "pg-connection-string": "0.1.3",
25
- "pg-packet-stream": "^1.1.0",
26
- "pg-pool": "^3.0.0",
24
+ "pg-connection-string": "^2.2.2",
25
+ "pg-pool": "^3.2.0",
26
+ "pg-protocol": "^1.2.2",
27
27
  "pg-types": "^2.1.0",
28
28
  "pgpass": "1.x",
29
29
  "semver": "4.3.2"
@@ -32,18 +32,11 @@
32
32
  "async": "0.9.0",
33
33
  "bluebird": "3.5.2",
34
34
  "co": "4.6.0",
35
- "eslint": "^6.0.1",
36
- "eslint-config-standard": "^13.0.1",
37
- "eslint-plugin-import": "^2.18.1",
38
- "eslint-plugin-node": "^9.1.0",
39
- "eslint-plugin-promise": "^4.2.1",
40
- "eslint-plugin-standard": "^4.0.0",
41
35
  "pg-copy-streams": "0.3.0"
42
36
  },
43
37
  "minNativeVersion": "2.0.0",
44
38
  "scripts": {
45
- "test": "make test-all",
46
- "lint": "make lint"
39
+ "test": "make test-all"
47
40
  },
48
41
  "files": [
49
42
  "lib",
@@ -53,5 +46,5 @@
53
46
  "engines": {
54
47
  "node": ">= 8.0.0"
55
48
  },
56
- "gitHead": "a227d3e8d47e1eb53296a3a013f2e7514cd152c3"
49
+ "gitHead": "3f5bc58a86cda3b4812addc1e42a06d61d31e614"
57
50
  }