Files
vscode/extensions/javascript/snippets/javascriptreact.json
Oliver Joseph Ash 81444f43fa Add import statement snippet to .js(x) files (#34682)
* Add import statement snippet to JS files

This makes them consistent with TS files.

* Add import statement snippet to jsx files
2017-09-20 08:49:57 -07:00

149 lines
2.7 KiB
JSON

{
"define module": {
"prefix": "define",
"body": [
"define([",
"\t'require',",
"\t'${1:dependency}'",
"], function(require, ${2:factory}) {",
"\t'use strict';",
"\t$0",
"});"
],
"description": "define module"
},
"For Loop": {
"prefix": "for",
"body": [
"for (var ${1:index} = 0; ${1:index} < ${2:array}.length; ${1:index}++) {",
"\tvar ${3:element} = ${2:array}[${1:index}];",
"\t$0",
"}"
],
"description": "For Loop"
},
"For-Each Loop": {
"prefix": "foreach",
"body": [
"${1:array}.forEach(function(${2:element}) {",
"\t$0",
"}, this);"
],
"description": "For-Each Loop"
},
"For-In Loop": {
"prefix": "forin",
"body": [
"for (var ${1:key} in ${2:object}) {",
"\tif (${2:object}.hasOwnProperty(${1:key})) {",
"\t\tvar ${3:element} = ${2:object}[${1:key}];",
"\t\t$0",
"\t}",
"}"
],
"description": "For-In Loop"
},
"Function Statement": {
"prefix": "function",
"body": [
"function ${1:name}(${2:params}) {",
"\t$0",
"}"
],
"description": "Function Statement"
},
"If Statement": {
"prefix": "if",
"body": [
"if (${1:condition}) {",
"\t$0",
"}"
],
"description": "If Statement"
},
"If-Else Statement": {
"prefix": "ifelse",
"body": [
"if (${1:condition}) {",
"\t$0",
"} else {",
"\t",
"}"
],
"description": "If-Else Statement"
},
"New Statement": {
"prefix": "new",
"body": [
"var ${1:name} = new ${2:type}(${3:arguments});$0"
],
"description": "New Statement"
},
"Switch Statement": {
"prefix": "switch",
"body": [
"switch (${1:key}) {",
"\tcase ${2:value}:",
"\t\t$0",
"\t\tbreak;",
"",
"\tdefault:",
"\t\tbreak;",
"}"
],
"description": "Switch Statement"
},
"While Statement": {
"prefix": "while",
"body": [
"while (${1:condition}) {",
"\t$0",
"}"
],
"description": "While Statement"
},
"Do-While Statement": {
"prefix": "dowhile",
"body": [
"do {",
"\t$0",
"} while (${1:condition});"
],
"description": "Do-While Statement"
},
"Try-Catch Statement": {
"prefix": "trycatch",
"body": [
"try {",
"\t$0",
"} catch (${2:error}) {",
"\t",
"}"
],
"description": "Try-Catch Statement"
},
"Set Timeout Function": {
"prefix": "settimeout",
"body": [
"setTimeout(function() {",
"\t$0",
"}, ${1:timeout});"
],
"description": "Set Timeout Function"
},
"Relative Reference to another File": {
"prefix": "reference",
"body": [
"/// <reference path=\"$1\" />$0"
],
"description": "Relative Reference to another File"
},
"Import external module.": {
"prefix": "import statement",
"body": [
"import { $0 } from \"${1:module}\";"
],
"description": "Import external module."
}
}