git ssb

0+

wanderer🌟 / buffer-pipe



Tree: 8acecacb775090bbbb8c84f5650a86fa4fc48833

Files: 8acecacb775090bbbb8c84f5650a86fa4fc48833 / tests / index.js

580 bytesRaw
1const tape = require('tape')
2const Pipe = require('../')
3
4tape('tests', t => {
5 let p = new Pipe(Buffer.from([1, 2, 3, 4]))
6 p.write(Buffer.from([99]))
7
8 t.deepEquals(p.buffer, Buffer.from([1, 2, 3, 4, 99]))
9
10 const buf = p.read(3)
11
12 t.equals(p.bytesRead, 3, 'should record the number of bytes read from the pipe')
13 t.deepEquals(buf, Buffer.from([1, 2, 3]))
14 t.equal(p.end, false)
15
16 p = new Pipe()
17 p.write(Buffer.from([99]))
18 t.equals(p.bytesWrote, 1, 'should record the number of bytes written to a the pipe')
19
20 t.deepEquals(p.buffer, Buffer.from([99]))
21 t.end()
22})
23

Built with git-ssb-web