📜  Node.js util.types.isBigUint64Array() 方法

📅  最后修改于: 2022-05-13 01:56:19.847000             🧑  作者: Mango

Node.js util.types.isBigUint64Array() 方法

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