{"id":18317946,"url":"https://github.com/idiocc/dicer","last_synced_at":"2025-06-13T19:05:35.901Z","repository":{"id":57117471,"uuid":"194381680","full_name":"idiocc/dicer","owner":"idiocc","description":"[fork] A Very Fast Streaming Multipart Parser For Node.JS Written In ES6 And Optimised With JavaScript Compiler.","archived":false,"fork":false,"pushed_at":"2019-12-24T06:07:53.000Z","size":77,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-05-11T10:04:30.051Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://idio.cc","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/idiocc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-06-29T08:16:06.000Z","updated_at":"2019-12-24T06:07:57.000Z","dependencies_parsed_at":"2022-08-23T05:20:58.046Z","dependency_job_id":null,"html_url":"https://github.com/idiocc/dicer","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/idiocc/dicer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiocc%2Fdicer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiocc%2Fdicer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiocc%2Fdicer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiocc%2Fdicer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/idiocc","download_url":"https://codeload.github.com/idiocc/dicer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiocc%2Fdicer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259436511,"owners_count":22857154,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T18:07:57.188Z","updated_at":"2025-06-13T19:05:35.870Z","avatar_url":"https://github.com/idiocc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @idio/dicer\n\n[![npm version](https://badge.fury.io/js/%40idio%2Fdicer.svg)](https://www.npmjs.com/package/@idio/dicer)\n\n`@idio/dicer` is a [fork](https://github.com/mscdex/dicer) of A Very Fast Streaming Multipart Parser For Node.JS Written In ES6 And Optimised With [JavaScript Compiler](https://compiler.page).\n\n```sh\nyarn add @idio/dicer\n```\n\n## Table Of Contents\n\n- [Table Of Contents](#table-of-contents)\n- [API](#api)\n- [`class Dicer`](#class-dicer)\n  * [`_idio.DicerConfig`](#type-_idiodicerconfig)\n  * [`_idio.Dicer`](#type-_idiodicer)\n- [Copyright](#copyright)\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\n  \u003cimg src=\"/.documentary/section-breaks/0.svg?sanitize=true\"\u003e\n\u003c/a\u003e\u003c/p\u003e\n\n## API\n\nThe package is available by importing its default function:\n\n```js\nimport Dicer from '@idio/dicer'\n```\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\n  \u003cimg src=\"/.documentary/section-breaks/1.svg?sanitize=true\"\u003e\n\u003c/a\u003e\u003c/p\u003e\n\n## `class Dicer`\n\nDicer is a _Writable_ stream.\n\n`import('stream').WritableOptions` __\u003ca name=\"type-streamwritableoptions\"\u003e`stream.WritableOptions`\u003c/a\u003e__\n\n\u003cstrong\u003e\u003ca name=\"type-_idiodicerconfig\"\u003e`_idio.DicerConfig`\u003c/a\u003e extends [`stream.WritableOptions`](#type-streamwritableoptions)\u003c/strong\u003e: Options for the program.\n\n|      Name      |       Type       |                           Description                            | Default |\n| -------------- | ---------------- | ---------------------------------------------------------------- | ------- |\n| boundary       | \u003cem\u003estring\u003c/em\u003e  | This is the boundary used to detect the beginning of a new part. | -       |\n| headerFirst    | \u003cem\u003eboolean\u003c/em\u003e | If true, preamble header parsing will be performed first.        | `false` |\n| partHwm        | \u003cem\u003eboolean\u003c/em\u003e | High watermark for parsing parts.                                | -       |\n| maxHeaderPairs | \u003cem\u003enumber\u003c/em\u003e  | The maximum number of header key=\u0026gt;value pairs to parse.       | `2000`  |\n\n\u003cstrong\u003e\u003ca name=\"type-_idiodicer\"\u003e`_idio.Dicer`\u003c/a\u003e\u003c/strong\u003e\n\n|      Name       |                                                                       Type                                                                       |                                                                                                              Description                                                                                                              |\n| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| __constructor__ | \u003cem\u003enew (cfg?: \u003ca href=\"#type-_idiodicerconfig\" title=\"Options for the program.\"\u003e!_idio.DicerConfig\u003c/a\u003e) =\u003e [_idio.Dicer](#type-_idiodicer)\u003c/em\u003e | Creates a new instance.                                                                                                                                                                                                               |\n| __setBoundary__ | \u003cem\u003e(boundary: string) =\u003e void\u003c/em\u003e                                                                                                              | 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| ___ignore__     | \u003cem\u003e() =\u003e void\u003c/em\u003e                                                                                                                              | Ignores current part.                                                                                                                                                                                                                 |\n\n```js\nimport Dicer from '@idio/dicer'\nimport { createServer } from 'http'\nimport { inspect } from 'util'\n\nconst RE_BOUNDARY = /^multipart\\/.+?(?:; boundary=(?:(?:\"(.+)\")|(?:([^\\s]+))))$/i,\n  HTML = Buffer.from('\u003chtml\u003e\u003chead\u003e\u003c/head\u003e\u003cbody\u003e\\\n                        \u003cform method=\"POST\" enctype=\"multipart/form-data\"\u003e\\\n                         \u003cinput type=\"text\" name=\"textfield\"\u003e\u003cbr /\u003e\\\n                         \u003cinput type=\"file\" name=\"filefield\"\u003e\u003cbr /\u003e\\\n                         \u003cinput type=\"submit\"\u003e\\\n                        \u003c/form\u003e\\\n                        \u003c/body\u003e\u003c/html\u003e'),\n  PORT = 8080\n\ncreateServer(function(req, res) {\n  var m\n  if (req.method === 'POST'\n      \u0026\u0026 req.headers['content-type']\n      \u0026\u0026 (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' \u0026\u0026 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  this.close()\n})\n```\n```\nListening for requests on port 8080\n```\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\n  \u003cimg src=\"/.documentary/section-breaks/2.svg?sanitize=true\"\u003e\n\u003c/a\u003e\u003c/p\u003e\n\n## Copyright\n\nOriginal Work by [Brian White aka mscdex](https://github.com/mscdex/dicer).\n\n---\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003cth\u003e\n      \u003ca href=\"https://artd.eco\"\u003e\n        \u003cimg width=\"100\" src=\"https://raw.githubusercontent.com/wrote/wrote/master/images/artdeco.png\"\n          alt=\"Art Deco\"\u003e\n      \u003c/a\u003e\n    \u003c/th\u003e\n    \u003cth\u003e© \u003ca href=\"https://artd.eco\"\u003eArt Deco\u003c/a\u003e for \u003ca href=\"https://idio.cc\"\u003eIdio\u003c/a\u003e 2019\u003c/th\u003e\n    \u003cth\u003e\n      \u003ca href=\"https://idio.cc\"\u003e\n        \u003cimg src=\"https://avatars3.githubusercontent.com/u/40834161?s=100\" width=\"100\" alt=\"Idio\"\u003e\n      \u003c/a\u003e\n    \u003c/th\u003e\n    \u003cth\u003e\n      \u003ca href=\"https://www.technation.sucks\" title=\"Tech Nation Visa\"\u003e\n        \u003cimg width=\"100\" src=\"https://raw.githubusercontent.com/idiocc/cookies/master/wiki/arch4.jpg\"\n          alt=\"Tech Nation Visa\"\u003e\n      \u003c/a\u003e\n    \u003c/th\u003e\n    \u003cth\u003e\u003ca href=\"https://www.technation.sucks\"\u003eTech Nation Visa Sucks\u003c/a\u003e\u003c/th\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\n  \u003cimg src=\"/.documentary/section-breaks/-1.svg?sanitize=true\"\u003e\n\u003c/a\u003e\u003c/p\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidiocc%2Fdicer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidiocc%2Fdicer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidiocc%2Fdicer/lists"}