Skip to content

Commit

Permalink
Merge pull request #1 from slaviczavik/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
slaviczavik authored Nov 25, 2019
2 parents 3a17e68 + b5f503d commit 6b49dab
Show file tree
Hide file tree
Showing 10 changed files with 2,702 additions and 278 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: node_js

node_js:
- "6.14.3"
- "7"
- "8"
- "10"
- "11"
- "12"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const HttpDataParser = require('@slaviczavik/http-data-parser')

// A boundary must be extracted from 'content-type' request header.
const boundary '--------------------------034172598905589540726558'
const parser = new HttpDataParser(boundary)
const parser = HttpDataParser(boundary)

parser.on('header', function (data, isLast) {
// Save headers somewhere...
Expand Down Expand Up @@ -55,7 +55,7 @@ req.on('end', function () {
# API

## Constructor
### `new HttpDataParser(boundary)`
### `HttpDataParser(boundary)`

| Name | Required | Type | Description | Default
| - | - | - | - | - |
Expand Down
20 changes: 10 additions & 10 deletions benchmark/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
const Parser = require('../lib/')
const Parser = require('../src/')

const boundary = '--------------------------034172598905589540726558'
const parser = new Parser(boundary)
const parser = Parser(boundary)

const MB = 100
const buffer = createMultipartBuffer(boundary, MB * 1024 * 1024)

let start = +new Date()
const start = +new Date()

parser.on('end', function () {
let duration = +new Date() - start
let ratio = (MB / (duration / 1000)).toFixed(2)
const duration = +new Date() - start
const ratio = (MB / (duration / 1000)).toFixed(2)

console.log(`${ratio} MB/s`)
})
Expand All @@ -19,10 +19,10 @@ parser.write(buffer)
parser.end()

function createMultipartBuffer (boundary, size) {
let head = Buffer.from('--' + boundary + '\r\n')
let body = Buffer.from('Content-Disposition: form-data; name="field"\r\n\r\n')
let tail = Buffer.from('\r\n--' + boundary + '--\r\n')
let buff = Buffer.allocUnsafe(size)
const head = Buffer.from('--' + boundary + '\r\n')
const body = Buffer.from('Content-Disposition: form-data; name="field"\r\n\r\n')
const tail = Buffer.from('\r\n--' + boundary + '--\r\n')
const buff = Buffer.allocUnsafe(size)

return Buffer.concat([ head, body, buff, tail ])
return Buffer.concat([head, body, buff, tail])
}
110 changes: 0 additions & 110 deletions lib/index.js

This file was deleted.

Loading

0 comments on commit 6b49dab

Please sign in to comment.