Skip to content
This repository was archived by the owner on Feb 7, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: remove dep on is package
  • Loading branch information
alvarowolfx committed Jul 21, 2025
commit d09bee2c536d4c37dde35059996e74765764d6a8
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"big.js": "^6.2.2",
"duplexify": "^4.1.3",
"extend": "^3.0.2",
"is": "^3.3.0",
"stream-events": "^1.0.5"
},
"overrides": {
Expand Down
29 changes: 14 additions & 15 deletions src/bigquery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ import * as common from '@google-cloud/common';
import {paginator, ResourceStream} from '@google-cloud/paginator';
import {promisifyAll} from '@google-cloud/promisify';
import {PreciseDate} from '@google-cloud/precise-date';
import {toArray} from './util';
import {toArray, isArray, isObject, isDate, isBoolean, isNumber} from './util';
import * as Big from 'big.js';
import * as extend from 'extend';
import * as is from 'is';
import {randomUUID} from 'crypto';

import {Dataset, DatasetOptions} from './dataset';
Expand Down Expand Up @@ -1071,13 +1070,13 @@ export class BigQuery extends Service {
'RANGE',
];

if (is.array(providedType)) {
if (isArray(providedType)) {
providedType = providedType as Array<ProvidedTypeStruct | string | []>;
return {
type: 'ARRAY',
arrayType: BigQuery.getTypeDescriptorFromProvidedType_(providedType[0]),
};
} else if (is.object(providedType)) {
} else if (isObject(providedType)) {
return {
type: 'STRUCT',
structTypes: Object.keys(providedType).map(prop => {
Expand Down Expand Up @@ -1147,7 +1146,7 @@ export class BigQuery extends Service {
type: value.elementType,
},
};
} else if (Array.isArray(value)) {
} else if (isArray(value)) {
if (value.length === 0) {
throw new Error(
"Parameter types must be provided for empty arrays via the 'types' field in query options.",
Expand All @@ -1157,11 +1156,11 @@ export class BigQuery extends Service {
type: 'ARRAY',
arrayType: BigQuery.getTypeDescriptorFromValue_(value[0]),
};
} else if (is.boolean(value)) {
} else if (isBoolean(value)) {
typeName = 'BOOL';
} else if (is.number(value)) {
} else if (isNumber(value)) {
typeName = (value as number) % 1 === 0 ? 'INT64' : 'FLOAT64';
} else if (is.object(value)) {
} else if (isObject(value)) {
return {
type: 'STRUCT',
structTypes: Object.keys(value as object).map(prop => {
Expand Down Expand Up @@ -1207,7 +1206,7 @@ export class BigQuery extends Service {
value: any,
providedType?: string | ProvidedTypeStruct | ProvidedTypeArray,
) {
if (is.date(value)) {
if (isDate(value)) {
value = BigQuery.timestamp(value as Date);
}
let parameterType: bigquery.IQueryParameterType;
Expand All @@ -1223,8 +1222,8 @@ export class BigQuery extends Service {
queryParameter.parameterValue!.arrayValues = (value as Array<{}>).map(
itemValue => {
const value = BigQuery._getValue(itemValue, parameterType.arrayType!);
if (is.object(value) || is.array(value)) {
if (is.array(providedType)) {
if (isObject(value) || isArray(value)) {
if (isArray(providedType)) {
providedType = providedType as [];
return BigQuery.valueToQueryParameter_(value, providedType[0])
.parameterValue!;
Expand Down Expand Up @@ -1271,7 +1270,7 @@ export class BigQuery extends Service {
value: rangeValue.value.end,
},
};
} else if (typeName === 'JSON' && is.object(value)) {
} else if (typeName === 'JSON' && isObject(value)) {
queryParameter.parameterValue!.value = JSON.stringify(value);
} else {
queryParameter.parameterValue!.value = BigQuery._getValue(
Expand Down Expand Up @@ -1586,7 +1585,7 @@ export class BigQuery extends Service {
params: undefined,
};
}
const parameterMode = is.array(params) ? 'positional' : 'named';
const parameterMode = isArray(params) ? 'positional' : 'named';
const queryParameters: bigquery.IQueryParameter[] = [];
if (parameterMode === 'named') {
const namedParams = params as {[param: string]: any};
Expand All @@ -1595,7 +1594,7 @@ export class BigQuery extends Service {
let queryParameter;

if (types) {
if (!is.object(types)) {
if (!isObject(types)) {
throw new Error(
'Provided types must match the value type passed to `params`',
);
Expand All @@ -1620,7 +1619,7 @@ export class BigQuery extends Service {
}
} else {
if (types) {
if (!is.array(types)) {
if (!isArray(types)) {
throw new Error(
'Provided types must match the value type passed to `params`',
);
Expand Down
11 changes: 5 additions & 6 deletions src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ import {
} from '@google-cloud/common';
import {paginator, ResourceStream} from '@google-cloud/paginator';
import {promisifyAll} from '@google-cloud/promisify';
import {toArray} from './util';
import {isArray, isString, isDate, toArray} from './util';
import * as Big from 'big.js';
import * as extend from 'extend';
import {once} from 'events';
import * as fs from 'fs';
import * as is from 'is';
import * as path from 'path';
import * as streamEvents from 'stream-events';
import {randomUUID} from 'crypto';
Expand Down Expand Up @@ -592,11 +591,11 @@ class Table extends ServiceObject {
return (value as {value: {}}).value;
}

if (is.date(value)) {
if (isDate(value)) {
return (value as Date).toJSON();
}

if (is.array(value)) {
if (isArray(value)) {
return (value as []).map(Table.encodeValue_);
}

Expand Down Expand Up @@ -625,11 +624,11 @@ class Table extends ServiceObject {
delete (body as TableMetadata).name;
}

if (is.string(options.schema)) {
if (isString(options.schema)) {
body.schema = Table.createSchemaFromString_(options.schema as string);
}

if (is.array(options.schema)) {
if (isArray(options.schema)) {
body.schema = {
fields: options.schema as [],
};
Expand Down
48 changes: 48 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,51 @@ export function toArray(value: any) {

return [value];
}

/**
* Check if value is an object.
* @internal
*/
export function isObject(value: any) {
return value && [undefined, Object].includes(value.constructor);
}

/**
* Check if value is an object.
* @internal
*/
export function isString(value: any) {
return Object.prototype.toString.call(value) === '[object String]';
}

/**
* Check if value is an array.
* @internal
*/
export function isArray(value: any) {
return Array.isArray(value);
}

/**
* Check if value is an instance of Date.
* @internal
*/
export function isDate(value: any) {
return value instanceof Date;
}

/**
* Check if value is a boolean.
* @internal
*/
export function isBoolean(value: any) {
return Object.prototype.toString.call(value) === '[object Boolean]';
}

/**
* Check if value is a number.
* @internal
*/
export function isNumber(value: any) {
return Object.prototype.toString.call(value) === '[object Number]';
}