Skip to content

Commit b61e619

Browse files
committed
Optimize args and refs
PR-URL: #112
1 parent ab67a0a commit b61e619

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

lib/application.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Application extends events.EventEmitter {
6363
}
6464

6565
runScript(methodName, session) {
66-
const sandbox = session ? session.sandbox : this.sandbox;
66+
const { sandbox } = (session || this);
6767
const script = this.api.get(methodName);
6868
if (!script) return null;
6969
return script.runInContext(sandbox, SCRIPT_OPTIONS);

lib/auth.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ module.exports = application => {
5757
const fillPool = () => {
5858
const need = SANDBOX_POOL - pool.length;
5959
for (let i = 0; i < need; i++) {
60-
const sandbox = application.createSandbox();
61-
pool.push(sandbox);
60+
pool.push(application.createSandbox());
6261
}
6362
};
6463

lib/server.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ class Client {
5555
}
5656

5757
static() {
58-
const { url } = this.req;
58+
const { req: { url }, res, application } = this;
5959
const filePath = url === '/' ? '/index.html' : url;
6060
const fileExt = path.extname(filePath).substring(1);
6161
const mimeType = MIME_TYPES[fileExt] || MIME_TYPES.html;
62-
this.res.writeHead(200, { 'Content-Type': mimeType });
63-
const data = this.application.cache.get(filePath);
64-
if (data) this.res.end(data);
62+
res.writeHead(200, { 'Content-Type': mimeType });
63+
const data = application.cache.get(filePath);
64+
if (data) res.end(data);
6565
else this.error(404);
6666
}
6767

0 commit comments

Comments
 (0)