Skip to content

Commit

Permalink
Replacing home brewed arity detection for Function.prototype.length
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed Oct 20, 2017
1 parent fc3bf50 commit e832c1d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion lib/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@

module.exports = {
escape: arg => arg.replace(/[-[\]\/{}()*+?.,\\^$|#]/g, "\\$&"),
getArity: arg => arg.toString().replace(/(^.*\()|(\).*)|(\n.*)/g, "").split(",").length,
schemeless: arg => arg.replace(/^.*:\/\//, "")
};
4 changes: 2 additions & 2 deletions lib/woodland.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ class Woodland {
process.nextTick(() => {
if (res.headersSent === false) {
let iter = middleware.next(),
arity = iter.done === false ? utility.getArity(iter.value) : 0;
arity = iter.done === false ? iter.value.length : 0;

if (iter.done === false) {
if (err !== void 0) {
do {
arity = utility.getArity(iter.value);
arity = iter.value.length;
} while (arity < 4 && (iter = middleware.next()) && iter.done === false);
}

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "woodland",
"version": "3.0.2",
"version": "3.0.3",
"description": "Lightweight HTTP/HTTPS router with automatic `Allow` & `CORS` headers",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit e832c1d

Please sign in to comment.