Skip to content

Commit

Permalink
chore(deps): update dependencies (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] committed Mar 17, 2021
2 parents 7cbdbdf + 881e881 commit ee5747b
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 162 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Expand Up @@ -8,7 +8,6 @@ module.exports = {
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'prettier/@typescript-eslint',
'plugin:jsonc/auto-config',
],
parser: '@typescript-eslint/parser',
Expand Down
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -50,8 +50,8 @@
"yargs": "^16.1.1"
},
"devDependencies": {
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"@commitlint/cli": "^12.0.1",
"@commitlint/config-conventional": "^12.0.1",
"@databases/pg-test": "^3.0.0",
"@semantic-release/changelog": "^5.0.1",
"@semantic-release/git": "^9.0.0",
Expand All @@ -63,7 +63,7 @@
"@typescript-eslint/parser": "^4.9.1",
"config": "^3.3.3",
"eslint": "^7.15.0",
"eslint-config-prettier": "^7.0.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-jsonc": "^1.2.1",
"eslint-plugin-prettier": "^3.2.0",
"husky": "^5.0.0",
Expand Down
11 changes: 7 additions & 4 deletions src/datasource/DBDataSource.ts
Expand Up @@ -49,6 +49,10 @@ export type LoaderCallback<TResultType> = (
const parseTS = (value: number): Date | null =>
value === null ? null : new Date(value)

const isArray = <T extends unknown[] | readonly unknown[], U>(
value: T | U
): value is T => Array.isArray(value)

export default class DBDataSource<
TRowType,
TContext = unknown,
Expand Down Expand Up @@ -212,11 +216,10 @@ export default class DBDataSource<
options: QueryOptions<TRowType> = {}
): Promise<TRowType | readonly TRowType[] | null> {
if (!options.expected) {
options.expected =
!Array.isArray(rows) || rows.length === 1 ? 'one' : 'many'
options.expected = !isArray(rows) || rows.length === 1 ? 'one' : 'many'
}

if (Array.isArray(rows) && rows.length === 0) {
if (isArray(rows) && rows.length === 0) {
switch (options.expected) {
case 'one': // we should really raise here, strictly speaking
case 'maybeOne':
Expand Down Expand Up @@ -419,7 +422,7 @@ export default class DBDataSource<
return
}

if (!Array.isArray(results)) {
if (!isArray(results)) {
results = [results]
}

Expand Down

0 comments on commit ee5747b

Please sign in to comment.