diff --git a/README.md b/README.md index c0f85dd..4254913 100755 --- a/README.md +++ b/README.md @@ -1,619 +1,620 @@ -# JavaScript Snippets for VS Code - -[![Visual Studio Marketplace](https://img.shields.io/vscode-marketplace/v/nathanchapman.JavaScriptSnippets.svg)](https://marketplace.visualstudio.com/items?itemName=nathanchapman.JavaScriptSnippets) -[![Visual Studio Marketplace](https://img.shields.io/vscode-marketplace/d/nathanchapman.JavaScriptSnippets.svg)](https://marketplace.visualstudio.com/items?itemName=nathanchapman.JavaScriptSnippets) -[![Visual Studio Marketplace](https://img.shields.io/vscode-marketplace/r/nathanchapman.JavaScriptSnippets.svg)](https://marketplace.visualstudio.com/items?itemName=nathanchapman.JavaScriptSnippets) - -## Snippets - -Snippets are optimized to be short and easy to remember. - -Below is a list of all available snippets and the triggers of each one. The **⇥** means the `TAB` key. - -### Declarations -#### `v⇥` var statement -```javascript -var ${0} -``` - -#### `v=⇥` var assignment -```javascript -var ${1:name} = ${2:value}; -``` - -#### `l⇥` let statement -```javascript -let ${0} -``` - -#### `l=⇥` let assignment -```javascript -let ${1:name} = ${2:value}; -``` - -#### `dl=⇥` destructuring let assignment -```javascript -let {${1:name}} = ${2:value}; -``` - -#### `co⇥` const statement -```javascript -const ${0} -``` - -#### `co=⇥` const assignment -```javascript -const ${1:name} = ${2:value}; -``` - -#### `dco=⇥` destructuring const assignment -```javascript -const {${1:name}} = ${2:value}; -``` - -### Flow Control -#### `if⇥` if statement -```javascript -if (${1:condition}) { - ${0} -} -``` - -#### `el⇥` else statement -```javascript -else { - ${0} -} -``` - -#### `ife⇥` if/else statement -```javascript -if (${1:condition}) { - ${0} -} else { - -} -``` - -#### `ei⇥` else if statement -```javascript -else if (${1:condition}) { - ${0} -} -``` - -#### `ter⇥` ternary operator -```javascript -${1:condition} ? ${2:expression} : ${3:expression}; -``` - -#### `fl⇥` for loop -```javascript -for (let ${1:i} = 0, ${2:len} = ${3:iterable}.length; ${1:i} < ${2:len}; ${1:i}++) { - ${0} -} -``` - -#### `rfl⇥` reverse for loop -```javascript -for (let ${1:i} = ${2:iterable}.length - 1; ${1:i} >= 0; ${1:i}--) { - ${0} -} -``` - -#### `fi⇥` for in loop -```javascript -for (let ${1:key} in ${2:array}) { - if (${2:array}.hasOwnProperty(${1:key})) { - ${0} - } -} -``` - -}, -#### `fo⇥` for of loop (ES6) -```javascript -for (let ${1:key} of ${2:array}) { - ${0} -} -``` - -#### `wl⇥` while loop -```javascript -while (${1:condition}) { - ${0} -} -``` - -#### `tc⇥` try/catch -```javascript -try { - ${0} -} catch (${1:err}) { - -} -``` - -#### `tf⇥` try/finally -```javascript -try { - ${0} -} finally { - -} -``` - -#### `tcf⇥` try/catch/finally -```javascript -try { - ${0} -} catch (${1:err}) { - -} finally { - -} -``` - -#### `sw⇥` switch case -```javascript -switch (${1:expr}) { - case ${2:value}: - return $0; - default: - return; -} -``` - -### Functions -#### `f⇥` anonymous function -```javascript -function (${1:arguments}) { - ${0} -} -``` - -#### `fn⇥` named function -```javascript -function ${1:name}(${2:arguments}) { - ${0} -} -``` - -#### `iife⇥` immediately-invoked function expression (IIFE) -```javascript -((${1:arguments}) => { - ${0} -})(${2}); -``` - -#### `fa⇥` function apply -```javascript -${1:fn}.apply(${2:this}, ${3:arguments}) -``` - -#### `fc⇥` function call -```javascript -${1:fn}.call(${2:this}, ${3:arguments}) -``` - -#### `fb⇥` function bind -```javascript -${1:fn}.bind(${2:this}, ${3:arguments}) -``` - -#### `af⇥` arrow function (ES6) -```javascript -(${1:arguments}) => ${2:statement} -``` - -#### `afb⇥` arrow function with body (ES6) -```javascript -(${1:arguments}) => { - ${0} -} -``` - -#### `gf⇥` generator function (ES6) -```javascript -function* (${1:arguments}) { - ${0} -} -``` - -#### `gfn⇥` named generator function (ES6) -```javascript -function* ${1:name}(${2:arguments}) { - ${0} -} -``` - -### Iterables -#### `seq⇥` sequence of 0..n -```javascript -[...Array(${1:length}).keys()]${0} -``` - -#### `fe⇥` forEach loop -```javascript -${1}.forEach((${2:item}) => { - ${0} -}); -``` - -#### `map⇥` map -```javascript -${1}.map((${2:item}) => { - ${0} -}); -``` - -#### `reduce⇥` reduce -```javascript -${1}.reduce((${2:previous}, ${3:current}) => { - ${0} -}${4:, initial}); -``` - -#### `filter⇥` filter -```javascript -${1}.filter(${2:item} => { - ${0} -}); -``` - -#### `find⇥` find -```javascript -${1}.find(${2:item} => { - ${0} -}); -``` - -### Objects and Classes -#### `ol⇥` object literal -```javascript -{ - kv${0} -}; -``` - -#### `slol⇥` same-line object literal -```javascript -{ kv${0} }; -``` - -#### `kv⇥` key/value pair -```javascript -${1:key}: ${2:value}, -``` - -#### `c⇥` class (ES6) -```javascript -class ${1:name} { - constructor(${2:arguments}) { - ${0} - } -} -``` - -#### `cex⇥` child class (ES6) -```javascript -class ${1:name} extends ${2:base} { - constructor(${3:arguments}) { - super(${3:arguments}); - ${0} - } -} -``` - -#### `ctor⇥` class constructor (ES6) -```javascript -constructor(${1:arguments}) { - super(${1:arguments}); - ${0} -} -``` - -#### `m⇥` method (ES6 syntax) -```javascript -${1:method}(${2:arguments}) { - ${0} -} -``` - -#### `get⇥` getter (ES6 syntax) -```javascript -get ${1:property}() { - ${0} -} -``` - -#### `set⇥` setter (ES6 syntax) -```javascript -set ${1:property}(${2:value}) { - ${0} -} -``` - -#### `gs⇥` getter and setter (ES6 syntax) -```javascript -get ${1:property}() { - ${0} -} -set ${1:property}(${2:value}) { - -} -``` - -#### `pctor⇥` prototypal constructor -```javascript -var ${1:Class} = function(${2:arguments}) { - ${0} -}; -``` - -#### `proto⇥` prototype method -```javascript -${1:Class}.prototype.${2:method} = function(${3:arguments}) { - ${0} -}; -``` - -#### `oa⇥` Object.assign -```javascript -Object.assign(${1:dest}, ${2:source}) -``` - -#### `oc⇥` Object.assign copy (shallow clone) -```javascript -Object.assign({}, ${1:original}, ${2:source}) -``` - -### Returning values -#### `r⇥` return -```javascript -return ${0}; -``` - -#### `rp⇥` return Promise (ES6) -```javascript -return new Promise((resolve, reject) => { - ${0} -}); -``` - -#### `rc⇥` return complex value (such as JSX components) -```javascript -return ( - ${0} -); -``` - -### Types -#### `tof⇥` typeof -```javascript -typeof ${1:source} === '${2:undefined}' -``` - -#### `iof⇥` instanceof -```javascript -${1:source} instanceof ${2:Object} -``` - -### Promises -#### `pr⇥` Promise (ES6) -```javascript -new Promise((resolve, reject) => { - ${0} -}) -``` - -#### `then⇥` Promise.then -```javascript -${1:promise}.then((${2:value}) => { - ${0} -}) -``` - -#### `catch⇥` Promise.catch -```javascript -${1:promise}.catch((${2:err}) => { - ${0} -}) -``` - -### ES6 Modules -#### `ex⇥` export (ES6) -```javascript -export ${1:member}; -``` - -#### `exd⇥` export default (ES6) -```javascript -export default ${1:member}; -``` - -#### `im⇥` import module (ES6) -```javascript -import ${1:*} from '${2:module}'; -``` - -#### `ima⇥` import module as (ES6) -```javascript -import ${1:*} as ${2:name} from '${3:module}'; -``` - -### Node.js -#### `cb⇥` Node.js style callback -```javascript -(err, ${1:value}) => {${0}} -``` - -#### `re⇥` require -```javascript -require('${1:module}'); -``` - -#### `req⇥` require assignment -```javascript -const ${1:module} = require('${1:module}'); -``` - -#### `dreq⇥` destructuring require assignment -```javascript -const {${1:module}} = require('${1:module}'); -``` - -#### `em⇥` exports.member -```javascript -exports.${1:member} = ${2:value}; -``` - -#### `me⇥` module.exports -```javascript -module.exports = ${1:name}; -``` - -#### `meo⇥` module exports object -```javascript -module.exports = { - ${1:member} -}; -``` - -#### `on⇥` event handler -```javascript -${1:emitter}.on('${2:event}', (${3:arguments}) => { - ${0} -}); -``` - -### BDD Testing (Mocha, Jasmine, etc.) -#### `desc⇥` describe -```javascript -describe('${1:description}', () => { - ${0} -}); -``` - -#### `cont⇥` context -```javascript -context('${1:description}', () => { - ${0} -}); -``` - -#### `it⇥` it -```javascript -it('${1:description}', () => { - ${0} -}); -``` - -#### `its⇥` it synchronous -```javascript -it('${1:description}', () => { - ${0} -}); -``` - -#### `ita⇥` it asynchronous -```javascript -it('${1:description}', (done) => { - ${0} - done(); -}); -``` - -#### `bf⇥` before test suite -```javascript -before(() => { - ${0} -}); -``` - -#### `bfe⇥` before each test -```javascript -beforeEach(() => { - ${0} -}); -``` - -#### `aft⇥` after test suite -```javascript -after(() => { - ${0} -}); -``` - -#### `afe⇥` after each test -```javascript -afterEach(() => { - ${0} -}); -``` - -### Console -#### `cl⇥` console.log -```javascript -console.log(${0}); -``` - -#### `ce⇥` console.error -```javascript -console.error(${0}); -``` - -#### `cw⇥` console.warn -```javascript -console.warn(${0}); -``` - -#### `cll⇥` console.log labeled -```javascript -console.log('${0}', ${0}); -``` - -#### `cel⇥` console.error labeled -```javascript -console.error('${0}', ${0}); -``` - -#### `cwl⇥` console.warn labeled -```javascript -console.warn('${0}', ${0}); -``` - -### Timers -#### `st⇥` setTimeout -```javascript -setTimeout(() => { - ${0} -}, ${1:delay}); -``` - -#### `si⇥` setInterval -```javascript -setInterval(() => { - ${0} -}, ${1:delay}); -``` - -#### `sim⇥` setImmediate -```javascript -setImmediate(() => { - ${0} -}); -``` - -#### `nt⇥` process nextTick -```javascript -process.nextTick(() => { - ${0} -}); -``` - -### Miscellaneous -#### `us⇥` insert 'use strict' statement -```javascript -'use strict'; -``` +# JavaScript Snippets for VS Code + +[![Visual Studio Marketplace](https://img.shields.io/vscode-marketplace/v/nathanchapman.JavaScriptSnippets.svg)](https://marketplace.visualstudio.com/items?itemName=nathanchapman.JavaScriptSnippets) +[![Visual Studio Marketplace](https://img.shields.io/vscode-marketplace/d/nathanchapman.JavaScriptSnippets.svg)](https://marketplace.visualstudio.com/items?itemName=nathanchapman.JavaScriptSnippets) +[![Visual Studio Marketplace](https://img.shields.io/vscode-marketplace/r/nathanchapman.JavaScriptSnippets.svg)](https://marketplace.visualstudio.com/items?itemName=nathanchapman.JavaScriptSnippets) + + +## Snippets + +Snippets are optimized to be short and easy to remember. + +Below is a list of all available snippets and the triggers of each one. The **⇥** means the `TAB` key. + +### Declarations +#### `v⇥` var statement +```javascript +var ${0} +``` + +#### `v=⇥` var assignment +```javascript +var ${1:name} = ${2:value}; +``` + +#### `l⇥` let statement +```javascript +let ${0} +``` + +#### `l=⇥` let assignment +```javascript +let ${1:name} = ${2:value}; +``` + +#### `dl=⇥` destructuring let assignment +```javascript +let {${1:name}} = ${2:value}; +``` + +#### `co⇥` const statement +```javascript +const ${0} +``` + +#### `co=⇥` const assignment +```javascript +const ${1:name} = ${2:value}; +``` + +#### `dco=⇥` destructuring const assignment +```javascript +const {${1:name}} = ${2:value}; +``` + +### Flow Control +#### `if⇥` if statement +```javascript +if (${1:condition}) { + ${0} +} +``` + +#### `el⇥` else statement +```javascript +else { + ${0} +} +``` + +#### `ife⇥` if/else statement +```javascript +if (${1:condition}) { + ${0} +} else { + +} +``` + +#### `ei⇥` else if statement +```javascript +else if (${1:condition}) { + ${0} +} +``` + +#### `ter⇥` ternary operator +```javascript +${1:condition} ? ${2:expression} : ${3:expression}; +``` + +#### `fl⇥` for loop +```javascript +for (let ${1:i} = 0, ${2:len} = ${3:iterable}.length; ${1:i} < ${2:len}; ${1:i}++) { + ${0} +} +``` + +#### `rfl⇥` reverse for loop +```javascript +for (let ${1:i} = ${2:iterable}.length - 1; ${1:i} >= 0; ${1:i}--) { + ${0} +} +``` + +#### `fi⇥` for in loop +```javascript +for (let ${1:key} in ${2:array}) { + if (${2:array}.hasOwnProperty(${1:key})) { + ${0} + } +} +``` + +}, +#### `fo⇥` for of loop (ES6) +```javascript +for (let ${1:key} of ${2:array}) { + ${0} +} +``` + +#### `wl⇥` while loop +```javascript +while (${1:condition}) { + ${0} +} +``` + +#### `tc⇥` try/catch +```javascript +try { + ${0} +} catch (${1:err}) { + +} +``` + +#### `tf⇥` try/finally +```javascript +try { + ${0} +} finally { + +} +``` + +#### `tcf⇥` try/catch/finally +```javascript +try { + ${0} +} catch (${1:err}) { + +} finally { + +} +``` + +#### `sw⇥` switch case +```javascript +switch (${1:expr}) { + case ${2:value}: + return $0; + default: + return; +} +``` + +### Functions +#### `f⇥` anonymous function +```javascript +function (${1:arguments}) { + ${0} +} +``` + +#### `fn⇥` named function +```javascript +function ${1:name}(${2:arguments}) { + ${0} +} +``` + +#### `iife⇥` immediately-invoked function expression (IIFE) +```javascript +((${1:arguments}) => { + ${0} +})(${2}); +``` + +#### `fa⇥` function apply +```javascript +${1:fn}.apply(${2:this}, ${3:arguments}) +``` + +#### `fc⇥` function call +```javascript +${1:fn}.call(${2:this}, ${3:arguments}) +``` + +#### `fb⇥` function bind +```javascript +${1:fn}.bind(${2:this}, ${3:arguments}) +``` + +#### `af⇥` arrow function (ES6) +```javascript +(${1:arguments}) => ${2:statement} +``` + +#### `afb⇥` arrow function with body (ES6) +```javascript +(${1:arguments}) => { + ${0} +} +``` + +#### `gf⇥` generator function (ES6) +```javascript +function* (${1:arguments}) { + ${0} +} +``` + +#### `gfn⇥` named generator function (ES6) +```javascript +function* ${1:name}(${2:arguments}) { + ${0} +} +``` + +### Iterables +#### `seq⇥` sequence of 0..n +```javascript +[...Array(${1:length}).keys()]${0} +``` + +#### `fe⇥` forEach loop +```javascript +${1}.forEach((${2:item}) => { + ${0} +}); +``` + +#### `map⇥` map +```javascript +${1}.map((${2:item}) => { + ${0} +}); +``` + +#### `reduce⇥` reduce +```javascript +${1}.reduce((${2:previous}, ${3:current}) => { + ${0} +}${4:, initial}); +``` + +#### `filter⇥` filter +```javascript +${1}.filter(${2:item} => { + ${0} +}); +``` + +#### `find⇥` find +```javascript +${1}.find(${2:item} => { + ${0} +}); +``` + +### Objects and Classes +#### `ol⇥` object literal +```javascript +{ + kv${0} +}; +``` + +#### `slol⇥` same-line object literal +```javascript +{ kv${0} }; +``` + +#### `kv⇥` key/value pair +```javascript +${1:key}: ${2:value}, +``` + +#### `c⇥` class (ES6) +```javascript +class ${1:name} { + constructor(${2:arguments}) { + ${0} + } +} +``` + +#### `cex⇥` child class (ES6) +```javascript +class ${1:name} extends ${2:base} { + constructor(${3:arguments}) { + super(${3:arguments}); + ${0} + } +} +``` + +#### `ctor⇥` class constructor (ES6) +```javascript +constructor(${1:arguments}) { + super(${1:arguments}); + ${0} +} +``` + +#### `m⇥` method (ES6 syntax) +```javascript +${1:method}(${2:arguments}) { + ${0} +} +``` + +#### `get⇥` getter (ES6 syntax) +```javascript +get ${1:property}() { + ${0} +} +``` + +#### `set⇥` setter (ES6 syntax) +```javascript +set ${1:property}(${2:value}) { + ${0} +} +``` + +#### `gs⇥` getter and setter (ES6 syntax) +```javascript +get ${1:property}() { + ${0} +} +set ${1:property}(${2:value}) { + +} +``` + +#### `pctor⇥` prototypal constructor +```javascript +var ${1:Class} = function(${2:arguments}) { + ${0} +}; +``` + +#### `proto⇥` prototype method +```javascript +${1:Class}.prototype.${2:method} = function(${3:arguments}) { + ${0} +}; +``` + +#### `oa⇥` Object.assign +```javascript +Object.assign(${1:dest}, ${2:source}) +``` + +#### `oc⇥` Object.assign copy (shallow clone) +```javascript +Object.assign({}, ${1:original}, ${2:source}) +``` + +### Returning values +#### `r⇥` return +```javascript +return ${0}; +``` + +#### `rp⇥` return Promise (ES6) +```javascript +return new Promise((resolve, reject) => { + ${0} +}); +``` + +#### `rc⇥` return complex value (such as JSX components) +```javascript +return ( + ${0} +); +``` + +### Types +#### `tof⇥` typeof +```javascript +typeof ${1:source} === '${2:undefined}' +``` + +#### `iof⇥` instanceof +```javascript +${1:source} instanceof ${2:Object} +``` + +### Promises +#### `pr⇥` Promise (ES6) +```javascript +new Promise((resolve, reject) => { + ${0} +}) +``` + +#### `then⇥` Promise.then +```javascript +${1:promise}.then((${2:value}) => { + ${0} +}) +``` + +#### `catch⇥` Promise.catch +```javascript +${1:promise}.catch((${2:err}) => { + ${0} +}) +``` + +### ES6 Modules +#### `ex⇥` export (ES6) +```javascript +export ${1:member}; +``` + +#### `exd⇥` export default (ES6) +```javascript +export default ${1:member}; +``` + +#### `im⇥` import module (ES6) +```javascript +import ${1:*} from '${2:module}'; +``` + +#### `ima⇥` import module as (ES6) +```javascript +import ${1:*} as ${2:name} from '${3:module}'; +``` + +### Node.js +#### `cb⇥` Node.js style callback +```javascript +(err, ${1:value}) => {${0}} +``` + +#### `re⇥` require +```javascript +require('${1:module}'); +``` + +#### `req⇥` require assignment +```javascript +const ${1:module} = require('${1:module}'); +``` + +#### `dreq⇥` destructuring require assignment +```javascript +const {${1:module}} = require('${1:module}'); +``` + +#### `em⇥` exports.member +```javascript +exports.${1:member} = ${2:value}; +``` + +#### `me⇥` module.exports +```javascript +module.exports = ${1:name}; +``` + +#### `meo⇥` module exports object +```javascript +module.exports = { + ${1:member} +}; +``` + +#### `on⇥` event handler +```javascript +${1:emitter}.on('${2:event}', (${3:arguments}) => { + ${0} +}); +``` + +### BDD Testing (Mocha, Jasmine, etc.) +#### `desc⇥` describe +```javascript +describe('${1:description}', () => { + ${0} +}); +``` + +#### `cont⇥` context +```javascript +context('${1:description}', () => { + ${0} +}); +``` + +#### `it⇥` it +```javascript +it('${1:description}', () => { + ${0} +}); +``` + +#### `its⇥` it synchronous +```javascript +it('${1:description}', () => { + ${0} +}); +``` + +#### `ita⇥` it asynchronous +```javascript +it('${1:description}', (done) => { + ${0} + done(); +}); +``` + +#### `bf⇥` before test suite +```javascript +before(() => { + ${0} +}); +``` + +#### `bfe⇥` before each test +```javascript +beforeEach(() => { + ${0} +}); +``` + +#### `aft⇥` after test suite +```javascript +after(() => { + ${0} +}); +``` + +#### `afe⇥` after each test +```javascript +afterEach(() => { + ${0} +}); +``` + +### Console +#### `cl⇥` console.log +```javascript +console.log(${0}); +``` + +#### `ce⇥` console.error +```javascript +console.error(${0}); +``` + +#### `cw⇥` console.warn +```javascript +console.warn(${0}); +``` + +#### `cll⇥` console.log labeled +```javascript +console.log('${0}', ${0}); +``` + +#### `cel⇥` console.error labeled +```javascript +console.error('${0}', ${0}); +``` + +#### `cwl⇥` console.warn labeled +```javascript +console.warn('${0}', ${0}); +``` + +### Timers +#### `st⇥` setTimeout +```javascript +setTimeout(() => { + ${0} +}, ${1:delay}); +``` + +#### `si⇥` setInterval +```javascript +setInterval(() => { + ${0} +}, ${1:delay}); +``` + +#### `sim⇥` setImmediate +```javascript +setImmediate(() => { + ${0} +}); +``` + +#### `nt⇥` process nextTick +```javascript +process.nextTick(() => { + ${0} +}); +``` + +### Miscellaneous +#### `us⇥` insert 'use strict' statement +```javascript +'use strict'; +``` diff --git a/snippets/snippets.json b/snippets/snippets.json index 6e56e1d..814139a 100755 --- a/snippets/snippets.json +++ b/snippets/snippets.json @@ -1,384 +1,384 @@ -{ - // Declarations - "var statement": { - "prefix": "v", - "body": "var ${0}" - }, - "var assignment": { - "prefix": "v=", - "body": "var ${1:name} = ${2:value};" - }, - "let statement": { - "prefix": "l", - "body": "let ${0}" - }, - "let assignment": { - "prefix": "l=", - "body": "let ${1:name} = ${2:value};" - }, - "destructuring let assignment": { - "prefix": "dl=", - "body": "let {${1:name}} = ${2:value};" - }, - "const statement": { - "prefix": "co", - "body": "const ${0}" - }, - "const assignment": { - "prefix": "co=", - "body": "const ${1:name} = ${2:value};" - }, - "destructuring const assignment": { - "prefix": "dco=", - "body": "const {${1:name}} = ${2:value};" - }, - // Flow Control - "if statement": { - "prefix": "if", - "body": "if (${1:condition}) {\n\t${0}\n}" - }, - "else statement": { - "prefix": "el", - "body": "else {\n\t${0}\n}" - }, - "if/else statement": { - "prefix": "ife", - "body": "if (${1:condition}) {\n\t${0}\n} else {\n\t\n}" - }, - "else if statement": { - "prefix": "ei", - "body": "else if (${1:condition}) {\n\t${0}\n}" - }, - "ternary operator": { - "prefix": "ter", - "body": "${1:condition} ? ${2:expression} : ${3:expression};" - }, - "for loop": { - "prefix": "fl", - "body": "for (let ${1:i} = 0, ${2:len} = ${3:iterable}.length; ${1:i} < ${2:len}; ${1:i}++) {\n\t${0}\n}" - }, - "reverse for loop": { - "prefix": "rfl", - "body": "for (let ${1:i} = ${2:iterable}.length - 1; ${1:i} >= 0; ${1:i}--) {\n\t${0}\n}" - }, - "for in loop": { - "prefix": "fi", - "body": "for (let ${1:key} in ${2:array}) {\n\tif (${2:array}.hasOwnProperty(${1:key})) {\n\t\t${0}\n\t}\n}" - }, - "for of loop (ES6)": { - "prefix": "fo", - "body": "for (let ${1:key} of ${2:array}) {\n\t${0}\n}" - }, - "while loop": { - "prefix": "wl", - "body": "while (${1:condition}) {\n\t${0}\n}" - }, - "try/catch": { - "prefix": "tc", - "body": "try {\n\t${0}\n} catch (${1:err}) {\n\t\n}" - }, - "try/finally": { - "prefix": "tf", - "body": "try {\n\t${0}\n} finally {\n\t\n}" - }, - "try/catch/finally": { - "prefix": "tcf", - "body": "try {\n\t${0}\n} catch (${1:err}) {\n\t\n} finally {\n\t\n}" - }, - "switch case": { - "prefix": "sw", - "body": "switch (${1:expr}) {\n\tcase ${2:value}:\n\t\treturn $0;\n\tdefault:\n\t\treturn;\n}" - }, - // Functions - "anonymous function": { - "prefix": "f", - "body": "function (${1:arguments}) {\n\t${0}\n}" - }, - "named function": { - "prefix": "fn", - "body": "function ${1:name}(${2:arguments}) {\n\t${0}\n}" - }, - "immediately-invoked function expression (IIFE)": { - "prefix": "iife", - "body": "((${1:arguments}) => {\n\t${0}\n})(${2});" - }, - "function apply": { - "prefix": "fa", - "body": "${1:fn}.apply(${2:this}, ${3:arguments})" - }, - "function call": { - "prefix": "fc", - "body": "${1:fn}.call(${2:this}, ${3:arguments})" - }, - "function bind": { - "prefix": "fb", - "body": "${1:fn}.bind(${2:this}, ${3:arguments})" - }, - "arrow function (ES6)": { - "prefix": "af", - "body": "(${1:arguments}) => ${2:statement}" - }, - "arrow function with body (ES6)": { - "prefix": "afb", - "body": "(${1:arguments}) => {\n\t${0}\n}" - }, - "generator function (ES6)": { - "prefix": "gf", - "body": "function* (${1:arguments}) {\n\t${0}\n}" - }, - "named generator function (ES6)": { - "prefix": "gfn", - "body": "function* ${1:name}(${2:arguments}) {\n\t${0}\n}" - }, - // Iterables - "sequence of 0..n": { - "prefix": "seq", - "body": "[...Array(${1:length}).keys()]${0}" - }, - "forEach loop": { - "prefix": "fe", - "body": "${1}.forEach((${2:item}) => {\n\t${0}\n});" - }, - "map": { - "prefix": "map", - "body": "${1}.map((${2:item}) => {\n\t${0}\n});" - }, - "reduce": { - "prefix": "reduce", - "body": "${1}.reduce((${2:previous}, ${3:current}) => {\n\t${0}\n}${4:, initial});" - }, - "filter": { - "prefix": "filter", - "body": "${1}.filter(${2:item} => {\n\t${0}\n});" - }, - "find": { - "prefix": "find", - "body": "${1}.find(${2:item} => {\n\t${0}\n});" - }, - // Objects and Classes - "object literal": { - "prefix": "ol", - "body": "{\n\tkv${0}\n};" - }, - "same-line object literal": { - "prefix": "slol", - "body": "{ kv${0} };" - }, - "key/value pair": { - "prefix": "kv", - "body": "${1:key}: ${2:value}," - }, - "class (ES6)": { - "prefix": "c", - "body": "class ${1:name} {\n\tconstructor(${2:arguments}) {\n\t\t${0}\n\t}\n}" - }, - "child class (ES6)": { - "prefix": "cex", - "body": "class ${1:name} extends ${2:base} {\n\tconstructor(${3:arguments}) {\n\t\tsuper(${3:arguments});\n\t\t${0}\n\t}\n}" - }, - "class constructor (ES6)": { - "prefix": "ctor", - "body": "constructor(${1:arguments}) {\n\tsuper(${1:arguments});${0}\n}" - }, - "method (ES6 syntax)": { - "prefix": "m", - "body": "${1:method}(${2:arguments}) {\n\t${0}\n}" - }, - "getter (ES6 syntax)": { - "prefix": "get", - "body": "get ${1:property}() {\n\t${0}\n}" - }, - "setter (ES6 syntax)": { - "prefix": "set", - "body": "set ${1:property}(${2:value}) {\n\t${0}\n}" - }, - "getter and setter (ES6 syntax)": { - "prefix": "gs", - "body": "get ${1:property}() {\n\t${0}\n}\nset ${1:property}(${2:value}) {\n\t\n}" - }, - "prototypal constructor": { - "prefix": "pctor", - "body": "var ${1:Class} = function(${2:arguments}) {\n\t${0}\n};" - }, - "prototype method": { - "prefix": "proto", - "body": "${1:Class}.prototype.${2:method} = function(${3:arguments}) {\n\t${0}\n};" - }, - "Object.assign": { - "prefix": "oa", - "body": "Object.assign(${1:dest}, ${2:source})" - }, - "Object.assign copy (shallow clone)": { - "prefix": "oc", - "body": "Object.assign({}, ${1:original}, ${2:source})" - }, - // Returning values - "return": { - "prefix": "r", - "body": "return ${0};" - }, - "return Promise (ES6)": { - "prefix": "rp", - "body": "return new Promise((resolve, reject) => {\n\t${0}\n});" - }, - "return complex value (such as JSX components)": { - "prefix": "rc", - "body": "return (\n\t${0}\n);" - }, - // Types - "typeof": { - "prefix": "tof", - "body": "typeof ${1:source} === '${2:undefined}'" - }, - "instanceof": { - "prefix": "iof", - "body": "${1:source} instanceof ${2:Object}" - }, - // Promises - "Promise (ES6)": { - "prefix": "pr", - "body": "new Promise((resolve, reject) => {\n\t${0}\n})" - }, - "Promise.then": { - "prefix": "then", - "body": "${1:promise}.then((${2:value}) => {\n\t${0}\n})" - }, - "Promise.catch": { - "prefix": "catch", - "body": "${1:promise}.catch((${2:err}) => {\n\t${0}\n})" - }, - // ES6 Modules - "export (ES6)": { - "prefix": "ex", - "body": "export ${1:member};" - }, - "export default (ES6)": { - "prefix": "exd", - "body": "export default ${1:member};" - }, - "import module (ES6)": { - "prefix": "im", - "body": "import ${1:*} from '${2:module}';" - }, - "import module as (ES6)": { - "prefix": "ima", - "body": "import ${1:*} as ${2:name} from '${3:module}';" - }, - // Node.js - "Node.js style callback": { - "prefix": "cb", - "body": "(err, ${1:value}) => {${0}}" - }, - "require": { - "prefix": "re", - "body": "require('${1:module}');" - }, - "require assignment": { - "prefix": "req", - "body": "const ${1:module} = require('${1:module}');" - }, - "destructuring require assignment": { - "prefix": "dreq", - "body": "const {${1:module}} = require('${1:module}');" - }, - "exports.member": { - "prefix": "em", - "body": "exports.${1:member} = ${2:value};" - }, - "module.exports": { - "prefix": "me", - "body": "module.exports = ${1:name};" - }, - "module exports object": { - "prefix": "meo", - "body": "module.exports = {\n\t${1:member}\n};" - }, - "event handler": { - "prefix": "on", - "body": "${1:emitter}.on('${2:event}', (${3:arguments}) => {\n\t${0}\n});" - }, - // BDD Testing (Mocha, Jasmine, etc.) - "describe": { - "prefix": "desc", - "body": "describe('${1:description}', () => {\n\t${0}\n});" - }, - "context": { - "prefix": "cont", - "body": "context('${1:description}', () => {\n\t${0}\n});" - }, - "it": { - "prefix": "it", - "body": "it('${1:description}', () => {\n\t${0}\n});" - }, - "it synchronous": { - "prefix": "its", - "body": "it('${1:description}', () => {\n\t${0}\n});" - }, - "it asynchronous": { - "prefix": "ita", - "body": "it('${1:description}', (done) => {\n\t${0}\n\tdone();\n});" - }, - "before test suite": { - "prefix": "bf", - "body": "before(() => {\n\t${0}\n});" - }, - "before each test": { - "prefix": "bfe", - "body": "beforeEach(() => {\n\t${0}\n});" - }, - "after test suite": { - "prefix": "aft", - "body": "after(() => {\n\t${0}\n});" - }, - "after each test": { - "prefix": "afe", - "body": "afterEach(() => {\n\t${0}\n});" - }, - // Console - "console.log": { - "prefix": "cl", - "body": "console.log(${0});" - }, - "console.error": { - "prefix": "ce", - "body": "console.error(${0});" - }, - "console.warn": { - "prefix": "cw", - "body": "console.warn(${0});" - }, - "console.log labeled": { - "prefix": "cll", - "body": "console.log('${0}', ${0});" - }, - "console.error labeled": { - "prefix": "cel", - "body": "console.error('${0}', ${0});" - }, - "console.warn labeled": { - "prefix": "cwl", - "body": "console.warn('${0}', ${0});" - }, - // Timers - "setTimeout": { - "prefix": "st", - "body": "setTimeout(() => {\n\t${0}\n}, ${1:delay});" - }, - "setInterval": { - "prefix": "si", - "body": "setInterval(() => {\n\t${0}\n}, ${1:delay});" - }, - "setImmediate": { - "prefix": "sim", - "body": "setImmediate(() => {\n\t${0}\n});" - }, - "process nextTick": { - "prefix": "nt", - "body": "process.nextTick(() => {\n\t${0}\n});" - }, - // Miscellaneous - "insert 'use strict' statement": { - "prefix": "us", - "body": "'use strict';" - } +{ + // Declarations + "var statement": { + "prefix": "v", + "body": "var ${0}" + }, + "var assignment": { + "prefix": "v=", + "body": "var ${1:name} = ${2:value};" + }, + "let statement": { + "prefix": "l", + "body": "let ${0}" + }, + "let assignment": { + "prefix": "l=", + "body": "let ${1:name} = ${2:value};" + }, + "destructuring let assignment": { + "prefix": "dl=", + "body": "let {${1:name}} = ${2:value};" + }, + "const statement": { + "prefix": "co", + "body": "const ${0}" + }, + "const assignment": { + "prefix": "co=", + "body": "const ${1:name} = ${2:value};" + }, + "destructuring const assignment": { + "prefix": "dco=", + "body": "const {${1:name}} = ${2:value};" + }, + // Flow Control + "if statement": { + "prefix": "if", + "body": "if (${1:condition}) {\n\t${0}\n}" + }, + "else statement": { + "prefix": "el", + "body": "else {\n\t${0}\n}" + }, + "if/else statement": { + "prefix": "ife", + "body": "if (${1:condition}) {\n\t${0}\n} else {\n\t\n}" + }, + "else if statement": { + "prefix": "ei", + "body": "else if (${1:condition}) {\n\t${0}\n}" + }, + "ternary operator": { + "prefix": "ter", + "body": "${1:condition} ? ${2:expression} : ${3:expression};" + }, + "for loop": { + "prefix": "fl", + "body": "for (let ${1:i} = 0, ${2:len} = ${3:iterable}.length; ${1:i} < ${2:len}; ${1:i}++) {\n\t${0}\n}" + }, + "reverse for loop": { + "prefix": "rfl", + "body": "for (let ${1:i} = ${2:iterable}.length - 1; ${1:i} >= 0; ${1:i}--) {\n\t${0}\n}" + }, + "for in loop": { + "prefix": "fi", + "body": "for (let ${1:key} in ${2:array}) {\n\tif (${2:array}.hasOwnProperty(${1:key})) {\n\t\t${0}\n\t}\n}" + }, + "for of loop (ES6)": { + "prefix": "fo", + "body": "for (let ${1:key} of ${2:array}) {\n\t${0}\n}" + }, + "while loop": { + "prefix": "wl", + "body": "while (${1:condition}) {\n\t${0}\n}" + }, + "try/catch": { + "prefix": "tc", + "body": "try {\n\t${0}\n} catch (${1:err}) {\n\t\n}" + }, + "try/finally": { + "prefix": "tf", + "body": "try {\n\t${0}\n} finally {\n\t\n}" + }, + "try/catch/finally": { + "prefix": "tcf", + "body": "try {\n\t${0}\n} catch (${1:err}) {\n\t\n} finally {\n\t\n}" + }, + "switch case": { + "prefix": "sw", + "body": "switch (${1:expr}) {\n\tcase ${2:value}:\n\t\treturn $0;\n\tdefault:\n\t\treturn;\n}" + }, + // Functions + "anonymous function": { + "prefix": "f", + "body": "function (${1:arguments}) {\n\t${0}\n}" + }, + "named function": { + "prefix": "fn", + "body": "function ${1:name}(${2:arguments}) {\n\t${0}\n}" + }, + "immediately-invoked function expression (IIFE)": { + "prefix": "iife", + "body": "((${1:arguments}) => {\n\t${0}\n})(${2});" + }, + "function apply": { + "prefix": "fa", + "body": "${1:fn}.apply(${2:this}, ${3:arguments})" + }, + "function call": { + "prefix": "fc", + "body": "${1:fn}.call(${2:this}, ${3:arguments})" + }, + "function bind": { + "prefix": "fb", + "body": "${1:fn}.bind(${2:this}, ${3:arguments})" + }, + "arrow function (ES6)": { + "prefix": "af", + "body": "(${1:arguments}) => ${2:statement}" + }, + "arrow function with body (ES6)": { + "prefix": "afb", + "body": "(${1:arguments}) => {\n\t${0}\n}" + }, + "generator function (ES6)": { + "prefix": "gf", + "body": "function* (${1:arguments}) {\n\t${0}\n}" + }, + "named generator function (ES6)": { + "prefix": "gfn", + "body": "function* ${1:name}(${2:arguments}) {\n\t${0}\n}" + }, + // Iterables + "sequence of 0..n": { + "prefix": "seq", + "body": "[...Array(${1:length}).keys()]${0}" + }, + "forEach loop": { + "prefix": "fe", + "body": "${1}.forEach((${2:item}) => {\n\t${0}\n});" + }, + "map": { + "prefix": "map", + "body": "${1}.map((${2:item}) => {\n\t${0}\n});" + }, + "reduce": { + "prefix": "reduce", + "body": "${1}.reduce((${2:previous}, ${3:current}) => {\n\t${0}\n}${4:, initial});" + }, + "filter": { + "prefix": "filter", + "body": "${1}.filter(${2:item} => {\n\t${0}\n});" + }, + "find": { + "prefix": "find", + "body": "${1}.find(${2:item} => {\n\t${0}\n});" + }, + // Objects and Classes + "object literal": { + "prefix": "ol", + "body": "{\n\tkv${0}\n};" + }, + "same-line object literal": { + "prefix": "slol", + "body": "{ kv${0} };" + }, + "key/value pair": { + "prefix": "kv", + "body": "${1:key}: ${2:value}," + }, + "class (ES6)": { + "prefix": "c", + "body": "class ${1:name} {\n\tconstructor(${2:arguments}) {\n\t\t${0}\n\t}\n}" + }, + "child class (ES6)": { + "prefix": "cex", + "body": "class ${1:name} extends ${2:base} {\n\tconstructor(${3:arguments}) {\n\t\tsuper(${3:arguments});\n\t\t${0}\n\t}\n}" + }, + "class constructor (ES6)": { + "prefix": "ctor", + "body": "constructor(${1:arguments}) {\n\tsuper(${1:arguments});${0}\n}" + }, + "method (ES6 syntax)": { + "prefix": "m", + "body": "${1:method}(${2:arguments}) {\n\t${0}\n}" + }, + "getter (ES6 syntax)": { + "prefix": "get", + "body": "get ${1:property}() {\n\t${0}\n}" + }, + "setter (ES6 syntax)": { + "prefix": "set", + "body": "set ${1:property}(${2:value}) {\n\t${0}\n}" + }, + "getter and setter (ES6 syntax)": { + "prefix": "gs", + "body": "get ${1:property}() {\n\t${0}\n}\nset ${1:property}(${2:value}) {\n\t\n}" + }, + "prototypal constructor": { + "prefix": "pctor", + "body": "var ${1:Class} = function(${2:arguments}) {\n\t${0}\n};" + }, + "prototype method": { + "prefix": "proto", + "body": "${1:Class}.prototype.${2:method} = function(${3:arguments}) {\n\t${0}\n};" + }, + "Object.assign": { + "prefix": "oa", + "body": "Object.assign(${1:dest}, ${2:source})" + }, + "Object.assign copy (shallow clone)": { + "prefix": "oc", + "body": "Object.assign({}, ${1:original}, ${2:source})" + }, + // Returning values + "return": { + "prefix": "r", + "body": "return ${0};" + }, + "return Promise (ES6)": { + "prefix": "rp", + "body": "return new Promise((resolve, reject) => {\n\t${0}\n});" + }, + "return complex value (such as JSX components)": { + "prefix": "rc", + "body": "return (\n\t${0}\n);" + }, + // Types + "typeof": { + "prefix": "tof", + "body": "typeof ${1:source} === '${2:undefined}'" + }, + "instanceof": { + "prefix": "iof", + "body": "${1:source} instanceof ${2:Object}" + }, + // Promises + "Promise (ES6)": { + "prefix": "pr", + "body": "new Promise((resolve, reject) => {\n\t${0}\n})" + }, + "Promise.then": { + "prefix": "then", + "body": "${1:promise}.then((${2:value}) => {\n\t${0}\n})" + }, + "Promise.catch": { + "prefix": "catch", + "body": "${1:promise}.catch((${2:err}) => {\n\t${0}\n})" + }, + // ES6 Modules + "export (ES6)": { + "prefix": "ex", + "body": "export ${1:member};" + }, + "export default (ES6)": { + "prefix": "exd", + "body": "export default ${1:member};" + }, + "import module (ES6)": { + "prefix": "im", + "body": "import ${1:*} from '${2:module}';" + }, + "import module as (ES6)": { + "prefix": "ima", + "body": "import ${1:*} as ${2:name} from '${3:module}';" + }, + // Node.js + "Node.js style callback": { + "prefix": "cb", + "body": "(err, ${1:value}) => {${0}}" + }, + "require": { + "prefix": "re", + "body": "require('${1:module}');" + }, + "require assignment": { + "prefix": "req", + "body": "const ${1:module} = require('${1:module}');" + }, + "destructuring require assignment": { + "prefix": "dreq", + "body": "const {${1:module}} = require('${1:module}');" + }, + "exports.member": { + "prefix": "em", + "body": "exports.${1:member} = ${2:value};" + }, + "module.exports": { + "prefix": "me", + "body": "module.exports = ${1:name};" + }, + "module exports object": { + "prefix": "meo", + "body": "module.exports = {\n\t${1:member}\n};" + }, + "event handler": { + "prefix": "on", + "body": "${1:emitter}.on('${2:event}', (${3:arguments}) => {\n\t${0}\n});" + }, + // BDD Testing (Mocha, Jasmine, etc.) + "describe": { + "prefix": "desc", + "body": "describe('${1:description}', () => {\n\t${0}\n});" + }, + "context": { + "prefix": "cont", + "body": "context('${1:description}', () => {\n\t${0}\n});" + }, + "it": { + "prefix": "it", + "body": "it('${1:description}', () => {\n\t${0}\n});" + }, + "it synchronous": { + "prefix": "its", + "body": "it('${1:description}', () => {\n\t${0}\n});" + }, + "it asynchronous": { + "prefix": "ita", + "body": "it('${1:description}', (done) => {\n\t${0}\n\tdone();\n});" + }, + "before test suite": { + "prefix": "bf", + "body": "before(() => {\n\t${0}\n});" + }, + "before each test": { + "prefix": "bfe", + "body": "beforeEach(() => {\n\t${0}\n});" + }, + "after test suite": { + "prefix": "aft", + "body": "after(() => {\n\t${0}\n});" + }, + "after each test": { + "prefix": "afe", + "body": "afterEach(() => {\n\t${0}\n});" + }, + // Console + "console.log": { + "prefix": "cl", + "body": "console.log(${0});" + }, + "console.error": { + "prefix": "ce", + "body": "console.error(${0});" + }, + "console.warn": { + "prefix": "cw", + "body": "console.warn(${0});" + }, + "console.log labeled": { + "prefix": "cll", + "body": "console.log('${0}', ${0});" + }, + "console.error labeled": { + "prefix": "cel", + "body": "console.error('${0}', ${0});" + }, + "console.warn labeled": { + "prefix": "cwl", + "body": "console.warn('${0}', ${0});" + }, + // Timers + "setTimeout": { + "prefix": "st", + "body": "setTimeout(() => {\n\t${0}\n}, ${1:delay});" + }, + "setInterval": { + "prefix": "si", + "body": "setInterval(() => {\n\t${0}\n}, ${1:delay});" + }, + "setImmediate": { + "prefix": "sim", + "body": "setImmediate(() => {\n\t${0}\n});" + }, + "process nextTick": { + "prefix": "nt", + "body": "process.nextTick(() => {\n\t${0}\n});" + }, + // Miscellaneous + "insert 'use strict' statement": { + "prefix": "us", + "body": "'use strict';" + } } \ No newline at end of file