Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

then-busboy

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

then-busboy - npm Package Compare versions

Comparing version 4.2.0 to 4.3.0

lib/Body.mjs

17

lib/File.js

@@ -8,5 +8,5 @@ "use strict";

var _path = require("path");
var _path = _interopRequireDefault(require("path"));
var _fs = require("fs");
var _fs = _interopRequireDefault(require("fs"));

@@ -78,3 +78,3 @@ var _invariant = _interopRequireDefault(require("@octetstream/invariant"));

this.contents.on("error", reject).on("end", resolve).pipe((0, _fs.createWriteStream)(path || this.path));
this.contents.on("error", reject).on("end", resolve).pipe(_fs.default.createWriteStream(path || this.path));
}));

@@ -90,3 +90,3 @@

(0, _invariant.default)(!contents, "File contents required.");
(0, _invariant.default)(!(contents instanceof _fs.ReadStream), TypeError, "Contents should be a ReadStream stream. Received %s", (0, _getType.default)(contents));
(0, _invariant.default)(!(contents instanceof _fs.default.ReadStream), TypeError, "Contents should be a ReadStream stream. Received %s", (0, _getType.default)(contents));
(0, _invariant.default)(!filename, "Filename required.");

@@ -98,7 +98,10 @@ (0, _invariant.default)(!(0, _isString.default)(filename), TypeError, "Filename should be a string. Received %s", (0, _getType.default)(filename));

(0, _invariant.default)(!(0, _isString.default)(mime), TypeError, "File mime type should be a string. Received %s", (0, _getType.default)(mime));
const ext = (0, _path.extname)(filename);
const base = (0, _path.basename)(filename, ext);
const ext = _path.default.extname(filename);
const base = _path.default.basename(filename, ext);
this.__contents = contents;
this.__stream = contents;
this.__filename = (0, _path.basename)(filename);
this.__filename = _path.default.basename(filename);
this.__basename = base;

@@ -105,0 +108,0 @@ this.__extname = ext;

@@ -8,7 +8,7 @@ "use strict";

var _fs = require("fs");
var _os = _interopRequireDefault(require("os"));
var _path = require("path");
var _fs = _interopRequireDefault(require("fs"));
var _os = require("os");
var _path = _interopRequireDefault(require("path"));

@@ -34,7 +34,8 @@ var _nanoid = _interopRequireDefault(require("nanoid"));

