Register a listener on an event.
Returns : The current StreamHelper object, for chaining.
Throws : An exception if the event is unknown.
name | type | description |
---|---|---|
event | string | the name of the event. Only 3 events are supported : data , end and error . |
callback | function | the function called when the event occurs. See below for the arguments. |
The callbacks are executed in with the current StreamHelper
as this
.
data
callbackIt takes 2 parameters:
end
callbackIt does not take any parameter.
error
callbackIt takes an Error
as parameter.
zip
.generateInternalStream({type:"uint8array"})
.on('data', function (data, metadata) {
// data is a Uint8Array because that's the type asked in generateInternalStream
// metadata contains for example currentFile and percent, see the generateInternalStream doc.
})
.on('error', function (e) {
// e is the error
})
.on('end', function () {
// no parameter
})
.resume();