util模块的util.types.isBigUint64Array()方法主要旨在满足Node.js自己的内部API的需求。
util.types.isBigUint64Array()方法用于检查给定值是否为BigUint64Array对象。
用法:
util.types.isBigUint64Array( value )
参数:该函数接受上面提到并在下面描述的一个参数:
- value:这是BigUint64Array对象要检查的值。
返回值:此方法返回一个布尔值,即如果传递的值是BigUint64Array的实例,则为true,否则返回false。
以下示例说明了Node.js中的util.types.isBigUint64Array()方法:
范例1:
// Node.js program to demonstrate the
// util.types.isBigUint64Array() method
// Import the util module
const util = require('util');
// Checking for a big signed 64-bit integer array
isBigUnsignedint64Arr
= util.types.isBigUint64Array(new BigUint64Array());
console.log("Object is Big Unsigned 64-bit array object:",
isBigUnsignedint64Arr);
isBigUnsignedint64Arr
= util.types.isBigUint64Array(new BigInt64Array());
console.log("Object is Big Unsigned 64-bit array object:",
isBigUnsignedint64Arr);
isBigUnsignedint64Arr
= util.types.isBigUint64Array(new Int32Array());
console.log("Object is Big Unsigned 64-bit array object:",
isBigUnsignedint64Arr);
输出:
Object is Big Unsigned 64-bit array object:true Object is Big Unsigned 64-bit array object:false Object is Big Unsigned 64-bit array object:false
范例2:
// Node.js program to demonstrate the
// util.types.isBigUint64Array() method
// Import the util module
const util = require('util');
// Checking a big unsigned 64-bit integer array
let bigUnsigned64Arr
= new BigUint64Array([16n, 25n, 69n]);
console.log(bigUnsigned64Arr);
isBigUnsignedint64Arr
= util.types.isBigUint64Array(bigUnsigned64Arr);
console.log("Object is Big Unsigned 64-bit array object:",
isBigUnsignedint64Arr);
// Checking a big signed 64-bit integer array
let bigSigned64Arr
= new BigInt64Array([16n, 25n, 69n]);
console.log(bigSigned64Arr);
isBigUnsignedint64Arr
= util.types.isBigUint64Array(bigSigned64Arr);
console.log("Object is Big Unsigned 64-bit array object:",
isBigUnsignedint64Arr);
// Checking a unsigned 32-bit integer array
let unsigned32Arr
= new Uint32Array([16, 25, 69]);
console.log(unsigned32Arr);
isBigUnsignedint64Arr
= util.types.isBigUint64Array(unsigned32Arr);
console.log("Object is Big Unsigned 64-bit array object:",
isBigUnsignedint64Arr);
输出:
BigUint64Array [ 16n, 25n, 69n ] Object is Big Unsigned 64-bit array object:true BigInt64Array [ 16n, 25n, 69n ] Object is Big Unsigned 64-bit array object:false Uint32Array [ 16, 25, 69 ] Object is Big Unsigned 64-bit array object:false
参考: https://nodejs.org/api/util.html#util_util_types_isbiguint64array_value
相关用法
注:本文由纯净天空筛选整理自sayantanm19大神的英文原创作品 Node.js | util.types.isBigUint64Array() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。