@@ -25,10 +25,17 @@ import * as common from '@google-cloud/common';
2525import { paginator , ResourceStream } from '@google-cloud/paginator' ;
2626import { promisifyAll } from '@google-cloud/promisify' ;
2727import { PreciseDate } from '@google-cloud/precise-date' ;
28- import { toArray } from './util' ;
28+ import {
29+ toArray ,
30+ isArray ,
31+ isString ,
32+ isObject ,
33+ isDate ,
34+ isBoolean ,
35+ isNumber ,
36+ } from './util' ;
2937import * as Big from 'big.js' ;
3038import * as extend from 'extend' ;
31- import * as is from 'is' ;
3239import { randomUUID } from 'crypto' ;
3340
3441import { Dataset , DatasetOptions } from './dataset' ;
@@ -1071,13 +1078,13 @@ export class BigQuery extends Service {
10711078 'RANGE' ,
10721079 ] ;
10731080
1074- if ( is . array ( providedType ) ) {
1081+ if ( isArray ( providedType ) ) {
10751082 providedType = providedType as Array < ProvidedTypeStruct | string | [ ] > ;
10761083 return {
10771084 type : 'ARRAY' ,
10781085 arrayType : BigQuery . getTypeDescriptorFromProvidedType_ ( providedType [ 0 ] ) ,
10791086 } ;
1080- } else if ( is . object ( providedType ) ) {
1087+ } else if ( isObject ( providedType ) ) {
10811088 return {
10821089 type : 'STRUCT' ,
10831090 structTypes : Object . keys ( providedType ) . map ( prop => {
@@ -1147,7 +1154,7 @@ export class BigQuery extends Service {
11471154 type : value . elementType ,
11481155 } ,
11491156 } ;
1150- } else if ( Array . isArray ( value ) ) {
1157+ } else if ( isArray ( value ) ) {
11511158 if ( value . length === 0 ) {
11521159 throw new Error (
11531160 "Parameter types must be provided for empty arrays via the 'types' field in query options." ,
@@ -1157,11 +1164,11 @@ export class BigQuery extends Service {
11571164 type : 'ARRAY' ,
11581165 arrayType : BigQuery . getTypeDescriptorFromValue_ ( value [ 0 ] ) ,
11591166 } ;
1160- } else if ( is . boolean ( value ) ) {
1167+ } else if ( isBoolean ( value ) ) {
11611168 typeName = 'BOOL' ;
1162- } else if ( is . number ( value ) ) {
1169+ } else if ( isNumber ( value ) ) {
11631170 typeName = ( value as number ) % 1 === 0 ? 'INT64' : 'FLOAT64' ;
1164- } else if ( is . object ( value ) ) {
1171+ } else if ( isObject ( value ) ) {
11651172 return {
11661173 type : 'STRUCT' ,
11671174 structTypes : Object . keys ( value as object ) . map ( prop => {
@@ -1172,7 +1179,7 @@ export class BigQuery extends Service {
11721179 } ;
11731180 } ) ,
11741181 } ;
1175- } else if ( is . string ( value ) ) {
1182+ } else if ( isString ( value ) ) {
11761183 typeName = 'STRING' ;
11771184 }
11781185
@@ -1207,7 +1214,7 @@ export class BigQuery extends Service {
12071214 value : any ,
12081215 providedType ?: string | ProvidedTypeStruct | ProvidedTypeArray ,
12091216 ) {
1210- if ( is . date ( value ) ) {
1217+ if ( isDate ( value ) ) {
12111218 value = BigQuery . timestamp ( value as Date ) ;
12121219 }
12131220 let parameterType : bigquery . IQueryParameterType ;
@@ -1223,8 +1230,8 @@ export class BigQuery extends Service {
12231230 queryParameter . parameterValue ! . arrayValues = ( value as Array < { } > ) . map (
12241231 itemValue => {
12251232 const value = BigQuery . _getValue ( itemValue , parameterType . arrayType ! ) ;
1226- if ( is . object ( value ) || is . array ( value ) ) {
1227- if ( is . array ( providedType ) ) {
1233+ if ( isObject ( value ) || isArray ( value ) ) {
1234+ if ( isArray ( providedType ) ) {
12281235 providedType = providedType as [ ] ;
12291236 return BigQuery . valueToQueryParameter_ ( value , providedType [ 0 ] )
12301237 . parameterValue ! ;
@@ -1271,7 +1278,7 @@ export class BigQuery extends Service {
12711278 value : rangeValue . value . end ,
12721279 } ,
12731280 } ;
1274- } else if ( typeName === 'JSON' && is . object ( value ) ) {
1281+ } else if ( typeName === 'JSON' && isObject ( value ) ) {
12751282 queryParameter . parameterValue ! . value = JSON . stringify ( value ) ;
12761283 } else {
12771284 queryParameter . parameterValue ! . value = BigQuery . _getValue (
@@ -1586,7 +1593,7 @@ export class BigQuery extends Service {
15861593 params : undefined ,
15871594 } ;
15881595 }
1589- const parameterMode = is . array ( params ) ? 'positional' : 'named' ;
1596+ const parameterMode = isArray ( params ) ? 'positional' : 'named' ;
15901597 const queryParameters : bigquery . IQueryParameter [ ] = [ ] ;
15911598 if ( parameterMode === 'named' ) {
15921599 const namedParams = params as { [ param : string ] : any } ;
@@ -1595,7 +1602,7 @@ export class BigQuery extends Service {
15951602 let queryParameter ;
15961603
15971604 if ( types ) {
1598- if ( ! is . object ( types ) ) {
1605+ if ( ! isObject ( types ) ) {
15991606 throw new Error (
16001607 'Provided types must match the value type passed to `params`' ,
16011608 ) ;
@@ -1620,7 +1627,7 @@ export class BigQuery extends Service {
16201627 }
16211628 } else {
16221629 if ( types ) {
1623- if ( ! is . array ( types ) ) {
1630+ if ( ! isArray ( types ) ) {
16241631 throw new Error (
16251632 'Provided types must match the value type passed to `params`' ,
16261633 ) ;
@@ -2466,7 +2473,7 @@ function convertSchemaFieldValue(
24662473 parseJSON ?: boolean ;
24672474 } ,
24682475) {
2469- if ( is . null ( value ) ) {
2476+ if ( value === null ) {
24702477 return value ;
24712478 }
24722479
@@ -2783,7 +2790,7 @@ export class BigQueryTime {
27832790 const h = value . hours ;
27842791 const m = value . minutes || 0 ;
27852792 const s = value . seconds || 0 ;
2786- const f = is . defined ( value . fractional ) ? '.' + value . fractional : '' ;
2793+ const f = value . fractional !== undefined ? '.' + value . fractional : '' ;
27872794 value = `${ h } :${ m } :${ s } ${ f } ` ;
27882795 }
27892796 this . value = value as string ;
0 commit comments