@google-cloud/bigquery
Version:
Google BigQuery Client Library for Node.js
84 lines • 2.16 kB
JavaScript
;
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.toArray = toArray;
exports.isObject = isObject;
exports.isString = isString;
exports.isArray = isArray;
exports.isDate = isDate;
exports.isBoolean = isBoolean;
exports.isNumber = isNumber;
/**
* Convert a value to an array. Replacement to arrify
* @internal
*/
function toArray(value) {
if (value === null || value === undefined) {
return [];
}
if (Array.isArray(value)) {
return value;
}
if (typeof value === 'string') {
return [value];
}
if (typeof value[Symbol.iterator] === 'function') {
return [...value];
}
return [value];
}
/**
* Check if value is an object.
* @internal
*/
function isObject(value) {
return value && [undefined, Object].includes(value.constructor);
}
/**
* Check if value is an object.
* @internal
*/
function isString(value) {
return Object.prototype.toString.call(value) === '[object String]';
}
/**
* Check if value is an array.
* @internal
*/
function isArray(value) {
return Array.isArray(value);
}
/**
* Check if value is an instance of Date.
* @internal
*/
function isDate(value) {
return value instanceof Date;
}
/**
* Check if value is a boolean.
* @internal
*/
function isBoolean(value) {
return Object.prototype.toString.call(value) === '[object Boolean]';
}
/**
* Check if value is a number.
* @internal
*/
function isNumber(value) {
return Object.prototype.toString.call(value) === '[object Number]';
}
//# sourceMappingURL=util.js.map