turbo-js
Turbo-js for vscode is forked from atom-turbo-javascript
Declarations
l=⇥ let assignment
let ${1:name} = ${2:value}
co⇥ const statement
const ${1:name}
co=⇥ const assignment
const ${1:name} = ${2:value}
Flow Control
if⇥ if statement
if (${1:condition}) {
${0}
}
ife⇥ else statement
if (${1:condition}) {
${0}
} else {
}
fo⇥ for of loop (ES6)
for (let ${1:key} of ${2:source}) {
${0}
}
wl⇥ while loop
while (${1:condition}) {
${0}
}
tc⇥ try/catch
try {
${0}
} catch (${1:err}) {
}
Functions
fn⇥ named function
function ${1:name}(${2:arguments}) {
${0}
}
(function (${1:arguments}) {
${0}
})(${2});
af⇥ arrow function (ES6)
(${1:arguments}) => ${2:statement}
afb⇥ arrow function with body (ES6)
(${1:arguments}) => {
\t${0}
}
Iterables
fe⇥ forEach loop (chainable)
${1:iterable}.forEach((${2:item}) => {
${0}
});
reduce⇥ reduce function (chainable)
${1:iterable}.reduce((${2:previous}, ${3:current}) => {
${0}
}${4:, initial});
filter⇥ filter function (chainable)
${1:iterable}.filter((${2:item}) => {
${0}
});
find⇥ ES6 find function (chainable)
${1:iterable}.find((${2:item}) => {
${0}
});
Objects and classes
cls⇥ class (ES6)
class ${1:name} {
constructor(${2:arguments}) {
${0}
}
}
cex⇥ child class (ES6)
class ${1:name} extends ${2:base} {
constructor(${2:arguments}) {
super(${2:arguments});
${0}
}
}
med⇥ method (ES6 syntax)
${1:method}(${2:arguments}) {
${0}
}
get⇥ getter (ES6 syntax)
get ${1:property}() {
${0}
}
set⇥ setter (ES6 syntax)
set ${1:property}(${2:value}) {
${0}
}
proto⇥ prototype method (chainable)
${1:Class}.prototype.${2:methodName} = function (${3:arguments}) {
${0}
};
oa⇥ Object assign
Object.assign(${1:dest}, ${2:source})
ok⇥ Object.keys
Object.keys(${1:obj})
Promises
rp⇥ return Promise (ES6)
return new Promise((resolve, reject) => {
${0}
});
ES6 modules
ex⇥ module export
export ${1:member};
exd⇥ module default export
export default ${1:member};
im⇥ module import
import ${1:*} from '${2:module}';
ima⇥ module import as
import ${1:*} as ${2:name} from '${3:module}';
Console
cl⇥ console.log
console.log(${0});
ce⇥ console.error
console.error(${0});
cw⇥ console.warn
console.warn(${0});
Timers
st⇥ setTimeout
setTimeout(() => {
${0}
}, ${1:delay});
si⇥ setInterval
setInterval(() => {
${0}
}, ${1:delay});
setImmediate(() => {
${0}
});
Node.js specifics
re⇥ require a module
require('${1:module}');
cre⇥ require a module
const ${1:name} = require('${2:module}');
me⇥ module.exports
module.exports = ${1:name};
Miscellaneous
us⇥ use strict
'use strict';