當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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



相關用法


注:本文由純淨天空篩選整理自sayantanm19大神的英文原創作品 Node.js | util.types.isBigUint64Array() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。