A collection of ES6 standardjs code style snippets for faster JavaScript development in Atom Editor.
Yes!, no semicolons:
apm install standardjs-snippets
Snippets are optimized to be short and easy to remember. Some snippets are "chainable" and render differently when preceded by a "."
For example, .fe
renders a chain-friendly version of the "forEach" snippet, while fe
renders a full code block.
var ${1:name} = ${2:value}
let ${1:name} = ${2:value}
lif=⇥
let declaration and if statement
let ${1} if (${0}) { ${1} = ${2} }
ly⇥
let yielded assignment
let ${1:name} = yield ${2:value}
const ${1:name} = ${2:value}
cy⇥
const yielded assignment
const ${1:name} = yield ${2:value}
if (${1:condition}) { ${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} } catch (${1:err}) { } finally { }
function (${1:arguments}) { ${0} }
function ${1:name} (${2:arguments}) { ${0} }
async function (${1:arguments}) { ${0} }
iife⇥
immediately-invoked function expression (IIFE)
;(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}
afb⇥
arrow function with body (ES6)
(${1:arguments}) => { ${0} }
gf⇥
generator function (ES6)
function* (${1:arguments}) { ${0} }
gfn⇥
named generator function (ES6)
function* ${1:name}(${1:arguments}) { ${0} }
sf⇥
switch function based on object literals
const ${1:name} = (${2:switching}) => ({ ${3:case}: ${4:value}, }[${2:switching}] || ${5:default value} )
fe⇥
forEach loop (chainable)
${1:iterable}.forEach((${2:item}) => { ${0} })
map⇥
map function (chainable)
${1:iterable}.map((${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} })
every⇥
every function (chainable)
${1:iterable}.every((${2:item}) => { ${0} })
some⇥
some function (chainable)
${1:iterable}.some((${2:item}) => { ${0} })
class ${1:name} { constructor (${2:arguments}) { ${0} } }
class ${1:name} extends ${2:base} { constructor (${2:arguments}) { super(${2:arguments}) ${0} } }
Javascript:
JSON:
${1:method} (${2:arguments}) { ${0} }
get ${1:property}() { ${0} }
set ${1:property}(${2:value}) { ${0} }
gs⇥
getter and setter (ES6 syntax)
get ${1:property}() { ${0} } set ${1:property}(${2:value}) { }
proto⇥
prototype method (chainable)
${1:Class}.prototype.${2:methodName} = function (${3:arguments}) { ${0} }
Object.assign(${1:dest}, ${2:source})
return new Promise((resolve, reject) => { ${0} })
typeof ${1:source} === '${2:undefined}'
iof⇥
instanceof comparison
${1:source} instanceof ${2:Object}
Array.isArray(${1:source})
new Promise((resolve, reject) => { ${0} })
then⇥
Promise.then (chainable)
${1:promise}.then((${2:value}) => { ${0} })
catch⇥
Promise.catch (chainable)
${1:promise}.catch((${2:err}) => { ${0} })
exd⇥
module default export
export default ${1:member}
import ${1:*} from '${2:module}'
import ${1:*} as ${2:name} from '${3:module}'
imd⇥
module import destructuring
import {$1} from '${2:module}'BDD testing (Mocha, Jasmine, etc.)
describe('${1:description}', () => { ${0} })
it('${1:description}', () => { ${0} })
it('${1:description}', (done) => { ${0} })
beforeEach(() => { ${0} })
afterEach(() => { ${0} })
setTimeout(() => { ${0} }, ${1:delay})
setInterval(() => { ${0} }, ${1:delay})
setImmediate(() => { ${0} })
${1:document}.addEventListener('${2:event}', ${3:ev} => { ${0} })
${1:document}.removeEventListener('${2:event}', ${3:listener})
${1:document}.getElementById('${2:id}')
gc⇥
getElementsByClassName
Array.from(${1:document}.getElementsByClassName('${2:class}'))
Array.from(${1:document}.getElementsByTagName('${2:tag}'))
${1:document}.querySelector('${2:selector}')
Array.from(${1:document}.querySelectorAll('${2:selector}'))
cdf⇥
createDocumentFragment
${1:document}.createDocumentFragment(${2:elem});
${1:document}.createElement(${2:elem});
${1:document}.appendChild(${2:elem});
${1:document}.removeChild(${2:elem});
${1:document}.classList.add('${2:class}');
${1:document}.classList.toggle('${2:class}');
${1:document}.classList.remove('${2:class}');
${1:document}.getAttribute('${2:attr}');
${1:document}.setAttribute('${2:attr}', ${3:value});
${1:document}.removeAttribute('${2:attr}');
cb⇥
Node.js style callback
function (err, ${1:value}) { if (err) throw err t${0} }
cre⇥
require and assign a module
const ${1:module} = require('${1:module}')
exports.${1:name} = ${2:value}
module.exports = ${1:name}
on⇥
attach an event handler (chainable)
${1:emitter}.on('${2:event}', (${3:arguments}) => { ${0} })
function (req, res${1:, next}) { ${0} }
xerr⇥
Express error handler
function (err, req, res, next) { ${0} }
Use the following keymaps to speed up your development. You can quickly terminate lines with colons or manipulate blocks of code with ease.
End Line with a commaCTRL-,
Terminates the current line with a comma (great for object literals).
Terminates the current line with a colon followed with a new line. A comma is inserted when the cursor is inside an object literal.
Creates a statement block { ... }
with the selected text placed inside and properly indented. If the selection is already wrapped with a block, the block is removed and its content is unindented.
More than happy to accept external contributions to the project in the form of feedback, bug reports and even better pull requests. Please read the contributing guidelines
Alternatives to Standard StyleSoftware engineer and consultant. I help companies develop software products and make technical decisions. I’m a proponent of devops, continuous delivery, lightweight agile methodologies and open source technology stacks.
I occasionally blog at gaboesquivel.com and you can find me on twitter as @gaboesquivel
The MIT License (MIT)
Copyright (c) 2015, Gabo Esquivel
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 NON INFRINGEMENT. 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.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4