{"name":"dicer","version":"0.3.1","author":{"name":"Brian White","email":"mscdex@mscdex.net"},"description":"A very fast streaming multipart parser for node.js","main":"./lib/Dicer.js","dependencies":{"streamsearch":"^1.1.0"},"devDependencies":{"@mscdex/eslint-config":"^1.1.0","eslint":"^7.32.0"},"scripts":{"test":"node test/test.js","lint":"eslint --cache --report-unused-disable-directives --ext=.js .eslintrc.js lib test","lint:fix":"npm run lint -- --fix"},"engines":{"node":">=10.0.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":"git+ssh://git@github.com/mscdex/dicer.git"},"_resolved":"","_integrity":"","_from":"https://github.com/mscdex/dicer/tarball/v0.3.1","bugs":{"url":"https://github.com/mscdex/dicer/issues"},"homepage":"https://github.com/mscdex/dicer#readme","_id":"dicer@0.3.1","_nodeVersion":"10.22.1","_npmVersion":"6.14.6","dist":{"integrity":"sha512-ObioMtXnmjYs3aRtpIJt9rgQSPCIhKVkFPip+E9GUDyWl8N435znUxK/JfNwGZJ2wnn5JKQ7Ly3vOK5Q5dylGA==","shasum":"abf28921e3475bc5e801e74e0159fd94f927ba97","tarball":"http://registry-npm.ywwl.com/dicer/download/dicer-0.3.1.tgz","fileCount":71,"unpackedSize":48301,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhv4SuCRA9TVsSAnZWagAARC8QAKJXmCXR4iQbj1/8V5qn\n2pD5zQypo0BmRAn9lq7yEDn+kUrOwyA/dBYJVVu1+poZ6K/bgUzqdRUqMRnM\nrxqUdyr6lUqx0o+F/S95ywRhvurPPRSMwaDsuJLnJzxO70b0GfNT+IpnNd0S\ntOiFBaxxGt4tWZbZ/KkPzB+YTeBImN2DfLp8SeyiOybxAZ8m4IoIow+hKNj8\nxZhzl0cEluuHZQm8c8yNFkxUlp88FdAuS2RVTw0CBPEYt7tbYgcALXOWbgtS\nTE/5wWixLfrfsE0itWy6VDOxm4aCqkfEO5vLWYxDDCBsEHFdKALq7340Z/DA\nwBWu1BohhaSjrDzh/XayyTZpMKGaJBAsxGjrH7gbshgtRv0D73mt96DzwrlT\nJOhkJPpWcvF15m6rXdVq+NiqdaAW5mASYwJIuxiv0BCM70ewfHTvBsA5uqbn\n3TTwE5xpdisiHKc/NlTnex/FfBFl+BZV3J44zaxCj8JGr6Bg7w1KGl9xqe+m\nqPoVbBD7K8dyMDW3pPSJKkXS3t+Z+MWA0de/soT03DcekW988bOdHzasYleV\nKX711GeUNHl2QjdxnGDKz+Vds8wsUIATPxbh3Bn7218nUL+LO0zd+164GClq\nXmA6m5FDqrHdPqYCDavqHTix5J2hg9rfCBrd6nY1KOSnraJj9KMHdxBJcLxg\ngZE7\r\n=58FB\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEWIUqGpp1Z1yqa2UqEu7UNxztq1cDkEuTGULwov/OZHAiBbAUySr25vHMYhPLhVWMDsdGk4mKESixz3lgXaEWXrJw=="}],"size":12209,"noattachment":false,"key":"/dicer/-/dicer-0.3.1.tgz"},"_npmUser":{"name":"mscdex","email":"mscdex@mscdex.net"},"directories":{},"maintainers":[{"name":"mscdex","email":"mscdex@mscdex.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dicer_0.3.1_1639941293920_0.3047678125651829"},"_hasShrinkwrap":false,"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/) -- v10.0.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```js\nconst { inspect } = require('util');\nconst http = require('http');\n\nconst Dicer = require('dicer');\n\n// Quick and dirty way to parse multipart boundary\nconst RE_BOUNDARY =\n  /^multipart\\/.+?(?:; boundary=(?:(?:\"(.+)\")|(?:([^\\s]+))))$/i;\nconst HTML = Buffer.from(`\n  <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`);\nconst PORT = 8080;\n\nhttp.createServer((req, res) => {\n  let m;\n  if (req.method === 'POST'\n      && req.headers['content-type']\n      && (m = RE_BOUNDARY.exec(req.headers['content-type']))) {\n    const d = new Dicer({ boundary: m[1] || m[2] });\n\n    d.on('part', (p) => {\n      console.log('New part!');\n      p.on('header', (header) => {\n        for (const h in header) {\n          console.log(\n            `Part header: k: ${inspect(h)}, v: ${inspect(header[h])}`\n          );\n        }\n      });\n      p.on('data', (data) => {\n        console.log(`Part data: ${inspect(data.toString())}`);\n      });\n      p.on('end', () => {\n        console.log('End of part\\n');\n      });\n    });\n    d.on('finish', () => {\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, () => {\n  console.log(`Listening for requests on port ${PORT}`);\n});\n```\n\n\nAPI\n===\n\n_Dicer_ is a _Writable_ stream\n\nDicer (special) events\n----------------------\n\n* **finish**() - Emitted when all parts have been parsed and the Dicer instance has been ended.\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 _Readable_ stream\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","publish_time":1639941294059,"_cnpm_publish_time":1639941294059,"dist-tags":{"latest":"0.3.1"}}