try {
const path = (0, _getFieldPath.default)(fieldname);
filename = (0, _path.join)((0, _os.tmpdir)(), `${(0, _nanoid.default)()}__${filename}`);
const fieldPath = (0, _getFieldPath.default)(fieldname);
filename = _path.default.join(_os.default.tmpdir(), `${(0, _nanoid.default)()}__${filename}`);
function onEnd() {
const contents = (0, _fs.createReadStream)(filename);
const contents = _fs.default.createReadStream(filename);
const file = new _File.default({

@@ -46,3 +47,3 @@ filename,

});
cb(null, [path, file]);
cb(null, [fieldPath, file]);
}

@@ -52,3 +53,3 @@

stream.once("error", cb).once("end", onEnd).once("limit", onLimit).pipe((0, _fs.createWriteStream)(filename));
stream.once("error", cb).once("end", onEnd).once("limit", onLimit).pipe(_fs.default.createWriteStream(filename));
} catch (err) {

@@ -55,0 +56,0 @@ return cb(err);

@@ -8,6 +8,4 @@ "use strict";

var _http = require("http");
var _http = _interopRequireDefault(require("http"));
var _path = require("path");
var _busboy = _interopRequireDefault(require("busboy"));

@@ -19,4 +17,2 @@

var _readListeners = _interopRequireDefault(require("./util/readListeners"));
var _arrayRunWaterfall = _interopRequireDefault(require("./util/arrayRunWaterfall"));

@@ -32,5 +28,21 @@

var _onFile = _interopRequireDefault(require("./listener/onFile"));
var _onField = _interopRequireDefault(require("./listener/onField"));
var _onFilesLimit = _interopRequireDefault(require("./listener/onFilesLimit"));
var _onPartsLimit = _interopRequireDefault(require("./listener/onPartsLimit"));
var _onFieldsLimit = _interopRequireDefault(require("./listener/onFieldsLimit"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const initializers = (0, _readListeners.default)((0, _path.join)(__dirname, "listener"));
const initializers = {
onFile: _onFile.default,
onField: _onField.default,
onFilesLimit: _onFilesLimit.default,
onPartsLimit: _onPartsLimit.default,
onFieldsLimit: _onFieldsLimit.default
};
const defaults = {

@@ -86,3 +98,3 @@ restoreTypes: true

* // Simplest Koa.js middleware:
* import busboy, {Body} from "then-busboy"
* import {parse, Body} from "then-busboy"
*

@@ -110,3 +122,3 @@ * const toLowerCase = string => String.prototype.toLowerCase.call(string)

async function parse(request, options = {}) {
(0, _invariant.default)(!(request instanceof _http.IncomingMessage), TypeError, "Request must be an instance of http.IncomingMessage. Received %s", (0, _getType.default)(request));
(0, _invariant.default)(!(request instanceof _http.default.IncomingMessage), TypeError, "Request must be an instance of http.IncomingMessage. Received %s", (0, _getType.default)(request));
(0, _invariant.default)(!(0, _isPlainObject.default)(options), TypeError, "Options must be an object. Received %s", (0, _getType.default)(options));

@@ -113,0 +125,0 @@ options = (0, _lodash.default)({}, defaults, options, {

@@ -81,6 +81,4 @@ "use strict";

var _File = _interopRequireWildcard(require("./lib/File"));
var _File = _interopRequireDefault(require("./lib/File"));
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
{
"name": "then-busboy",
"description": "Promise-based wrapper around Busboy. Processes multipart/form-data content and returns it as a single object.",
"version": "4.2.0",
"version": "4.3.0",
"author": "Nick K. <nick.kruchinin@gmail.com>",
"license": "MIT",
"repository": "octet-stream/then-busboy",
"main": "./main.js",
"main": "main",
"engines": {
"node": ">= 8"
"node": ">= 8.9.4 < 9 || >= 10"
},

@@ -23,18 +23,20 @@ "keywords": [

"scripts": {
"eslint": "node_modules/.bin/eslint src",
"staged": "node_modules/.bin/lint-staged",
"make": "node_modules/.bin/babel src -d .",
"watch": "node_modules/.bin/babel src -w -d .",
"make:ci": "node_modules/.bin/babel src -s -d .",
"m": "yarn make",
"w": "yarn watch",
"cleanup": "node_modules/.bin/rimraf lib test main.js main.js.map",
"test": "node_modules/.bin/ava",
"coverage": "node_modules/.bin/nyc npm run test",
"report": "yarn make:ci && yarn coverage && node_modules/.bin/nyc report --reporter=html yarn test && yarn cleanup && yarn make",
"report:ci": "node_modules/.bin/nyc report --reporter=lcov yarn test",
"codecov": "node_modules/.bin/codecov",
"ci": "yarn make:ci && yarn coverage && yarn report:ci && yarn codecov",
"precommit": "yarn staged",
"prepush": "yarn make:ci && yarn coverage && yarn cleanup && yarn make"
"eslint": "eslint src",
"staged": "lint-staged",
"make": "babel src -d .",
"make:esm": "BABEL_ESM=1 babel src -d . --keep-file-extension",
"prepare": "npm run cleanup && npm run make && npm run make:esm",
"watch": "babel src -w -d .",
"make:test": "babel src -s -d .",
"cleanup": "rimraf lib test main.js main.js.map",
"test:cleanup": "npm run cleanup && npm run make:spec && ava && npm run cleanup && npm run prepare",
"test": "ava",
"m": "npm run make",
"p": "npm run prepare",
"w": "npm run watch",
"t": "npm run test",
"coverage": "nyc npm run test",
"report": "npm run make:test && npm run coverage && nyc report --reporter=html npm run test && npm run cleanup && npm run prepare",
"report:codecov": "nyc report --reporter=lcov npm run test",
"ci": "npm run make:test && npm run coverage && npm run report:codecov && codecov"
},

@@ -56,4 +58,4 @@ "ava": {

"@octetstream/invariant": "1.2.0",
"busboy": "0.3.0",
"formdata-node": "1.3.0",
"busboy": "0.3.1",
"formdata-node": "1.5.2",
"lodash.merge": "4.6.1",

@@ -64,25 +66,25 @@ "nanoid": "2.0.1",

"devDependencies": {
"@babel/cli": "7.2.3",
"@babel/core": "7.2.2",
"@babel/plugin-proposal-class-properties": "7.3.0",
"@babel/plugin-proposal-decorators": "7.3.0",
"@babel/cli": "7.4.3",
"@babel/core": "7.4.3",
"@babel/plugin-proposal-class-properties": "7.4.0",
"@babel/plugin-proposal-decorators": "7.4.0",
"@babel/plugin-proposal-export-default-from": "7.2.0",
"@babel/plugin-proposal-object-rest-spread": "7.3.1",
"@babel/plugin-transform-modules-commonjs": "7.2.0",
"@babel/plugin-proposal-object-rest-spread": "7.4.3",
"@babel/plugin-transform-modules-commonjs": "7.4.3",
"@octetstream/eslint-config": "3.0.0",
"ava": "0.25.x",
"babel-plugin-module-resolver": "3.1.3",
"codecov": "3.1.0",
"eslint": "5.12.1",
"eslint-import-resolver-babel-module": "5.0.0",
"eslint-plugin-ava": "5.1.1",
"ava": "1.4.1",
"babel-plugin-module-resolver": "3.2.0",
"codecov": "3.3.0",
"eslint": "5.16.0",
"eslint-import-resolver-babel-module": "5.0.1",
"eslint-plugin-ava": "6.0.0",
"husky": "1.3.1",
"lint-staged": "8.1.0",
"nyc": "13.1.0",
"promise-fs": "2.0.1",
"lint-staged": "8.1.5",
"nyc": "13.3.0",
"promise-fs": "2.1.0",
"proxyquire": "2.1.0",
"rimraf": "2.6.3",
"sinon": "7.2.3",
"supertest": "3.4.2"
"sinon": "7.3.1",
"supertest": "4.0.2"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc