Atom & VSCode - Modern javascript snippets for better productivity with support for JavaScript, Babel, TypeScript, JSX and semicolonless code. Using StandardJS Style.
Atom & VSCode - Modern javascript snippets for better productivity with support for JavaScript, Babel, TypeScript, JSX and semicolon-less code.
You might also be interested in always-done.
Highly opinionated to my needs - don't includes snippets that I don't use. But also is mixed between my previous Sublime javascript-charlike-snippets, standardjs-snippets and es6-javascript.
It uses standard style as base. But easily can be changed with a bit automation, so please open an issue if you want such thing.
The documentation is built and fully automated using verb, including table of contents and even the snippets docs.
(TOC generated by verb using markdown-toc)
Install with apm (Atom Editor's package manager)
$ apm install modern-javascript-snippets
Or launch VSCode Quick Open (Ctrl+P
), paste the following command, and press enter.
ext install modern-javascript-snippets
All assert snippets
ase⇥
assert.strictEqual${1:assert}.strictEqual(${2:actual}, ${3:expected})${0}
asn⇥
assert.notStrictEqual${1:assert}.notStrictEqual(${2:actual}, ${3:expected})${0}
asd⇥
assert.deepStrictEqual${1:assert}.deepStrictEqual(${2:actual}, ${3:expected})${0}
asdn⇥
assert.notDeepStrictEqual${1:assert}.notDeepStrictEqual(${2:actual}, ${3:expected})${0}
asi⇥
assert.ifError${1:assert}.ifError(${2:err})${0}
ast⇥
assert.throws${1:assert}.throws(${2:actual}, ${3:expected})${0}
All async snippets
cb⇥
Node callback(err, ${1:value}) => {${0}}
p⇥
Promise constructornew Promise((resolve${1:, 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}})
All classes snippets
cs⇥
classclass ${1:ClassName} {
constructor (${2:args}) {
${3}
}
}
csx⇥
class extendsclass ${1:ClassName} extends ${2:BaseClass} {
constructor (${3:args}) {
super(${3:args})
${4}
}
}
csm⇥
class method${1:name} (${2:args}) {
${3}
}
csi⇥
es5 singleton classfunction ${1:ClassName} (${2:args}) {
if (!(this instanceof ${1:ClassName})) {
return new ${1:ClassName}(${2:args})
}
${3}
}
csf⇥
es5 function classfunction ${1:ClassName} (${2:args}) {
${3}
}
All console snippets
cl⇥
console.logconsole.log(${0})
ce⇥
console.errorconsole.error(${0})
cw⇥
console.warnconsole.warn(${0})
cd⇥
console.dirconsole.dir(${0})
All control-flow snippets
if⇥
if statementif (${1:condition}) {
${2}
}
el⇥
else statementelse {
${1}
}
ife⇥
if/else statementif (${1:condition}) {
${2}
} else {
${3}
}
ei⇥
else if statementelse if (${1:condition}) {
${2}
}
tc⇥
try/catchtry {
${1}
} catch (${2:err}) {
${3}
}
tf⇥
try/finallytry {
${1}
} finally {
${2}
}
tcf⇥
try/catch/finallytry {
${1}
} catch (${2:err}) {
${3}
} finally {
${4}
}
All declarations snippets
v⇥
var statementvar ${1:name}
v=⇥
var assignmentvar ${1:name} = ${2:value}
l⇥
let statementlet ${1:name}
l=⇥
let assignmentlet ${1:name} = ${2:value}
c⇥
const statementconst ${1:name}
c=⇥
const assignmentconst ${1:name} = ${2:value}
cy⇥
const yieldedconst ${1:name} = yield ${2:value}
ca⇥
const awaitedconst ${1:name} = await ${2:value}
ly⇥
let yieldedlet ${1:name} = yield ${2:value}
la⇥
let awaitedlet ${1:name} = await ${2:value}
co⇥
const objectconst ${1:name} = {
${2}
}
ca⇥
const arrayconst ${1:name} = [
${2}
]
All events snippets
on⇥
on event handler${1:emitter}.on('${2:event}', ${3:args})
.on⇥
chain .on.on('${1:event}', ${2:handler})
once⇥
once event handler${1:emitter}.once('${2:event}', ${3:args})
.once⇥
chain .once.once('${1:event}', ${2:handler})
emit⇥
emit event${1:emitter}.emit('${2:event}', ${3:args})
.emit⇥
chain .emit.emit('${1:event}', ${2:args})
All functions snippets
f⇥
anonymous functionfunction (${1:args}) {${0}}
fn⇥
named functionfunction ${1:name} (${2:args}) {${0}}
asf⇥
async anonymous functionasync function (${1:args}) {${0}}
asfn⇥
async named functionasync function ${1:name} (${2:args}) {${0}}
af⇥
arrow function(${1:args}) => ${2:statement}
afn⇥
arrow fn with body(${1:args}) => {${0}}
gf⇥
generatorfunction * (${1:args}) {${0}}
gfn⇥
named generatorfunction * ${1:name} (${2:args}) {${0}}
iife⇥
immediately-invoked function expression;(function (${1:args}) {
${0}
})(${2})
fa⇥
function apply${1:fn}.apply(${2:this}, ${3:args})
fc⇥
function call${1:fn}.call(${2:this}, ${3:args})
fb⇥
function bind${1:fn}.bind(${2:this}, ${3:args})
All iterables snippets
fe⇥
forEach loop${1:iterable}.forEach(${2:iterator})
.fe⇥
chain forEach.forEach(${1:iterator})
map⇥
map${1:iterable}.map(${2:iterator})
.map⇥
chain map.map(${1:iterator})
reduce⇥
reduce${1:iterable}.reduce((${2:previous}, ${3:current}) => {
${0}
}${4:, initial})
.reduce⇥
chain reduce.reduce((${1:previous}, ${2:current}) => {
${0}
}${3:, initial})
filter⇥
filter${1:iterable}.filter(${2:iterator})
.filter⇥
chain filter.filter(${1:iterator})
find⇥
find${1:iterable}.find(${2:iterator})
.find⇥
chain find.find(${1:iterator})
every⇥
every${1:iterable}.every(${2:iterator})
.every⇥
chain every.every(${1:iterator})
some⇥
some${1:iterable}.some(${2:iterator})
.some⇥
chain some.some(${1:iterator})
All json snippets
;⇥
JSON key/value pair"${1:key}": "${2:value}"
;a⇥
JSON array"${1:key}": ["${2:values}"]
;t⇥
JSON true"${1:key}": true
All loops snippets
fl⇥
for loopfor (let ${1:i} = 0; ${1:i} < ${2:iterable}${3:.length}; ${1:i}++) {
${4}
}
fi⇥
for in loopfor (let ${1:key} in ${2:source}) {
if (${2:source}.hasOwnProperty(${1:key})) {
${3}
}
}
fo⇥
for of loopfor (let ${1:key} of ${2:source}) {
${3}
}
wl⇥
while loopwhile (${1:condition}) {
${2}
}
wf⇥
fast while looplet len = ${1:iterable}.length
let i = 0
while (i < len) {
let val = ${1:iterable}[${2:i++}]
${0}
}
All misc snippets
us⇥
use strict'use strict'
self⇥
const self thisconst self = this
ye⇥
yieldyield ${0}
aw⇥
awaitawait ${0}
pe⇥
process.exitprocess.exit(${1:code})${0}
thn⇥
throw new errorthrow new ${1:TypeError}('${2:message}')${3}
iferr⇥
if not typeof then throw errorif (typeof ${1:actual} !== ${2:expected}) {
throw new ${3:TypeError}('${4:message}')
}${5}
js⇥
JSON.stringify()JSON.stringify($0)
jp⇥
JSON.parse()JSON.parse($0)
afi⇥
arrayify/* istanbul ignore next */
const arrayify = (val) => {
if (!val) return []
if (Array.isArray(val)) return val
return [val]
}
fixture⇥
fixture (useful for assert.throws)function fixture () {
${1:fnName}
}${0}
All modules-commonjs snippets
req⇥
require modulerequire('${1:pkg}')${0}
rr⇥
const require packageconst ${2:name} = require('${1:pkg}')${0}
em⇥
exports.memberexports.${1:member} = ${2:value}
emd⇥
exports defaultexports['default'] = ${1:value}
me⇥
module.exportsmodule.exports = ${1:value}
med⇥
module exports and exports defaultmodule.exports = exports['default'] = ${1:value}
All modules-es2015 snippets
ex⇥
module exportexport ${1:member}
exd⇥
module default exportexport default ${1:member}
im⇥
import moduleimport ${2:name} from '${1:pkg}'${3}
ima⇥
import module asimport ${2:*} as ${3:name} from '${1:pkg}'${4}
imd⇥
import module destructuredimport { $2 } from '${1:pkg}'${3}
All objects snippets
kv⇥
key/value pair${1:key}: ${2:'value'}
proto⇥
prototype method${1:ClassName}.prototype.${2:key} = ${3:value}
.proto⇥
chain prototype method.prototype.${2:key} = ${3:value}
xa⇥
extend-shallowSee extend-shallow lib
extend(${1:defaults}, ${2:sources})${0}
oa⇥
Object.assignObject.assign(${1:dest}, ${2:source})${0}
ok⇥
Object.keysObject.keys(${1:obj})${0}
All returns snippets
r⇥
returnreturn ${0}
rth⇥
return thisreturn this
rn⇥
return nullreturn null
rt⇥
return truereturn true
rf⇥
return falsereturn false
r0⇥
return 0return 0
r-1⇥
return -1return -1
rp⇥
return promisereturn new Promise((resolve${1:, reject}) => {
${0}
})
All testing snippets
ita⇥
async test (mocha/mukla)${1:it}('${2:description}', (${3:done}) => {
${0}
})
its⇥
synchronous test (mocha/mukla)${1:it}('${2:description}', () => {
${0}
})
te⇥
tape-style test${1:test}('${2:description}', (${3:t}) => {
${0}
})
All timers snippets
st⇥
setTimeoutsetTimeout(() => {
${0}
}, ${1:delay})
nt⇥
process.nextTickprocess.nextTick(() => {
${0}
}${1:, args})
si⇥
setIntervalsetInterval(() => {
${0}
}, ${1:delay})
sim⇥
setImmediatesetImmediate(() => {
${0}
})
All types snippets
S⇥
StringString
Sy⇥
SymbolSymbol('${1:name}')
B⇥
BooleanBoolean
N⇥
NumberNumber
O⇥
ObjectObject
A⇥
ArrayArray
D⇥
DateDate
Rx⇥
RegExpRegExp
P⇥
PromisePromise
tof⇥
typeof equal totypeof ${1:source} === '${2:value}'
tofi⇥
typeof not equal totypeof ${1:source} !== '${2:value}'
iof⇥
instanceof${1:source} instanceof ${2:Object}
ia⇥
Array.isArray()Array.isArray(${1:source})
dush
, base
, minibase
and anything based on them. Works on Browser and Node.js | homepage
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue. Please read the contributing guidelines for advice on opening issues, pull requests, and coding standards. If you need some help and can spent some cash, feel free to contact me at CodeMentor.io too.
In short: If you want to contribute to that project, please follow these things
npm run commit
to commit changes instead of git commit
, because it is interactive and user-friendly. It uses commitizen behind the scenes, which follows Conventional Changelog idealogy.npm run release
, which is standard-version and follows Conventional Changelog idealogy.Thanks a lot! :)
Documentation and that readme is generated using verb-generate-readme, which is a verb generator, so you need to install both of them and then run verb
command like that
$ npm install verbose/verb#dev verb-generate-readme --global && verb
Please don't edit the README directly. Any changes to the readme must be made in .verb.md.
Clone repository and run the following in that cloned directory
$ npm install && npm test
Charlike Mike Reagent
Copyright © 2016-2017, Charlike Mike Reagent. Released under the MIT License.
This file was generated by verb-generate-readme, v0.6.0, on May 20, 2017.
Project scaffolded using charlike cli.