then-busboy
Advanced tools
Comparing version 1.0.4 to 1.1.0
22
main.js
"use strict"; | ||
var Busboy, IncomingMessage, Promise, Readable, assign, createReadStream, createWriteStream, extname, extractKeys, getObjFields, includes, isPlainObject, mapListeners, merge, reduceRight, reducer, ref, rescueObjStruct, rescueTypes, shortid, thenBusboy, tmpDir, | ||
slice = [].slice; | ||
var Busboy, FieldsLimitException, FilesLimitException, IncomingMessage, PartsLimitException, Promise, Readable, assign, createReadStream, createWriteStream, extname, extractKeys, getObjFields, includes, isPlainObject, mapListeners, merge, reduceRight, reducer, ref, ref1, rescueObjStruct, rescueTypes, shortid, thenBusboy, tmpDir, | ||
slice = [].slice, | ||
hasProp = {}.hasOwnProperty; | ||
@@ -21,2 +22,4 @@ Promise = require("pinkie-promise"); | ||
ref1 = require("./errors"), PartsLimitException = ref1.PartsLimitException, FieldsLimitException = ref1.FieldsLimitException, FilesLimitException = ref1.FilesLimitException; | ||
isPlainObject = require("lodash.isplainobject"); | ||
@@ -46,2 +49,3 @@ | ||
for (__name in listeners) { | ||
if (!hasProp.call(listeners, __name)) continue; | ||
__handler = listeners[__name]; | ||
@@ -191,3 +195,3 @@ fn(__name, __handler); | ||
return new Promise(function(resolve, reject) { | ||
var bb, fields, files, listeners, onError, onField, onFile; | ||
var bb, fields, files, listeners, onError, onField, onFieldsLimit, onFile, onFilesLimit, onPartsLimit; | ||
if (!(req instanceof IncomingMessage)) { | ||
@@ -234,2 +238,11 @@ throw new TypeError("Request parameter must be an instance of http.IncomingMessage."); | ||
}; | ||
onPartsLimit = function() { | ||
return onError(new PartsLimitException("Parts limit reached")); | ||
}; | ||
onFieldsLimit = function() { | ||
return onError(new FieldsLimitException("Fields limit reached")); | ||
}; | ||
onFilesLimit = function() { | ||
return onError(new FilesLimitException("Files limit reached")); | ||
}; | ||
listeners = { | ||
@@ -239,2 +252,5 @@ error: onError, | ||
file: onFile, | ||
partsLimit: onPartsLimit, | ||
filesLimit: onFilesLimit, | ||
fieldsLimit: onFieldsLimit, | ||
finish: function() { | ||
@@ -241,0 +257,0 @@ mapListeners(listeners, bb.removeListener.bind(bb)); |
{ | ||
"name": "then-busboy", | ||
"version": "1.0.4", | ||
"version": "1.1.0", | ||
"description": "Promise-based wrapper around Busboy, inspired by async-busboy", | ||
@@ -16,5 +16,5 @@ "main": "main.js", | ||
"tw": "npm run test:watch", | ||
"make": "./node_modules/coffee-script/bin/coffee --no-header -b -c main.coffee & ./node_modules/coffee-script/bin/coffee --no-header -b -c test.coffee & ./node_modules/coffee-script/bin/coffee --no-header -b -c example.coffee", | ||
"make": "./node_modules/coffee-script/bin/coffee --no-header -b -c main.coffee & ./node_modules/coffee-script/bin/coffee --no-header -b -c test.coffee & ./node_modules/coffee-script/bin/coffee --no-header -b -c example.coffee & ./node_modules/coffee-script/bin/coffee --no-header -b -c errors.coffee", | ||
"m": "npm run make", | ||
"watch": "./node_modules/coffee-script/bin/coffee --no-header -b -w -c main.coffee & ./node_modules/coffee-script/bin/coffee --no-header -b -w -c test.coffee & ./node_modules/coffee-script/bin/coffee --no-header -b -w -c example.coffee", | ||
"watch": "./node_modules/coffee-script/bin/coffee --no-header -b -w -c main.coffee & ./node_modules/coffee-script/bin/coffee --no-header -b -w -c test.coffee & ./node_modules/coffee-script/bin/coffee --no-header -b -w -c example.coffee & ./node_modules/coffee-script/bin/coffee --no-header -b -w -c errors.coffee", | ||
"w": "npm run watch" | ||
@@ -36,3 +36,4 @@ }, | ||
"coffee-script": "git+https://github.com/octet-stream/coffeescript.git", | ||
"istanbul": "0.4.5" | ||
"istanbul": "0.4.5", | ||
"supertest": "2.0.0" | ||
}, | ||
@@ -39,0 +40,0 @@ "repository": { |
@@ -5,4 +5,5 @@ # then-busboy | ||
[![dependencies Status](https://david-dm.org/octet-stream/then-busboy/status.svg?style=flat-square)](https://david-dm.org/octet-stream/then-busboy) | ||
[![devDependencies Status](https://david-dm.org/octet-stream/then-busboy/dev-status.svg?style=flat-square)](https://david-dm.org/octet-stream/then-busboy?type=dev) | ||
[![dependencies Status](https://david-dm.org/octet-stream/then-busboy/status.svg)](https://david-dm.org/octet-stream/then-busboy) | ||
[![devDependencies Status](https://david-dm.org/octet-stream/then-busboy/dev-status.svg)](https://david-dm.org/octet-stream/then-busboy?type=dev) | ||
[![Build Status](https://travis-ci.org/octet-stream/then-busboy.svg?branch=master)](https://travis-ci.org/octet-stream/then-busboy) | ||
@@ -9,0 +10,0 @@ ## Installation |
Sorry, the diff of this file is not supported yet
14171
7
279
90
4