Skip to content

Commit

Permalink
Refactor toArray to use OneOrMore utility type
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson committed Feb 10, 2022
1 parent 8973974 commit 930c813
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/connection_string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as fs from 'fs';
import ConnectionString from 'mongodb-connection-string-url';
import { URLSearchParams } from 'url';

import type { OneOrMore } from '.';
import type { Document } from './bson';
import { MongoCredentials } from './cmap/auth/mongo_credentials';
import { AUTH_MECHS_AUTH_SRC_EXTERNAL, AuthMechanism } from './cmap/auth/providers';
Expand Down Expand Up @@ -204,9 +205,8 @@ function getUint(name: string, value: unknown): number {
return parsedValue;
}

function toArray<T>(value: T): T[];
function toArray<T>(value: T[]): T[];
function toArray<T>(value: T | T[]): T[] {
/** Wrap a single value in an array if the value is not an array */
function toArray<T>(value: OneOrMore<T>): T[] {
return Array.isArray(value) ? value : [value];
}

Expand Down

0 comments on commit 930c813

Please sign in to comment.