if,else,while,for,do
```js
var a = 'foo';
function b(){
return a;
| # rename all .js to .mjs | |
| for f in **/*.js; do mv -- "$f" "${f%.js}.mjs"; done | |
| # add .mjs to all file-based import statements* | |
| find . -type f -name "*.mjs" -exec sed -i '' -E "s/(import.+'\.[a-zA-Z0-9\.\/-]+)';/\1\.mjs';/g" {} \; | |
| # *NOTES: | |
| # 1. This will double up existing .mjs extension in imports. | |
| # Couldn't get phrase negation working in this sed substitution regex :( | |
| # |
| // Assumes: | |
| // 1. application/json response content type | |
| // 2. registered error handler capable of handling rejections | |
| module.exports = function respond(handler) { | |
| return async (req, res, next) => { | |
| try { | |
| const result = await handler(req); | |
| res.json(result); | |
| } | |
| catch(err) { |
| const assert = require('assert'); | |
| const mongoose = require('mongoose'); | |
| const RequiredString = { type: String, required: true }; | |
| const schema = new mongoose.Schema({ | |
| name: RequiredString, | |
| type: RequiredString, | |
| colors: [{ | |
| name: RequiredString, |
Rather than creating DOM nodes in JavaScript, an AoT system can extract the html, deliver as html, and then only need reference the relevant DOM nodes in JavaScript. This has a number of performance benefits:
cloneNode can be used to produce cheaper copiesBased on the current Svelte 3.0 output, it seems well poised to take advantage of this.