Browse Source

Made code faster by removing moot `await`

master
Leo Lamprecht 8 years ago
parent
commit
9c280f896f
  1. 3
      bin/now-alias.js
  2. 4
      lib/alias.js
  3. 3
      lib/domains.js
  4. 11
      lib/get-files.js
  5. 7
      lib/index.js
  6. 7
      lib/plans.js
  7. 1
      package.json

3
bin/now-alias.js

@ -343,8 +343,7 @@ async function confirmDeploymentRemoval(alias, _alias) {
const msg = '> The following alias will be removed permanently\n' +
` ${tbl} \nAre you sure?`;
const prompted = await promptBool(msg);
return prompted;
return promptBool(msg);
}
function findAlias(alias, list) {

4
lib/alias.js

@ -99,9 +99,7 @@ module.exports = class Alias extends Now {
async updatePathBasedroutes(alias, rules) {
alias = await this.maybeSetUpDomain(alias);
const upsert = await this.upsertPathAlias(alias, rules);
return upsert;
return this.upsertPathAlias(alias, rules);
}
async upsertPathAlias(alias, rules) {

3
lib/domains.js

@ -10,8 +10,7 @@ const domainRegex = /^((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-
module.exports = class Domains extends Now {
async ls() {
const domains = await this.listDomains();
return domains;
return this.listDomains();
}
async rm(name) {

11
lib/get-files.js

@ -306,16 +306,7 @@ async function explode(paths, { accepts, debug }) {
return path;
};
const many = async all => {
const awaitAll = await Promise.all(
all.map(async file => {
const listed = await list(file);
return listed;
})
);
return awaitAll;
};
const many = async all => Promise.all(all.map(async file => list(file)));
return flatten(await many(paths)).filter(v => v !== null);
}

7
lib/index.js

@ -138,7 +138,7 @@ module.exports = class Now extends EventEmitter {
Array.from(this._files).map(async ([sha, { data, names }]) => {
const statFn = followSymlinks ? stat : lstat;
const nameList = await names.map(async name => {
return names.map(async name => {
let mode;
const getMode = async () => {
@ -164,8 +164,6 @@ module.exports = class Now extends EventEmitter {
mode
};
});
return nameList;
})
)
)
@ -473,8 +471,7 @@ module.exports = class Now extends EventEmitter {
console.timeEnd(`> [debug] #${attempt} GET /domains/${domain}`);
}
const parsedJSON = await res.json();
return parsedJSON;
return res.json();
});
}

7
lib/plans.js

@ -27,9 +27,7 @@ async function parsePlan(res) {
module.exports = class Plans extends Now {
async getCurrent() {
const res = await this._fetch('/www/user/plan');
const parsedPlan = await parsePlan(res);
return parsedPlan;
return parsePlan(res);
}
async set(plan) {
@ -39,8 +37,7 @@ module.exports = class Plans extends Now {
});
if (res.ok) {
const parsedPlan = await parsePlan(res);
return parsedPlan;
return parsePlan(res);
}
const err = new Error(res.statusText);

1
package.json

@ -31,7 +31,6 @@
]
},
"xo": {
"space": true,
"ignores": [
"test/_fixtures/**"
],

Loading…
Cancel
Save