-
Notifications
You must be signed in to change notification settings - Fork 5
/
package.json
50 lines (50 loc) · 4.73 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{
"name": "dicer",
"version": "0.2.3",
"author": {
"name": "Brian White",
"email": "mscdex@mscdex.net"
},
"description": "A very fast streaming multipart parser for node.js",
"main": "./lib/Dicer",
"dependencies": {
"streamsearch": "0.1.2",
"readable-stream": "1.1.x"
},
"scripts": {
"test": "node test/test.js"
},
"engines": {
"node": ">=0.8.0"
},
"keywords": [
"parser",
"parse",
"parsing",
"multipart",
"form-data",
"streaming"
],
"licenses": [
{
"type": "MIT",
"url": "http://github.com/mscdex/dicer/raw/master/LICENSE"
}
],
"repository": {
"type": "git",
"url": "http://github.com/mscdex/dicer.git"
},
"readme": "\nDescription\n===========\n\nA very fast streaming multipart parser for node.js.\n\nBenchmarks can be found [here](https://github.com/mscdex/dicer/wiki/Benchmarks).\n\n\nRequirements\n============\n\n* [node.js](http://nodejs.org/) -- v0.8.0 or newer\n\n\nInstall\n============\n\n npm install dicer\n\n\nExamples\n========\n\n* Parse an HTTP form upload\n\n```javascript\nvar inspect = require('util').inspect,\n http = require('http');\n\nvar Dicer = require('dicer');\n\n // quick and dirty way to parse multipart boundary\nvar RE_BOUNDARY = /^multipart\\/.+?(?:; boundary=(?:(?:\"(.+)\")|(?:([^\\s]+))))$/i,\n HTML = new Buffer('<html><head></head><body>\\\n <form method=\"POST\" enctype=\"multipart/form-data\">\\\n <input type=\"text\" name=\"textfield\"><br />\\\n <input type=\"file\" name=\"filefield\"><br />\\\n <input type=\"submit\">\\\n </form>\\\n </body></html>'),\n PORT = 8080;\n\nhttp.createServer(function(req, res) {\n var m;\n if (req.method === 'POST'\n && req.headers['content-type']\n && (m = RE_BOUNDARY.exec(req.headers['content-type']))) {\n var d = new Dicer({ boundary: m[1] || m[2] });\n\n d.on('part', function(p) {\n console.log('New part!');\n p.on('header', function(header) {\n for (var h in header) {\n console.log('Part header: k: ' + inspect(h)\n + ', v: ' + inspect(header[h]));\n }\n });\n p.on('data', function(data) {\n console.log('Part data: ' + inspect(data.toString()));\n });\n p.on('end', function() {\n console.log('End of part\\n');\n });\n });\n d.on('finish', function() {\n console.log('End of parts');\n res.writeHead(200);\n res.end('Form submission successful!');\n });\n req.pipe(d);\n } else if (req.method === 'GET' && req.url === '/') {\n res.writeHead(200);\n res.end(HTML);\n } else {\n res.writeHead(404);\n res.end();\n }\n}).listen(PORT, function() {\n console.log('Listening for requests on port ' + PORT);\n});\n```\n\n\nAPI\n===\n\n_Dicer_ is a _WritableStream_\n\nDicer (special) events\n----------------------\n\n* **end**() - Emitted when all parts have been parsed.\n\n* **part**(< _PartStream_ >stream) - Emitted when a new part has been found.\n\n* **preamble**(< _PartStream_ >stream) - Emitted for preamble if you should happen to need it (can usually be ignored).\n\n* **trailer**(< _Buffer_ >data) - Emitted when trailing data was found after the terminating boundary (as with the preamble, this can usually be ignored too).\n\n\nDicer methods\n-------------\n\n* **(constructor)**(< _object_ >config) - Creates and returns a new Dicer instance with the following valid `config` settings:\n\n * **boundary** - _string_ - This is the boundary used to detect the beginning of a new part.\n\n * **headerFirst** - _boolean_ - If true, preamble header parsing will be performed first.\n\n * **maxHeaderPairs** - _integer_ - The maximum number of header key=>value pairs to parse **Default:** 2000 (same as node's http).\n\n* **setBoundary**(< _string_ >boundary) - _(void)_ - Sets the boundary to use for parsing and performs some initialization needed for parsing. You should only need to use this if you set `headerFirst` to true in the constructor and are parsing the boundary from the preamble header.\n\n\n\n_PartStream_ is a _ReadableStream_\n\nPartStream (special) events\n---------------------------\n\n* **header**(< _object_ >header) - An object containing the header for this particular part. Each property value is an _array_ of one or more string values.\n",
"readmeFilename": "README.md",
"bugs": {
"url": "https://github.com/mscdex/dicer/issues"
},
"homepage": "https://github.com/mscdex/dicer",
"_id": "dicer@0.2.3",
"dist": {
"shasum": "287bec65f8d6ce8920133dfea3a57a22927deeaf"
},
"_from": "dicer@0.2.3",
"_resolved": "https://registry.npmjs.org/dicer/-/dicer-0.2.3.tgz"
}