JavaScript Turbo 🔥 A collection of Javascript clips for Nova. If you would like to make any suggestions, updates or changes please submit a Pull request via the GitHub Repo.
If you find these clips useful consider planting a tree for the world. 🌳 One Tree Planted
Happy Coding Dan 👨🏻💻
JavaScript Turbo is based on: Atom Turbo JavaScript
var ${1:name}var ${1:name} = ${2:value}let ${1:name}let ${1:name} = ${2:value}const ${1:name}const ${1:name} = ${2:value}if (${1:condition}) {
${0}
}else {
${0}
}if (${1:condition}) {
${0}
} else {
}else if (${1:condition}) {
${0}
}for (let ${1:i} = 0, ${2:len} = ${3:iterable}.length; ${1:i} < ${2:len}; ${1:i}++) {
${0}
}for (let ${1:key} in ${2:source}) {
if (${2:source}.hasOwnProperty(${1:key})) {
${0}
}
}for (let ${1:key} of ${2:source}) {
${0}
}while (${1:condition}) {
${0}
}try {
${0}
} catch (${1:err}) {
}try {
${0}
} finally {
}try {
${0}
} catch (${1:err}) {
} finally {
}switch (${1:expr}) {
case ${2:value}:
return $0;
default:
return;
}function (${1:arguments}) {${0}}function ${1:name}(${2:arguments}) {
${0}
}(function (${1:arguments}) {
${0}
})(${2});${1:fn}.apply(${2:this}, ${3:arguments})${1:fn}.call(${2:this}, ${3:arguments})${1:fn}.bind(${2:this}, ${3:arguments})(${1:arguments}) => ${2:statement}(${1:arguments}) => {
\t${0}
}function* (${1:arguments}) {
${0}
}function* ${1:name}(${1:arguments}) {
${0}
}[...Array(${1:length}).keys()]${0}${1:iterable}.forEach((${2:item}) => {
${0}
});${1:iterable}.map((${2:item}) => {
${0}
});${1:iterable}.reduce((${2:previous}, ${3:current}) => {
${0}
}${4:, initial});${1:iterable}.filter((${2:item}) => {
${0}
});${1:iterable}.find((${2:item}) => {
${0}
});class ${1:name} {
constructor(${2:arguments}) {
${0}
}
}class ${1:name} extends ${2:base} {
constructor(${2:arguments}) {
super(${2:arguments});
${0}
}
}constructor(${1:arguments}) {
super(${1:arguments});${0}
}Javascript:
${1:key}: ${2:'value'}JSON:
"${1:key}": ${2:"value"}${1:method}(${2:arguments}) {
${0}
}get ${1:property}() {
${0}
}set ${1:property}(${2:value}) {
${0}
}get ${1:property}() {
${0}
}
set ${1:property}(${2:value}) {
}${1:Class}.prototype.${2:methodName} = function (${3:arguments}) {
${0}
};Object.assign(${1:dest}, ${2:source})Object.assign({}, ${1:original}, ${2:source})return ${0};return this;return null;return true;return false;return 0;return -1;return new Promise((resolve, reject) => {
${0}
});return (
${0}
);new Promise((resolve, reject) => {
${0}
})${1:promise}.then(${2:value} => {
${0}
});${1:promise}.catch(${2:err} => {
${0}
});export ${1:member};export default ${1:member};import ${1:*} from '${2:module}';import ${1:*} as ${2:name} from '${3:module}';describe('${1:description}', function () {
${0}
});context('${1:description}', function () {
${0}
});it('${1:description}', function () {
${0}
});it('${1:description}', function (done) {
${0}
});before(function () {
${0}
});beforeEach(function () {
${0}
});after(function () {
${0}
});afterEach(function () {
${0}
});console.log(${0});console.error(${0});console.warn(${0});setTimeout(() => {
${0}
}, ${1:delay});setInterval(() => {
${0}
}, ${1:delay});setImmediate(() => {
${0}
});${1:document}.addEventListener('${2:event}', ${3:ev} => {
${0}
});${1:document}.getElementById('${2:id}')${1:document}.getElementsByClassName('${2:class}')${1:document}.getElementsByTagName('${2:tag}')${1:document}.querySelector('${2:selector}')${1:document}.querySelectorAll('${2:selector}')const $0 = document.createElement('${1:tag}');
$0.className= '${3:class name}';
$0.id = 'hello1';
$0.setAttribute('${4:attribute}', '${5:value});
var textNode = document.createTextNode('${6:text}');
$0.appendChild(textNode);function (err${1:, value}) {${0}}require("${1:module}");exports.${1:name} = ${2:value};module.exports = ${1:name};${1:emitter}.on('${2:event}', (${3:arguments}) => {
${0}
});function (req, res${1:, next}) {
${0}
}function (err, req, res, next) {
${0}
}${1:express/router}.${2:request}('/', async(req, res, next) => {
res.send();
});const express = require("express");
const app = express();
const helmet = require("helmet");
const bodyParser = require("body-parser");
app.get("/", (req, res, next) => {
return res.send("Hello, I am a Web Server");
});
const port = process.env.PORT || 3000;
app.listen(port, () => console.log(`Listening on port ${port}...`));"use strict";The MIT License (MIT)
Copyright (c) 2014, Nicolas Mercier
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.