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


Node.js Buffer buf.entries()用法及代碼示例

buf.entries()

添加於:v1.1.0

buf 的內容創建並返回 [index, byte] 對的 iterator

import { Buffer } from 'node:buffer';

// Log the entire contents of a `Buffer`.

const buf = Buffer.from('buffer');

for (const pair of buf.entries()) {
  console.log(pair);
}
// Prints:
//   [0, 98]
//   [1, 117]
//   [2, 102]
//   [3, 102]
//   [4, 101]
//   [5, 114]const { Buffer } = require('node:buffer');

// Log the entire contents of a `Buffer`.

const buf = Buffer.from('buffer');

for (const pair of buf.entries()) {
  console.log(pair);
}
// Prints:
//   [0, 98]
//   [1, 117]
//   [2, 102]
//   [3, 102]
//   [4, 101]
//   [5, 114]

相關用法


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