Skip to content

Instantly share code, notes, and snippets.

@gai00
Last active September 18, 2017 09:51
Show Gist options
  • Select an option

  • Save gai00/d1b60e82123390e80bf4d9f0f8ddffde to your computer and use it in GitHub Desktop.

Select an option

Save gai00/d1b60e82123390e80bf4d9f0f8ddffde to your computer and use it in GitHub Desktop.
nodejs is dynamic loading
// koa app ...
app.use(async (ctx, next) => {
const {url} = ctx.request;
if(url.match(/\/test/)) {
ctx.testDates = require('./test');
}
await next();
});
// koa app ...
let dates = [];
const limit = 100000;
console.log('loaded.');
for(let i = 0; i < limit; i += 1) {
dates.push(new Date());
}
module.exports = dates;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment