Skip to content

Commit 6330dc6

Browse files
authored
chore: bump Deno to v0.39.0 (#106)
1 parent 8fc90aa commit 6330dc6

18 files changed

+74
-70
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: generic
22

33
install:
4-
- curl -fsSL https://deno.land/x/install/install.sh | sh -s v0.35.0
4+
- curl -fsSL https://deno.land/x/install/install.sh | sh -s v0.39.0
55
- export PATH="$HOME/.deno/bin:$PATH"
66

77
services:

connection.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ import { ConnectionParams } from "./connection_params.ts";
3636

3737
export enum Format {
3838
TEXT = 0,
39-
BINARY = 1
39+
BINARY = 1,
4040
}
4141

4242
enum TransactionStatus {
4343
Idle = "I",
4444
IdleInTransaction = "T",
45-
InFailedTransaction = "E"
45+
InFailedTransaction = "E",
4646
}
4747

4848
export class Message {
@@ -51,7 +51,7 @@ export class Message {
5151
constructor(
5252
public type: string,
5353
public byteCount: number,
54-
public body: Uint8Array
54+
public body: Uint8Array,
5555
) {
5656
this.reader = new PacketReader(body);
5757
}
@@ -65,7 +65,7 @@ export class Column {
6565
public typeOid: number,
6666
public columnLength: number,
6767
public typeModifier: number,
68-
public format: Format
68+
public format: Format,
6969
) {}
7070
}
7171

@@ -111,7 +111,7 @@ export class Connection {
111111
// TODO: recognize other parameters
112112
(["user", "database", "application_name"] as Array<
113113
keyof ConnectionParams
114-
>).forEach(function(key) {
114+
>).forEach(function (key) {
115115
const val = connParams[key];
116116
writer.addCString(key).addCString(val);
117117
});
@@ -138,7 +138,7 @@ export class Connection {
138138
const { host, port } = this.connParams;
139139
this.conn = await Deno.connect({
140140
port: parseInt(port, 10),
141-
hostname: host
141+
hostname: host,
142142
});
143143

144144
this.bufReader = new BufReader(this.conn);
@@ -230,7 +230,7 @@ export class Connection {
230230
const password = hashMd5Password(
231231
this.connParams.password,
232232
this.connParams.user,
233-
salt
233+
salt,
234234
);
235235
const buffer = this.packetWriter.addCString(password).flush(0x70);
236236

@@ -253,7 +253,7 @@ export class Connection {
253253
private _processReadyForQuery(msg: Message) {
254254
const txStatus = msg.reader.readByte();
255255
this._transactionStatus = String.fromCharCode(
256-
txStatus
256+
txStatus,
257257
) as TransactionStatus;
258258
}
259259

@@ -262,7 +262,7 @@ export class Connection {
262262

263263
if (msg.type !== "Z") {
264264
throw new Error(
265-
`Unexpected message type: ${msg.type}, expected "Z" (ReadyForQuery)`
265+
`Unexpected message type: ${msg.type}, expected "Z" (ReadyForQuery)`,
266266
);
267267
}
268268

@@ -363,7 +363,7 @@ export class Connection {
363363
if (hasBinaryArgs) {
364364
this.packetWriter.addInt16(query.args.length);
365365

366-
query.args.forEach(arg => {
366+
query.args.forEach((arg) => {
367367
this.packetWriter.addInt16(arg instanceof Uint8Array ? 1 : 0);
368368
});
369369
} else {
@@ -372,7 +372,7 @@ export class Connection {
372372

373373
this.packetWriter.addInt16(query.args.length);
374374

375-
query.args.forEach(arg => {
375+
query.args.forEach((arg) => {
376376
if (arg === null || typeof arg === "undefined") {
377377
this.packetWriter.addInt32(-1);
378378
} else if (arg instanceof Uint8Array) {
@@ -546,7 +546,7 @@ export class Connection {
546546
msg.reader.readInt32(), // dataTypeOid
547547
msg.reader.readInt16(), // column
548548
msg.reader.readInt32(), // typeModifier
549-
msg.reader.readInt16() // format
549+
msg.reader.readInt16(), // format
550550
);
551551
columns.push(column);
552552
}

connection_params.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function getPgEnv(): IConnectionParams {
99
port: env.PGPORT,
1010
user: env.PGUSER,
1111
password: env.PGPASSWORD,
12-
application_name: env.PGAPPNAME
12+
application_name: env.PGAPPNAME,
1313
};
1414
} catch (e) {
1515
// PermissionDenied (--allow-env not passed)
@@ -19,7 +19,7 @@ function getPgEnv(): IConnectionParams {
1919

2020
function selectFrom(
2121
sources: Array<IConnectionParams>,
22-
key: keyof IConnectionParams
22+
key: keyof IConnectionParams,
2323
): string | undefined {
2424
for (const source of sources) {
2525
if (source[key]) {
@@ -32,15 +32,15 @@ function selectFrom(
3232

3333
function selectFromWithDefault(
3434
sources: Array<IConnectionParams>,
35-
key: keyof typeof DEFAULT_CONNECTION_PARAMS
35+
key: keyof typeof DEFAULT_CONNECTION_PARAMS,
3636
): string {
3737
return selectFrom(sources, key) || DEFAULT_CONNECTION_PARAMS[key];
3838
}
3939

4040
const DEFAULT_CONNECTION_PARAMS = {
4141
host: "127.0.0.1",
4242
port: "5432",
43-
application_name: "deno_postgres"
43+
application_name: "deno_postgres",
4444
};
4545

4646
export interface IConnectionParams {
@@ -83,35 +83,37 @@ export class ConnectionParams {
8383
config = dsn;
8484
}
8585

86-
let potentiallyNull: { [K in keyof IConnectionParams]?: string; } = {
86+
let potentiallyNull: { [K in keyof IConnectionParams]?: string } = {
8787
database: selectFrom([config, pgEnv], "database"),
88-
user: selectFrom([config, pgEnv], "user")
88+
user: selectFrom([config, pgEnv], "user"),
8989
};
9090

9191
this.host = selectFromWithDefault([config, pgEnv], "host");
9292
this.port = selectFromWithDefault([config, pgEnv], "port");
9393
this.application_name = selectFromWithDefault(
9494
[config, pgEnv],
95-
"application_name"
95+
"application_name",
9696
);
9797
this.password = selectFrom([config, pgEnv], "password");
9898

9999
const missingParams: string[] = [];
100100

101-
(["database", "user"] as Array<keyof IConnectionParams>).forEach(param => {
102-
if (potentiallyNull[param]) {
103-
this[param] = potentiallyNull[param]!;
104-
} else {
105-
missingParams.push(param);
106-
}
107-
});
101+
(["database", "user"] as Array<keyof IConnectionParams>).forEach(
102+
(param) => {
103+
if (potentiallyNull[param]) {
104+
this[param] = potentiallyNull[param]!;
105+
} else {
106+
missingParams.push(param);
107+
}
108+
},
109+
);
108110

109111
if (missingParams.length) {
110112
throw new ConnectionParamsError(
111113
`Missing connection parameters: ${missingParams.join(
112-
", "
114+
", ",
113115
)}. Connection parameters can be read
114-
from environment only if Deno is run with env permission (deno run --allow-env)`
116+
from environment only if Deno is run with env permission (deno run --allow-env)`,
115117
);
116118
}
117119
}

deferred.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export class DeferredStack<T> {
99
constructor(
1010
max?: number,
1111
ls?: Iterable<T>,
12-
private _creator?: () => Promise<T>
12+
private _creator?: () => Promise<T>,
1313
) {
1414
this._maxSize = max || 10;
1515
this._array = ls ? [...ls] : [];

deps.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
export {
22
BufReader,
33
BufWriter
4-
} from "https://deno.land/std@v0.35.0/io/bufio.ts";
4+
} from "https://deno.land/std@v0.39.0/io/bufio.ts";
55

6-
export { copyBytes } from "https://deno.land/std@v0.35.0/io/util.ts";
6+
export { copyBytes } from "https://deno.land/std@v0.39.0/io/util.ts";
77

88
export {
99
Deferred,
1010
deferred
11-
} from "https://deno.land/std@v0.35.0/util/async.ts";
11+
} from "https://deno.land/std@v0.39.0/util/async.ts";
1212

13-
export { Hash } from "https://deno.land/x/checksum@1.0.1/mod.ts";
13+
export { Hash } from "https://deno.land/x/checksum@1.2.0/mod.ts";

encode.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function encodeArray(array: Array<unknown>): string {
7373

7474
function encodeBytes(value: Uint8Array): string {
7575
let hex = Array.from(value)
76-
.map(val => (val < 10 ? `0${val.toString(16)}` : val.toString(16)))
76+
.map((val) => (val < 10 ? `0${val.toString(16)}` : val.toString(16)))
7777
.join("");
7878
return `\\x${hex}`;
7979
}

oid.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,5 +165,5 @@ export const Oid = {
165165
regnamespace: 4089,
166166
_regnamespace: 4090,
167167
regrole: 4096,
168-
_regrole: 4097
168+
_regrole: 4097,
169169
};

pool.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class Pool {
1515
constructor(
1616
connectionParams: IConnectionParams,
1717
maxSize: number,
18-
lazy?: boolean
18+
lazy?: boolean,
1919
) {
2020
this._connectionParams = new ConnectionParams(connectionParams);
2121
this._maxSize = maxSize;
@@ -54,7 +54,7 @@ export class Pool {
5454
this._availableConnections = new DeferredStack(
5555
this._maxSize,
5656
this._connections,
57-
this._createConnection.bind(this)
57+
this._createConnection.bind(this),
5858
);
5959
}
6060

@@ -89,8 +89,10 @@ export class Pool {
8989

9090
async end(): Promise<void> {
9191
await this._ready;
92-
const ending = this._connections.map(c => c.end());
93-
await Promise.all(ending);
92+
while (this.available > 0) {
93+
const conn = await this._availableConnections.pop();
94+
await conn.end();
95+
}
9496
}
9597

9698
// Support `using` module

query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class QueryResult {
4949
}
5050

5151
rowsOfObjects() {
52-
return this.rows.map(row => {
52+
return this.rows.map((row) => {
5353
const rv: { [key: string]: any } = {};
5454
this.rowDescription.columns.forEach((column, index) => {
5555
rv[column.name] = row[index];

test_deps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ export {
44
assertEquals,
55
assertStrContains,
66
assertThrowsAsync
7-
} from "https://deno.land/std@v0.35.0/testing/asserts.ts";
7+
} from "https://deno.land/std@v0.39.0/testing/asserts.ts";

tests/connection_params.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ConnectionParams } from "../connection_params.ts";
44

55
test(async function dsnStyleParameters() {
66
const p = new ConnectionParams(
7-
"postgres://some_user@some_host:10101/deno_postgres"
7+
"postgres://some_user@some_host:10101/deno_postgres",
88
);
99

1010
assertEquals(p.database, "deno_postgres");
@@ -18,7 +18,7 @@ test(async function objectStyleParameters() {
1818
user: "some_user",
1919
host: "some_host",
2020
port: "10101",
21-
database: "deno_postgres"
21+
database: "deno_postgres",
2222
});
2323

2424
assertEquals(p.database, "deno_postgres");
@@ -52,7 +52,7 @@ test(async function envParameters() {
5252
test(async function defaultParameters() {
5353
const p = new ConnectionParams({
5454
database: "deno_postgres",
55-
user: "deno_postgres"
55+
user: "deno_postgres",
5656
});
5757
assertEquals(p.database, "deno_postgres");
5858
assertEquals(p.user, "deno_postgres");
@@ -71,7 +71,7 @@ test(async function requiredParameters() {
7171
assertEquals(e.name, "ConnectionParamsError");
7272
assertStrContains(
7373
e.message,
74-
"Missing connection parameters: database, user"
74+
"Missing connection parameters: database, user",
7575
);
7676
}
7777
assertEquals(thrown, true);

tests/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ export const DEFAULT_SETUP = [
88
`INSERT INTO timestamps(dt) VALUES('2019-02-10T10:30:40.005+04:30');`,
99
"DROP TABLE IF EXISTS bytes;",
1010
"CREATE TABLE bytes(b bytea);",
11-
"INSERT INTO bytes VALUES(E'foo\\\\000\\\\200\\\\\\\\\\\\377')"
11+
"INSERT INTO bytes VALUES(E'foo\\\\000\\\\200\\\\\\\\\\\\377')",
1212
];
1313

1414
export const TEST_CONNECTION_PARAMS = {
1515
user: "test",
1616
password: "test",
1717
database: "deno_postgres",
1818
host: "127.0.0.1",
19-
port: "5432"
19+
port: "5432",
2020
};

0 commit comments

Comments
 (0)