From c39f0e4671757b028f8409156f4dac107bfb7567 Mon Sep 17 00:00:00 2001 From: Luke Edwards Date: Wed, 8 May 2019 13:53:41 -0700 Subject: [PATCH] golf(sirv): use `return` directly --- packages/sirv/index.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/sirv/index.js b/packages/sirv/index.js index 052b016..b8a4f91 100644 --- a/packages/sirv/index.js +++ b/packages/sirv/index.js @@ -25,9 +25,8 @@ function toAssume(uri, extns) { function find(uri, extns) { let i=0, data, arr=toAssume(uri, extns); for (; i < arr.length; i++) { - if (data=FILES[arr[i]]) break; + if (data = FILES[arr[i]]) return data; } - return data; } function is404(req, res) { @@ -84,15 +83,15 @@ module.exports = function (dir, opts={}) { while (file = arr.shift()) { stats = fs.statSync(file); if (stats.isDirectory()) continue; - setHeaders(res, uri, stats); - send(req, res, file, stats, { - 'Content-Type': mime.getType(file), - 'Last-Modified': stats.mtime.toUTCString(), - 'Content-Length': stats.size, - }); + setHeaders(res, uri, stats); + send(req, res, file, stats, { + 'Content-Type': mime.getType(file), + 'Last-Modified': stats.mtime.toUTCString(), + 'Content-Length': stats.size, + }); + } } } - } let cc = opts.maxAge != null && `public,max-age=${opts.maxAge}`; if (cc && opts.immutable) cc += ',immutable';