1515 */
1616import { GrpcService } from './common-grpc/service' ;
1717import { PreciseDate } from '@google-cloud/precise-date' ;
18- import { toArray } from './helper' ;
18+ import {
19+ isArray ,
20+ isBoolean ,
21+ isDate ,
22+ isDecimal ,
23+ isInfinite ,
24+ isInteger ,
25+ isNull ,
26+ isNumber ,
27+ isObject ,
28+ isString ,
29+ isUndefined ,
30+ toArray ,
31+ } from './helper' ;
1932import { Big } from 'big.js' ;
20- import * as is from 'is' ;
2133import { common as p } from 'protobufjs' ;
2234import { google as spannerClient } from '../protos/protos' ;
2335import { GoogleError } from 'google-gax' ;
@@ -440,19 +452,19 @@ export class Interval {
440452 * @param nanoseconds nanoseconds part of the `Interval`
441453 */
442454 constructor ( months : number , days : number , nanoseconds : bigint ) {
443- if ( ! is . integer ( months ) ) {
455+ if ( ! isInteger ( months ) ) {
444456 throw new GoogleError (
445457 `Invalid months: ${ months } , months should be an integral value` ,
446458 ) ;
447459 }
448460
449- if ( ! is . integer ( days ) ) {
461+ if ( ! isInteger ( days ) ) {
450462 throw new GoogleError (
451463 `Invalid days: ${ days } , days should be an integral value` ,
452464 ) ;
453465 }
454466
455- if ( is . null ( nanoseconds ) || is . undefined ( nanoseconds ) ) {
467+ if ( isNull ( nanoseconds ) || isUndefined ( nanoseconds ) ) {
456468 throw new GoogleError (
457469 `Invalid nanoseconds: ${ nanoseconds } , nanoseconds should be a valid bigint value` ,
458470 ) ;
@@ -502,7 +514,7 @@ export class Interval {
502514 * Constructs an `Interval` with specified seconds.
503515 */
504516 static fromSeconds ( seconds : number ) : Interval {
505- if ( ! is . integer ( seconds ) ) {
517+ if ( ! isInteger ( seconds ) ) {
506518 throw new GoogleError (
507519 `Invalid seconds: ${ seconds } , seconds should be an integral value` ,
508520 ) ;
@@ -518,7 +530,7 @@ export class Interval {
518530 * Constructs an `Interval` with specified milliseconds.
519531 */
520532 static fromMilliseconds ( milliseconds : number ) : Interval {
521- if ( ! is . integer ( milliseconds ) ) {
533+ if ( ! isInteger ( milliseconds ) ) {
522534 throw new GoogleError (
523535 `Invalid milliseconds: ${ milliseconds } , milliseconds should be an integral value` ,
524536 ) ;
@@ -534,7 +546,7 @@ export class Interval {
534546 * Constructs an `Interval` with specified microseconds.
535547 */
536548 static fromMicroseconds ( microseconds : number ) : Interval {
537- if ( ! is . integer ( microseconds ) ) {
549+ if ( ! isInteger ( microseconds ) ) {
538550 throw new GoogleError (
539551 `Invalid microseconds: ${ microseconds } , microseconds should be an integral value` ,
540552 ) ;
@@ -817,7 +829,7 @@ function decode(
817829 type : spannerClient . spanner . v1 . Type ,
818830 columnMetadata ?: object ,
819831) : Value {
820- if ( is . null ( value ) ) {
832+ if ( isNull ( value ) ) {
821833 return null ;
822834 }
823835
@@ -954,11 +966,11 @@ function encode(value: Value): p.IValue {
954966 * @returns {* }
955967 */
956968function encodeValue ( value : Value ) : Value {
957- if ( is . number ( value ) && ! is . decimal ( value ) ) {
969+ if ( isNumber ( value ) && ! isDecimal ( value ) ) {
958970 return value . toString ( ) ;
959971 }
960972
961- if ( is . date ( value ) ) {
973+ if ( isDate ( value ) ) {
962974 return value . toJSON ( ) ;
963975 }
964976
@@ -990,7 +1002,7 @@ function encodeValue(value: Value): Value {
9901002 return Array . from ( value ) . map ( field => encodeValue ( field . value ) ) ;
9911003 }
9921004
993- if ( is . array ( value ) ) {
1005+ if ( isArray ( value ) ) {
9941006 return value . map ( encodeValue ) ;
9951007 }
9961008
@@ -1002,7 +1014,7 @@ function encodeValue(value: Value): Value {
10021014 return value . toISO8601 ( ) ;
10031015 }
10041016
1005- if ( is . object ( value ) ) {
1017+ if ( isObject ( value ) ) {
10061018 return JSON . stringify ( value ) ;
10071019 }
10081020
@@ -1099,17 +1111,17 @@ interface FieldType extends Type {
10991111 */
11001112function getType ( value : Value ) : Type {
11011113 const isSpecialNumber =
1102- is . infinite ( value ) || ( is . number ( value ) && isNaN ( value ) ) ;
1114+ isInfinite ( value ) || ( isNumber ( value ) && isNaN ( value ) ) ;
11031115
11041116 if ( value instanceof Float32 ) {
11051117 return { type : 'float32' } ;
11061118 }
11071119
1108- if ( is . decimal ( value ) || isSpecialNumber || value instanceof Float ) {
1120+ if ( isDecimal ( value ) || isSpecialNumber || value instanceof Float ) {
11091121 return { type : 'float64' } ;
11101122 }
11111123
1112- if ( is . number ( value ) || value instanceof Int ) {
1124+ if ( isNumber ( value ) || value instanceof Int ) {
11131125 return { type : 'int64' } ;
11141126 }
11151127
@@ -1141,11 +1153,11 @@ function getType(value: Value): Type {
11411153 return { type : 'enum' , fullName : value . fullName } ;
11421154 }
11431155
1144- if ( is . boolean ( value ) ) {
1156+ if ( isBoolean ( value ) ) {
11451157 return { type : 'bool' } ;
11461158 }
11471159
1148- if ( is . string ( value ) ) {
1160+ if ( isString ( value ) ) {
11491161 return { type : 'string' } ;
11501162 }
11511163
@@ -1157,7 +1169,7 @@ function getType(value: Value): Type {
11571169 return { type : 'date' } ;
11581170 }
11591171
1160- if ( is . date ( value ) ) {
1172+ if ( isDate ( value ) ) {
11611173 return { type : 'timestamp' } ;
11621174 }
11631175
@@ -1170,13 +1182,13 @@ function getType(value: Value): Type {
11701182 } ;
11711183 }
11721184
1173- if ( is . array ( value ) ) {
1185+ if ( isArray ( value ) ) {
11741186 let child ;
11751187
11761188 for ( let i = 0 ; i < value . length ; i ++ ) {
11771189 child = value [ i ] ;
11781190
1179- if ( ! is . null ( child ) ) {
1191+ if ( ! isNull ( child ) ) {
11801192 break ;
11811193 }
11821194 }
@@ -1187,7 +1199,7 @@ function getType(value: Value): Type {
11871199 } ;
11881200 }
11891201
1190- if ( is . object ( value ) ) {
1202+ if ( isObject ( value ) ) {
11911203 return { type : 'json' } ;
11921204 }
11931205
0 commit comments