buf.values()
新增于: v1.1.0
-
返回:<Iterator>
\Returns: <Iterator>
为 buf 值(字节)创建并返回 迭代器。当在 for..of 语句中使用 Buffer 时,会自动调用此函数。
\Creates and returns an iterator for buf values (bytes). This function is
called automatically when a Buffer is used in a for..of statement.
import { Buffer } from 'node:buffer'; const buf = Buffer.from('buffer'); for (const value of buf.values()) { console.log(value); } // Prints: // 98 // 117 // 102 // 102 // 101 // 114 for (const value of buf) { console.log(value); } // Prints: // 98 // 117 // 102 // 102 // 101 // 114const { Buffer } = require('node:buffer'); const buf = Buffer.from('buffer'); for (const value of buf.values()) { console.log(value); } // Prints: // 98 // 117 // 102 // 102 // 101 // 114 for (const value of buf) { console.log(value); } // Prints: // 98 // 117 // 102 // 102 // 101 // 114