Last active
September 10, 2018 19:29
-
-
Save shovanch/d2ae1c1cdecd0ea896f77842aef28790 to your computer and use it in GitHub Desktop.
VSCode Javascript snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| // Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and | |
| // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
| // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the | |
| // same ids are connected. | |
| // Example: | |
| // "Print to console": { | |
| // "prefix": "log", | |
| // "body": [ | |
| // "console.log('$1');", | |
| // "$2" | |
| // ], | |
| // "description": "Log output to console" | |
| // } | |
| "let variable declaration": { | |
| "prefix": "l", | |
| "body": [ | |
| "let ${1:name} " | |
| ], | |
| "description": "let variable declaration", | |
| }, | |
| "let assignment": { | |
| "prefix": "l=", | |
| "body": [ | |
| "let ${1:name} = ${2:value};" | |
| ], | |
| "description": "let assignment" | |
| }, | |
| "const variable declaration": { | |
| "prefix": "co", | |
| "body": [ | |
| "const ${1:name} " | |
| ], | |
| "description": "const variable declaration" | |
| }, | |
| "const variable assignment": { | |
| "prefix": "co=", | |
| "body": [ | |
| "const ${1:name} = ${2:value};" | |
| ], | |
| "description": "const variable assignment" | |
| }, | |
| "if statement": { | |
| "prefix": "if", | |
| "body": [ | |
| "if (${1:condition}) {", | |
| " ${0}", | |
| "}" | |
| ], | |
| "description": "if statement" | |
| }, | |
| "else statement": { | |
| "prefix": "el", | |
| "body": [ | |
| "else {", | |
| " ${0}", | |
| "}" | |
| ], | |
| "description": "else statement" | |
| }, | |
| "if-else statement": { | |
| "prefix": "ife", | |
| "body": [ | |
| "if (${1:condition}) {", | |
| " ${2}", | |
| "} else {", | |
| " ${3}", | |
| "}" | |
| ], | |
| "description": "if-else statement" | |
| }, | |
| "else-if statement": { | |
| "prefix": "ei", | |
| "body": [ | |
| "else if (${1:condition}) {", | |
| " ${0}", | |
| "}" | |
| ], | |
| "description": "else-if statement" | |
| }, | |
| "key/value pair": { | |
| "prefix": ":", | |
| "body": [ | |
| "${1:key}: ${2:'value'}", | |
| "" | |
| ], | |
| "description": "key/value pair" | |
| }, | |
| "return": { | |
| "prefix": "r", | |
| "body": [ | |
| "return ${0};" | |
| ], | |
| "description": "return" | |
| }, | |
| "return true": { | |
| "prefix": "rt", | |
| "body": [ | |
| "return true;", | |
| "" | |
| ], | |
| "description": "return true" | |
| }, | |
| "return false": { | |
| "prefix": "rf", | |
| "body": [ | |
| "return false;", | |
| "" | |
| ], | |
| "description": "return false" | |
| }, | |
| "map": { | |
| "prefix": "map", | |
| "body": [ | |
| "${1:iterable}.map(${2:iterator});" | |
| ], | |
| "description": "map method" | |
| }, | |
| "chain map mathod": { | |
| "prefix": ".map", | |
| "body": [ | |
| ".map(${1:iterator});", | |
| "" | |
| ], | |
| "description": "chain map mathod" | |
| }, | |
| "reduce method": { | |
| "prefix": "reduce", | |
| "body": [ | |
| "${1:iterable}.reduce((${2:previous}, ${3:current}) => {", | |
| " ${0}", | |
| "}${4:, initial});" | |
| ], | |
| "description": "reduce method" | |
| }, | |
| "chain reduce method": { | |
| "prefix": ".reduce", | |
| "body": [ | |
| ".reduce((${1:previous}, ${2:current}) => {", | |
| " ${0}", | |
| "}${3:, initial});" | |
| ], | |
| "description": "chain reduce method" | |
| }, | |
| "filter method": { | |
| "prefix": "filter", | |
| "body": [ | |
| "${1:iterable}.filter(${2:iterator});" | |
| ], | |
| "description": "filter method" | |
| }, | |
| "chain filter method": { | |
| "prefix": ".filter", | |
| "body": [ | |
| ".filter(${1:iterator});" | |
| ], | |
| "description": "chain filter method" | |
| }, | |
| "find method": { | |
| "prefix": "find", | |
| "body": [ | |
| "${1:iterable}.find(${2:iterator});", | |
| "" | |
| ], | |
| "description": "find method" | |
| }, | |
| "chain find method": { | |
| "prefix": ".find", | |
| "body": [ | |
| ".find(${1:iterator});", | |
| "" | |
| ], | |
| "description": "chain find method" | |
| }, | |
| "JSON key/value pair": { | |
| "prefix": ";", | |
| "body": [ | |
| "\"${1:key}\": \"${2:value}\"" | |
| ], | |
| "description": "JSON key/value pair" | |
| }, | |
| "JSON array": { | |
| "prefix": ";a", | |
| "body": [ | |
| "\"${1:key}\": [\"${2:values}\"]" | |
| ], | |
| "description": "JSON array" | |
| }, | |
| "for loop": { | |
| "prefix": "fl", | |
| "body": [ | |
| "for (let ${1:i} = 0; ${1:i} < ${2:iterable}${3:.length}; ${1:i}++) {", | |
| " ${4}", | |
| "}" | |
| ], | |
| "description": "for loop" | |
| }, | |
| "Object key/value pair": { | |
| "prefix": "kv", | |
| "body": [ | |
| "${1:key}: ${2:'value'}" | |
| ], | |
| "description": "Object key/value pair" | |
| }, | |
| "prototype method": { | |
| "prefix": "proto", | |
| "body": [ | |
| "${1:ClassName}.prototype.${2:key} = ${3:value}" | |
| ], | |
| "description": "prototype method" | |
| }, | |
| "chain prototype method": { | |
| "prefix": ".proto", | |
| "body": [ | |
| ".prototype.${2:key} = ${3:value}" | |
| ], | |
| "description": "chain prototype method" | |
| }, | |
| " Promise.then": { | |
| "prefix": "then", | |
| "body": [ | |
| "${1:promise}.then((${2:value}) => {${0}});" | |
| ], | |
| "description": " Promise.then" | |
| }, | |
| "chain .then": { | |
| "prefix": ".then", | |
| "body": [ | |
| ".then((${1:value}) => {${0}})" | |
| ], | |
| "description": "chain .then" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment