-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsplit.js
More file actions
24 lines (16 loc) · 670 Bytes
/
Copy pathsplit.js
File metadata and controls
24 lines (16 loc) · 670 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
var BufferStream = require('../bufferstream');
var stream = new BufferStream({encoding:'utf8', size:'flexible'});
console.log("stream size is", stream.size);
stream.split('//', ':');
var i = 2;
stream.on('split', function (chunk, token) {
console.log("got '%s' by '%s'", chunk.toString(), token.toString());
if (token === ':' || (token === '//' && !--i)) stream.disable(token);
});
stream.on('data', function (chunk) {
console.log("got data '%s'", chunk.toString());
});
console.log("writing stream is",
stream.write("buffer:stream//23:42//disabled") && "ok" || "failed");
stream.end();
console.log("stream content:", stream.toString());