mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
7a0e462f9f
Manually fix issues that eslint --fix couldn't do automatically. PR-URL: https://github.com/nodejs/node/pull/10685 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
63 lines
909 B
JavaScript
63 lines
909 B
JavaScript
'use strict';
|
|
require('../common');
|
|
const assert = require('assert');
|
|
|
|
const buffer = Buffer.from([1, 2, 3, 4, 5]);
|
|
let arr;
|
|
let b;
|
|
|
|
// buffers should be iterable
|
|
|
|
arr = [];
|
|
|
|
for (b of buffer)
|
|
arr.push(b);
|
|
|
|
assert.deepStrictEqual(arr, [1, 2, 3, 4, 5]);
|
|
|
|
|
|
// buffer iterators should be iterable
|
|
|
|
arr = [];
|
|
|
|
for (b of buffer[Symbol.iterator]())
|
|
arr.push(b);
|
|
|
|
assert.deepStrictEqual(arr, [1, 2, 3, 4, 5]);
|
|
|
|
|
|
// buffer#values() should return iterator for values
|
|
|
|
arr = [];
|
|
|
|
for (b of buffer.values())
|
|
arr.push(b);
|
|
|
|
assert.deepStrictEqual(arr, [1, 2, 3, 4, 5]);
|
|
|
|
|
|
// buffer#keys() should return iterator for keys
|
|
|
|
arr = [];
|
|
|
|
for (b of buffer.keys())
|
|
arr.push(b);
|
|
|
|
assert.deepStrictEqual(arr, [0, 1, 2, 3, 4]);
|
|
|
|
|
|
// buffer#entries() should return iterator for entries
|
|
|
|
arr = [];
|
|
|
|
for (b of buffer.entries())
|
|
arr.push(b);
|
|
|
|
assert.deepStrictEqual(arr, [
|
|
[0, 1],
|
|
[1, 2],
|
|
[2, 3],
|
|
[3, 4],
|
|
[4, 5]
|
|
]);
|