Skip to content

Commit

Permalink
Replacing undefined with void 0
Browse files Browse the repository at this point in the history
  • Loading branch information
avoidwork committed May 28, 2017
1 parent 4a42240 commit 8128cc7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions lib/woodland.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Woodland {

allows (uri, host, override = false) {
const key = this.hash(host + delimiter + uri);
let result = !override ? this.permissions.get(key) : undefined;
let result = !override ? this.permissions.get(key) : void 0;

if (override || !result) {
let list = methods.filter(i => this.allowed(i, uri, host, override)),
Expand Down Expand Up @@ -74,15 +74,15 @@ class Woodland {
req.query = parsed.query;
req.host = this.host(req.parsed.hostname);
req.allow = this.allows(req.parsed.pathname, req.host);
req.cors = req.headers.origin !== undefined && utility.schemeless(req.headers.host) !== utility.schemeless(req.headers.origin);
req.cors = req.headers.origin !== void 0 && utility.schemeless(req.headers.host) !== utility.schemeless(req.headers.origin);

// CORS handling
if (req.cors) {
let headers = req.headers["access-control-request-headers"];

res.header("access-control-allow-origin", req.headers.origin);

if (headers !== undefined) {
if (headers !== void 0) {
res.header(regex.options.test(req.method) ? "access-control-allow-headers" : "access-control-expose-headers", headers);
}

Expand Down Expand Up @@ -146,7 +146,7 @@ class Woodland {
middleware, result;

let last = err => {
if (err === undefined) {
if (err === void 0) {
deferred.reject((req.allow || "").indexOf("GET") > -1 ? new Error(405) : new Error(404));
} else if (!isNaN(res.statusCode) && res.statusCode >= 400) {
deferred.reject(err);
Expand All @@ -162,20 +162,20 @@ class Woodland {
arity = !iter.done ? utility.getArity(iter.value) : 0;

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

if (!iter.done) {
if (err !== undefined && arity === 4) {
if (err !== void 0 && arity === 4) {
try {
iter.value(err, req, res, next);
} catch (e) {
next(e);
}
} else if (err === undefined && arity <= 3) {
} else if (err === void 0 && arity <= 3) {
try {
iter.value(req, res, next);
} catch (e) {
Expand Down Expand Up @@ -224,11 +224,11 @@ class Woodland {

routes (uri, host, method, override = false) {
const key = this.hash(method + delimiter + host + delimiter + uri),
cached = !override ? this.cache.get(key) : undefined;
cached = !override ? this.cache.get(key) : void 0;
let params = false,
result;

if (cached !== undefined) {
if (cached !== void 0) {
result = cached;
} else {
let allMap = this.middleware.get(all) || new Map(),
Expand All @@ -237,7 +237,7 @@ class Woodland {
pos = [];

retsu.each([allMap.get(allMethod), allMap.get(method), hostMap.get(allMethod), hostMap.get(method)], map => {
if (map !== undefined) {
if (map !== void 0) {
retsu.each(Array.from(map.keys()).filter(route => {
let now = false,
valid;
Expand Down Expand Up @@ -302,7 +302,7 @@ class Woodland {
rpath = "/.*";
}

method = method !== undefined ? method.toUpperCase() : "GET";
method = method !== void 0 ? method.toUpperCase() : "GET";

if (typeof fn !== "function") {
throw new Error("Invalid middleware");
Expand Down
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": "1.3.2",
"version": "1.3.3",
"description": "Lightweight HTTP/HTTPS router with virtual hosts, and automatic `Allow` & `CORS` headers",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 8128cc7

Please sign in to comment.