• {integer}

    返回 buf 中的字节数。

    1. // 创建一个 `Buffer`,并使用 UTF-8 写入一个短的字符串。
    2. const buf = Buffer.alloc(1234);
    3. console.log(buf.length);
    4. // 打印: 1234
    5. buf.write('http://nodejs.cn/', 0, 'utf8');
    6. console.log(buf.length);
    7. // 打印: 1234