on-finished
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
ee-first | 1.1.1 | 2.67 kB | MIT | prod |
The on-finished npm package is designed to execute a callback when an HTTP request closes, finishes, or encounters an error. It's a Node.js module that can be used to efficiently manage events related to HTTP requests on your server.
The on-finished npm package can be easily installed using the npm install on-finished
command. Once installed, it can be included in your Node.js project with the line of code var onFinished = require('on-finished')
.
To use on-finished, listeners are attached to requests or responses to listen for their conclusion, using onFinished(res, listener)
for responses and onFinished(req, listener)
for requests. An example of its usage is as follows:
var onFinished = require('on-finished')
var data = ''
req.setEncoding('utf8')
req.on('data', function (str) {
data += str
})
onFinished(req, function (err, req) {
// data is read unless there is an error
})
The package also provides functions to test if a request or response has already finished. These are used like 'onFinished.isFinished(res)' or 'onFinished.isFinished(req)'.
Documentation for the on-finished npm package can be found directly in the readme file on the package's official GitHub page - https://github.com/jshttp/on-finished.git. This readme provides complete documentation on how to install and use the package, along with specifics of its API and some examples of its usage.