JavaScript
VS Code JavaScript (ES6) Turbo
Snippets
Below is a list of all available snippets and the triggers of each one. The ⇥ means the TAB
key.
"cb" ⇥ Node callback,
(err, ${1:value}) => {${0}}
"pr" ⇥ Promise,
new Promise((resolve, reject) => {
${0}
})
"then" ⇥ Promise.then,
${1:promise}.then((${2:value}) => {
${0}
})
".then" ⇥ chain then,
.then((${1:value}) => {${0}})
"catch" ⇥ Promise.catch,
${1:promise}.catch((${2:err}) => {
${0}
})
".catch" ⇥ chain catch,
.catch((${1:err}) => {${0}})
"desc" ⇥ describe,
describe('${1:description}', () => {
${0}
});
"cont" ⇥ context,
context('${1:description}', () => {
${0}
});
"it" ⇥ it,
it('${1:description}', () => {
${0}
});
"its" ⇥ it synchronous,
it('${1:description}', () => {
${0}
});
"ita" ⇥ it asynchronous,
it('${1:description}', (done) => {
${0}
done();
});
"bf" ⇥ mocha before,
before(() => {
${0}
});
"bfe" ⇥ mocha beforeEach,
beforeEach(() => {
${0}
});
"aft" ⇥ mocha after,
after(() => {
${0}
});
"afe" ⇥ mocha afterEach,
afterEach(() => {
${0}
});
"cl" ⇥ class,
class ${1:name} {
constructor(${2:arguments}) {
${0}
}
}
"cex" ⇥ class extends,
class ${1:name} extends ${2:base} {
constructor(${3:arguments}) {
super(${3:arguments});
${0}
}
}
"ctor" ⇥ constructor,
constructor(${1:arguments}) {
super(${1:arguments});${0}
}
"clog" ⇥ console.log,
console.log(${0})
"cerr" ⇥ console.error,
console.error(${0})
"if" ⇥ if statement,
if (${1:condition}) {
${0}
}
"el" ⇥ else statement,
else {
${0}
}
"ife" ⇥ if/else statement,
if (${1:condition}) {
${0}
} else {
}
"ei" ⇥ else if statement,
else if (${1:condition}) {
${0}
}
"fl" ⇥ for loop,
for (let ${1:i} = 0, ${2:len} = ${3:iterable}.length; ${1:i} < ${2:len}; ${1:i}++) {
${0}
}
"fi" ⇥ for in loop,
for (let ${1:key} in ${2:source}) {
if (${2:source}.hasOwnProperty(${1:key})) {
${0}
}
}
"fo" ⇥ for of loop,
for (let ${1:key} of ${2:source}) {
${0}
}
"wl" ⇥ while loop,
while (${1:condition}) {
${0}
}
"tc" ⇥ try/catch,
try {
${0}
} catch (${1:err}) {
}
"tf" ⇥ try/finally,
try {
${0}
} finally {
}
"tcf" ⇥ try/catch/finally,
try {
${0}
} catch (${1:err}) {
} finally {
}
"sw" ⇥ switch case,
switch (${1:expr}) {
case ${2:value}:
return $0;
default:
return;
}
"iife" ⇥ immediately-invoked function expression,
((${1:arguments}) => {
${0}
})(${2});
"fa" ⇥ function apply,
${1:fn}.apply(${2:this}, ${3:arguments})
"fc" ⇥ function call,
${1:fn}.call(${2:this}, ${3:arguments})
"fb" ⇥ function bind,
${1:fn}.bind(${2:this}, ${3:arguments})
"af" ⇥ arrow function,
(${1:arguments}) => ${2:statement}
"seq" ⇥ sequence,
[...Array(${1:length}).keys()]${0}
"fe" ⇥ forEach loop,
${1:iterable}.forEach((${2:item}) => {
${0}
});
".fe" ⇥ chain forEach,
.forEach((${1:item}) => {${0}})
"map" ⇥ map,
${1:iterable}.map((${2:item}) => {
${0}
});
".map" ⇥ chain map,
.map((${1:item}) => {${0}})
"reduce" ⇥ reduce,
${1:iterable}.reduce((${2:previous}, ${3:current}) => {
${0}
}${4:, initial});
".reduce" ⇥ chain reduce,
.reduce((${1:previous}, ${2:current}) => {${0}}${4:, initial})
"filter" ⇥ filter,
${1:iterable}.filter(${2:item} => {
${0}
});
".filter" ⇥ chain filter,
.filter((${1:item}) => {${0}})
"find" ⇥ find,
${1:iterable}.find(${2:item} => {
${0}
});
".find" ⇥ chain find,
.find((${1:item}) => {${0}})
"ex" ⇥ module export,
export ${1:member};
"exd" ⇥ module default export,
export default ${1:member};
"im" ⇥ import module,
import ${1:*} from '${2:module}';
"ima" ⇥ import module as,
import ${1:*} as ${2:name} from '${3:module}';
"on" ⇥ event handler,
${1:emitter}.on('${2:event}', (${3:arguments}) => {
${0}
});
".on" ⇥ chain event handler,
.on('${2:event}', (${3:arguments}) => {${0}});
"kv" ⇥ key/value pair,
${1:key}: ${2:value}
"fn" ⇥ method,
const ${1:method} = (${2:arguments}) => {
${0}
}
"get" ⇥ getter,
get ${1:property}() {
${0}
}
"set" ⇥ setter,
set ${1:property}(${2:value}) {
${0}
}
"gs" ⇥ getter + setter,
get ${1:property}() {
${0}
}
set ${1:property}(${2:value}) {
}
"proto" ⇥ prototype method,
${1:Class}.prototype.${2:method} = (${3:arguments}) => {
${0}
};
".proto" ⇥ chain prototype method,
.prototype.${2:methodName} = (${3:arguments}) => {
${0}
}
"oa" ⇥ Object.assign,
Object.assign(${1:dest}, ${2:source})
"oc" ⇥ Object.assign copy,
Object.assign({}, ${1:original}, ${2:source})
"re" ⇥ require,
require('${1:module}');
"em" ⇥ exports.member,
exports.${1:member} = ${2:value};
"me" ⇥ module.exports,
module.exports = ${1:name};
"mc" ⇥ module as class,
var ${1:name} = (() => {
const ${1:name} = (${2:arguments}) => {
${0}
};
return ${1:name};
})();
module.exports = ${1:name};
"rp" ⇥ return promise,
return new Promise((resolve, reject) => {
${0}
});
"st" ⇥ setTimeout,
setTimeout(() => {
${0}
}, ${1:delay});
"si" ⇥ setInterval,
setInterval(() => {
${0}
}, ${1:delay});
"sim" ⇥ setImmediate,
setImmediate(() => {
${0}
});
"nt" ⇥ process nextTick,
process.nextTick(() => {
${1:}
});
"tof" ⇥ typeof,
typeof ${1:source} === '${2:undefined}'
"iof" ⇥ instanceof,
${1:source} instanceof ${2:Object}