当前位置: 首页>>编程示例 >>用法及示例精选 >>正文


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()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。