From cf8f58f851a8e32a4857f35c05a081cd031be124 Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Tue, 12 May 2020 06:53:34 -0700 Subject: [PATCH] fix: drop dependency on string-format-obj (#698) --- package.json | 1 - src/bigquery.ts | 25 ++++++++++--------------- src/table.ts | 8 +------- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index a32aaa1c..e0c015fa 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,6 @@ "is": "^3.3.0", "p-event": "^4.1.0", "stream-events": "^1.0.5", - "string-format-obj": "^1.1.1", "uuid": "^8.0.0" }, "devDependencies": { diff --git a/src/bigquery.ts b/src/bigquery.ts index 3a05fe88..53e895a3 100644 --- a/src/bigquery.ts +++ b/src/bigquery.ts @@ -20,9 +20,6 @@ import {promisifyAll} from '@google-cloud/promisify'; import arrify = require('arrify'); import {Big} from 'big.js'; import * as extend from 'extend'; - -// eslint-disable-next-line @typescript-eslint/no-var-requires -const format = require('string-format-obj'); import * as is from 'is'; import * as uuid from 'uuid'; @@ -1805,12 +1802,11 @@ export class BigQueryDatetime { if (value.hours) { time = BigQuery.time(value).value; } - value = format('{y}-{m}-{d}{time}', { - y: value.year, - m: value.month, - d: value.day, - time: time ? ' ' + time : '', - }); + const y = value.year; + const m = value.month; + const d = value.day; + time = time ? ' ' + time : ''; + value = `${y}-${m}-${d}${time}`; } else { value = value.replace(/^(.*)T(.*)Z$/, '$1 $2'); } @@ -1825,12 +1821,11 @@ export class BigQueryTime { value: string; constructor(value: BigQueryTimeOptions | string) { if (typeof value === 'object') { - value = format('{h}:{m}:{s}{f}', { - h: value.hours, - m: value.minutes || 0, - s: value.seconds || 0, - f: is.defined(value.fractional) ? '.' + value.fractional : '', - }); + const h = value.hours; + const m = value.minutes || 0; + const s = value.seconds || 0; + const f = is.defined(value.fractional) ? '.' + value.fractional : ''; + value = `${h}:${m}:${s}${f}`; } this.value = value as string; } diff --git a/src/table.ts b/src/table.ts index 9a1fb3f0..026536f1 100644 --- a/src/table.ts +++ b/src/table.ts @@ -21,9 +21,6 @@ import arrify = require('arrify'); import Big from 'big.js'; import * as extend from 'extend'; import pEvent from 'p-event'; - -// eslint-disable-next-line @typescript-eslint/no-var-requires -const format = require('string-format-obj'); import * as fs from 'fs'; import * as is from 'is'; import * as path from 'path'; @@ -1416,10 +1413,7 @@ class Table extends common.ServiceObject { }, } as {}, request: { - uri: format('{base}/{projectId}/jobs', { - base: `https://${this.bigQuery.apiEndpoint}/upload/bigquery/v2/projects`, - projectId: this.bigQuery.projectId, - }), + uri: `https://${this.bigQuery.apiEndpoint}/upload/bigquery/v2/projects/${this.bigQuery.projectId}/jobs`, }, }, // eslint-disable-next-line @typescript-eslint/no-explicit-any