From 383285ecd5292bf9a825e05904955b937de84cc9 Mon Sep 17 00:00:00 2001 From: Minteck Date: Sat, 4 Jun 2022 08:51:01 +0200 Subject: Initial commit --- node_modules/body/parse-arguments.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 node_modules/body/parse-arguments.js (limited to 'node_modules/body/parse-arguments.js') diff --git a/node_modules/body/parse-arguments.js b/node_modules/body/parse-arguments.js new file mode 100644 index 0000000..5c36ff7 --- /dev/null +++ b/node_modules/body/parse-arguments.js @@ -0,0 +1,30 @@ +module.exports = parseArguments + +function isWritable(stream) { + return typeof stream.write === "function" && + typeof stream.end === "function" +} + +function parseArguments(req, res, opts, callback) { + // (req, cb) + if (typeof res === "function") { + callback = res + opts = {} + res = null + } + + // (req, res, cb) + if (typeof opts === "function") { + callback = opts + opts = {} + } + + // (req, opts, cb) + if (res && !isWritable(res)) { + opts = res + res = null + } + + // default (req, res, opts, cb) + return { req: req, res: res, opts: opts, callback: callback } +} -- cgit