-
Notifications
You must be signed in to change notification settings - Fork 230
/
Copy pathjavascript.snip
211 lines (174 loc) · 3.31 KB
/
javascript.snip
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
snippet :f
options head
${1:#:method_name}: function(${2:#:attribute}) {
${0:TARGET}
}
snippet function
abbr func
options word
function ${1:#:function_name}(${2:#:argument}) {
${0:TARGET}
}
snippet function2
abbr func2
options head
function ${1:function_name}(${2:argument}) {
${0:TARGET}
}
snippet proto
options head
${1:#:class_name}.prototype.${2:#:method_name} = function(${3:#:first_argument}) {
${0:TARGET}
};
snippet f
options word
function(${1}) { ${0:TARGET} };
snippet if
options head
if (${1:true}) {
${0:TARGET}
}
snippet if-else
abbr ife
options head
if (${1:#:condition}) {
${2:TARGET}
} else {
${3}
}
snippet for
options head
for (let ${1:i} = 0; $1 < ${2:#:Things}.length; ++$1) {
${0:TARGET}
}
snippet forin
options head
for (let ${1:i} in ${2:#:Things}) {
${0:TARGET}
}
snippet forof
options head
for (let ${1:i} of ${2:#:Things}) {
${0:TARGET}
}
snippet while
options head
while (${1:true}) {
${0:TARGET}
}
snippet switch
options head
switch (${1:#:let}) {
case ${2:#:val}:
${0:TARGET}
break;
}
snippet try
options head
try {
${1:TARGET}
} catch (${2:e}) {
${3}
}
snippet try_finally
options head
try {
${1:TARGET}
} catch (${2:e}) {
${3}
} finally {
${4}
}
snippet key-value
abbr :,
options word
${1:#:value_name}: ${0:#:value},
#snippet key
#options word
# ${1:#:key}: "${2:#:value}"}${3:, }
snippet setTimeout-function
options head
setTimeout(function() { ${0} }, ${1:10});
snippet debugger
alias db
options head
debugger;
snippet console-log
alias cl
options head
console.log(${0:TARGET});
snippet console-trace
alias ct
options head
console.trace();
snippet console-error
alias ce
options head
console.error(${0:TARGET});
snippet console-warn
alias cw
options head
console.warn(${0:TARGET});
snippet console-info
alias ci
options head
console.info(${0:TARGET});
snippet iife
options head
(function(${1}) {
'use strict';
${0:TARGET}
})(${2});
snippet js
options head
JSON.stringify(${1:TARGET}, null, 2);
snippet jsc
options head
console.log(JSON.stringify(${1:TARGET}, null, 2));
snippet class
abbr class {...}
options head
class ${1:#:NAME} {
constructor(${2:#:ARGS}) {
${0:TARGET}
}
}
snippet class-extends
abbr class extends {...}
options head
class ${1:#:NAME} extends ${2:#:SuperClass} {
constructor(${3:#:ARGS}) {
${0:TARGET}
}
}
snippet static
options head
static ${1:#:NAME}(${2:#:ARGS}) {
${0:TARGET}
}
snippet set
options head
set ${1:#:NAME}(${2:#:ARGS}) {
${0:TARGET}
}
snippet get
options head
get ${1:#:NAME}() {
${0:TARGET}
}
snippet import
abbr import { member, ... } from "module-name";
options head
import { ${1:MEMBERS} } from "${0:TARGET}";
snippet import-default
abbr import defaultMember from "module-name";
options head
import ${1:defaultMember} from "${0:TARGET}";
snippet import-all
abbr import * as NAME from "...";
options head
import * as ${1:NAME} from "${0:TARGET}";
snippet import-default-member
abbr import defaultMember, { member, ... } from "module-name";
options head
import ${1:defaultMember}, { ${2:MEMBERS} } from "${0:TARGET}";