Sha256: 512e77eb8fede6a74eac4a647024317eacf99b88af904c20017f1d7908cbb381

Contents?: true

Size: 934 Bytes

Versions: 6

Compression:

Stored size: 934 Bytes

Contents

'use strict';
var Buffer = require('../../').Buffer;
if (Buffer.TYPED_ARRAY_SUPPORT) return;

var assert = require('assert');

var buffer = Buffer.from([1, 2, 3, 4, 5]);
var arr;
var b;

// buffers should be iterable

arr = [];

for (b of buffer)
  arr.push(b);

assert.deepEqual(arr, [1, 2, 3, 4, 5]);


// buffer iterators should be iterable

arr = [];

for (b of buffer[Symbol.iterator]())
  arr.push(b);

assert.deepEqual(arr, [1, 2, 3, 4, 5]);


// buffer#values() should return iterator for values

arr = [];

for (b of buffer.values())
  arr.push(b);

assert.deepEqual(arr, [1, 2, 3, 4, 5]);


// buffer#keys() should return iterator for keys

arr = [];

for (b of buffer.keys())
  arr.push(b);

assert.deepEqual(arr, [0, 1, 2, 3, 4]);


// buffer#entries() should return iterator for entries

arr = [];

for (b of buffer.entries())
  arr.push(b);

assert.deepEqual(arr, [
  [0, 1],
  [1, 2],
  [2, 3],
  [3, 4],
  [4, 5]
]);

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
brwy_rails-0.0.6 test/dummy/node_modules/buffer/test/node/test-buffer-iterator.js
brwy_rails-0.0.5 test/dummy/node_modules/buffer/test/node/test-buffer-iterator.js
brwy_rails-0.0.4 test/dummy/node_modules/buffer/test/node/test-buffer-iterator.js
brwy_rails-0.0.3 test/dummy/node_modules/buffer/test/node/test-buffer-iterator.js
brwy_rails-0.0.2 test/dummy/node_modules/buffer/test/node/test-buffer-iterator.js
brwy_rails-0.0.1 test/dummy/node_modules/buffer/test/node/test-buffer-iterator.js