From 5de85c69df8aee71d4f636f6d5e7ae424d2e0efa Mon Sep 17 00:00:00 2001 From: Irfan Erol Date: Thu, 24 Mar 2022 22:01:12 +0300 Subject: [PATCH] parseAsync --- index.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/index.js b/index.js index c57032e..4e697aa 100644 --- a/index.js +++ b/index.js @@ -88,6 +88,22 @@ function Form(options) { }); } +Form.prototype.parseAsync = function (req) { + let t = this; + return new Promise((resolve,reject) => { + t.parse(req, function (err, fields, files) { + if (err) { + return reject(err); + } else { + return resolve({ + fields: fields, + files: files + }); + } + }); + }); +} + Form.prototype.parse = function(req, cb) { var called = false; var self = this;