diff options
Diffstat (limited to 'tools/eslint/node_modules/concat-stream/test/typedarray.js')
-rw-r--r-- | tools/eslint/node_modules/concat-stream/test/typedarray.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tools/eslint/node_modules/concat-stream/test/typedarray.js b/tools/eslint/node_modules/concat-stream/test/typedarray.js new file mode 100644 index 0000000000..ee07110828 --- /dev/null +++ b/tools/eslint/node_modules/concat-stream/test/typedarray.js @@ -0,0 +1,33 @@ +var concat = require('../') +var test = require('tape') +var TA = require('typedarray') +var U8 = typeof Uint8Array !== 'undefined' ? Uint8Array : TA.Uint8Array + +test('typed array stream', function (t) { + t.plan(2) + var a = new U8(5) + a[0] = 97; a[1] = 98; a[2] = 99; a[3] = 100; a[4] = 101; + var b = new U8(3) + b[0] = 32; b[1] = 102; b[2] = 103; + var c = new U8(4) + c[0] = 32; c[1] = 120; c[2] = 121; c[3] = 122; + + var arrays = concat({ encoding: 'Uint8Array' }, function(out) { + t.equal(typeof out.subarray, 'function') + t.deepEqual(Buffer(out).toString('utf8'), 'abcde fg xyz') + }) + arrays.write(a) + arrays.write(b) + arrays.end(c) +}) + +test('typed array from strings, buffers, and arrays', function (t) { + t.plan(2) + var arrays = concat({ encoding: 'Uint8Array' }, function(out) { + t.equal(typeof out.subarray, 'function') + t.deepEqual(Buffer(out).toString('utf8'), 'abcde fg xyz') + }) + arrays.write('abcde') + arrays.write(Buffer(' fg ')) + arrays.end([ 120, 121, 122 ]) +}) |