add javascript react snippets

fixes #3415
This commit is contained in:
Joao Moreno
2016-02-26 10:31:26 +01:00
parent b534d175c8
commit cfbf9294e4
2 changed files with 145 additions and 0 deletions

View File

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