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
${1:assert}.strictEqual(${2:actual}, ${3:expected})${0}
${1:assert}.notStrictEqual(${2:actual}, ${3:expected})${0}
${1:assert}.deepStrictEqual(${2:actual}, ${3:expected})${0}
${1:assert}.notDeepStrictEqual(${2:actual}, ${3:expected})${0}
${1:assert}.ifError(${2:err})${0}
${1:assert}.throws(${2:actual}, ${3:expected})${0}
All async snippets
(err, ${1:value}) => {${0}}
new Promise((resolve${1:, reject}) => {
${0}
})
${1:promise}.then((${2:value}) => {${0}})
.then((${1:value}) => {${0}})
${1:promise}.catch((${2:err}) => {${0}})
.catch((${1:err}) => {${0}})
All classes snippets
class ${1:ClassName} {
constructor (${2:args}) {
${3}
}
}
class ${1:ClassName} extends ${2:BaseClass} {
constructor (${3:args}) {
super(${3:args})
${4}
}
}
${1:name} (${2:args}) {
${3}
}
function ${1:ClassName} (${2:args}) {
if (!(this instanceof ${1:ClassName})) {
return new ${1:ClassName}(${2:args})
}
${3}
}
function ${1:ClassName} (${2:args}) {
${3}
}
All console snippets
console.log(${0})
console.error(${0})
console.warn(${0})
console.dir(${0})
All control-flow snippets
if (${1:condition}) {
${2}
}
else {
${1}
}
if (${1:condition}) {
${2}
} else {
${3}
}
else if (${1:condition}) {
${2}
}
try {
${1}
} catch (${2:err}) {
${3}
}
try {
${1}
} finally {
${2}
}
try {
${1}
} catch (${2:err}) {
${3}
} finally {
${4}
}
All declarations snippets
var ${1:name}
var ${1:name} = ${2:value}
let ${1:name}
let ${1:name} = ${2:value}
const ${1:name}
const ${1:name} = ${2:value}
const ${1:name} = yield ${2:value}
const ${1:name} = await ${2:value}
let ${1:name} = yield ${2:value}
let ${1:name} = await ${2:value}
const ${1:name} = {
${2}
}
const ${1:name} = [
${2}
]
All events snippets
${1:emitter}.on('${2:event}', ${3:args})
.on('${1:event}', ${2:handler})
${1:emitter}.once('${2:event}', ${3:args})
.once('${1:event}', ${2:handler})
${1:emitter}.emit('${2:event}', ${3:args})
.emit('${1:event}', ${2:args})
All functions snippets
function (${1:args}) {${0}}
function ${1:name} (${2:args}) {${0}}
async function (${1:args}) {${0}}
async function ${1:name} (${2:args}) {${0}}
(${1:args}) => ${2:statement}
(${1:args}) => {${0}}
function * (${1:args}) {${0}}
function * ${1:name} (${2:args}) {${0}}
;(function (${1:args}) {
${0}
})(${2})
${1:fn}.apply(${2:this}, ${3:args})
${1:fn}.call(${2:this}, ${3:args})
${1:fn}.bind(${2:this}, ${3:args})
All iterables snippets
${1:iterable}.forEach(${2:iterator})
.forEach(${1:iterator})
${1:iterable}.map(${2:iterator})
.map(${1:iterator})
${1:iterable}.reduce((${2:previous}, ${3:current}) => {
${0}
}${4:, initial})
.reduce((${1:previous}, ${2:current}) => {
${0}
}${3:, initial})
${1:iterable}.filter(${2:iterator})
.filter(${1:iterator})
${1:iterable}.find(${2:iterator})
.find(${1:iterator})
${1:iterable}.every(${2:iterator})
.every(${1:iterator})
${1:iterable}.some(${2:iterator})
.some(${1:iterator})
All json snippets
"${1:key}": "${2:value}"
"${1:key}": ["${2:values}"]
"${1:key}": true
All loops snippets
for (let ${1:i} = 0; ${1:i} < ${2:iterable}${3:.length}; ${1:i}++) {
${4}
}
for (let ${1:key} in ${2:source}) {
if (${2:source}.hasOwnProperty(${1:key})) {
${3}
}
}
for (let ${1:key} of ${2:source}) {
${3}
}
while (${1:condition}) {
${2}
}
let len = ${1:iterable}.length
let i = 0
while (i < len) {
let val = ${1:iterable}[${2:i++}]
${0}
}
All misc snippets
'use strict'
const self = this
yield ${0}
await ${0}
process.exit(${1:code})${0}
throw new ${1:TypeError}('${2:message}')${3}
if (typeof ${1:actual} !== ${2:expected}) {
throw new ${3:TypeError}('${4:message}')
}${5}
JSON.stringify($0)
JSON.parse($0)
/* istanbul ignore next */
const arrayify = (val) => {
if (!val) return []
if (Array.isArray(val)) return val
return [val]
}
function fixture () {
${1:fnName}
}${0}
All modules-commonjs snippets
require('${1:pkg}')${0}
const ${2:name} = require('${1:pkg}')${0}
exports.${1:member} = ${2:value}
exports['default'] = ${1:value}
module.exports = ${1:value}
module.exports = exports['default'] = ${1:value}
All modules-es2015 snippets
export ${1:member}
export default ${1:member}
import ${2:name} from '${1:pkg}'${3}
import ${2:*} as ${3:name} from '${1:pkg}'${4}
import { $2 } from '${1:pkg}'${3}
All objects snippets
${1:key}: ${2:'value'}
${1:ClassName}.prototype.${2:key} = ${3:value}
.prototype.${2:key} = ${3:value}
See extend-shallow lib
extend(${1:defaults}, ${2:sources})${0}
Object.assign(${1:dest}, ${2:source})${0}
Object.keys(${1:obj})${0}
All returns snippets
return ${0}
return this
return null
return true
return false
return 0
return -1
return new Promise((resolve${1:, reject}) => {
${0}
})
All testing snippets
${1:it}('${2:description}', (${3:done}) => {
${0}
})
${1:it}('${2:description}', () => {
${0}
})
${1:test}('${2:description}', (${3:t}) => {
${0}
})
All timers snippets
setTimeout(() => {
${0}
}, ${1:delay})
process.nextTick(() => {
${0}
}${1:, args})
setInterval(() => {
${0}
}, ${1:delay})
setImmediate(() => {
${0}
})
All types snippets
String
Symbol('${1:name}')
Boolean
Number
Object
Array
Date
RegExp
Promise
typeof ${1:source} === '${2:value}'
typeof ${1:source} !== '${2:value}'
${1:source} instanceof ${2:Object}
Array.isArray(${1:source})
- always-done: Handle completion and errors with elegance! Support for streams, callbacks, promises, child processes, async/await and sync functions. A drop-in replacement… more | homepage
- dush-router: A simple regex-based router for
dush
,base
,minibase
and anything based on them. Works on Browser and Node.js | homepage - dush: Microscopic & functional event emitter in ~350 bytes, extensible through plugins | homepage
- minibase: Minimalist alternative for Base. Build complex APIs with small units called plugins. Works well with most of the already existing… more | homepage
- try-catch-core: Low-level package to handle completion and errors of sync or asynchronous functions, using once and dezalgo libs. Useful for and… more | 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
- Please DO NOT edit README.md, CHANGELOG.md and .verb.md files. See "Building docs" section.
- Ensure anything is okey by installing the dependencies and run the tests. See "Running tests" section.
- Always use
npm run commit
to commit changes instead ofgit commit
, because it is interactive and user-friendly. It uses commitizen behind the scenes, which follows Conventional Changelog idealogy. - Do NOT bump the version in package.json. For that we use
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.