1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-09-20 07:41:56 +00:00
musix-oss/node_modules/stream-events/index.js
2020-03-03 22:30:50 +02:00

31 lines
514 B
JavaScript

'use strict';
var stubs = require('stubs')
/*
* StreamEvents can be used 2 ways:
*
* 1:
* function MyStream() {
* require('stream-events').call(this)
* }
*
* 2:
* require('stream-events')(myStream)
*/
function StreamEvents(stream) {
stream = stream || this
var cfg = {
callthrough: true,
calls: 1
}
stubs(stream, '_read', cfg, stream.emit.bind(stream, 'reading'))
stubs(stream, '_write', cfg, stream.emit.bind(stream, 'writing'))
return stream
}
module.exports = StreamEvents