Skip to content

Commit 261bcab

Browse files
committed
snippets change and updated readme
1 parent 04c3b99 commit 261bcab

File tree

2 files changed

+214
-2
lines changed

2 files changed

+214
-2
lines changed

README.md

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,215 @@
44

55
### A collection of common javascript statement snippets for faster development in [Visual Studio Code](https://code.visualstudio.com/).
66

7+
***
8+
9+
* [Assignments](#assignments)
10+
* [Functions](#functions)
11+
* [Conditions](#conditions)
12+
* [Validations](#validations)
13+
* [DOM manipulations](#dom-manipulations)
14+
* [Others](#others)
15+
16+
***
17+
18+
## Assignments
19+
20+
#### `la =>` let assignment
21+
22+
```js
23+
let ${1:name} = ${2:value}
24+
```
25+
26+
#### `va =>` var assignment
27+
28+
```js
29+
var ${1:name} = ${2:value}
30+
```
31+
32+
#### `ca =>` const assignment
33+
34+
```js
35+
const ${1:name} = ${2:value}
36+
```
37+
38+
#### `aa =>` array assignment
39+
40+
```js
41+
let ${1:name} = [${2:value1}, ${3:value2}]
42+
```
43+
44+
#### `oa =>` object assignment
45+
46+
```js
47+
let ${1:obj} = {
48+
"${2:key}": ${3:value}
49+
}
50+
```
51+
52+
***
53+
54+
## Functions
55+
56+
#### `af =>` arrow function
57+
58+
```js
59+
const ${1:name} = (${2:param}) => {
60+
61+
}
62+
```
63+
64+
#### `nf =>` named function
65+
66+
```js
67+
function ${1:name} (${2:param}) {
68+
69+
}
70+
```
71+
72+
***
73+
74+
## Conditions
75+
76+
#### `ac =>` and condition
77+
78+
```js
79+
${1:condition1} && ${2:condition2}
80+
```
81+
82+
#### `oc =>` or condition
83+
84+
```js
85+
${1:condition1} || ${2:condition2}
86+
```
87+
88+
#### `co =>` condition operator
89+
90+
```js
91+
let ${1:name} = ${2:condition} ? ${3:value1} : ${4:value2}
92+
```
93+
94+
***
95+
96+
## Validations
97+
98+
#### `lv =>` length validation
99+
100+
```js
101+
${1:value}.length === ${2:0}
102+
```
103+
104+
#### `nv =>` null validation
105+
106+
```js
107+
${1:value} === null
108+
```
109+
110+
#### `nnv =>` not null validation
111+
112+
```js
113+
${1:value} !== null
114+
```
115+
116+
#### `uv =>` undefined validation
117+
118+
```js
119+
typeof ${1:value} === "undefined"
120+
```
121+
122+
#### `nuv =>` not undefined validation
123+
124+
```js
125+
typeof ${1:value} !== "undefined"
126+
```
127+
128+
#### `cv =>` contains validation
129+
130+
```js
131+
${1:value}.indexOf(${2:value2}) > -1
132+
```
133+
134+
#### `dcv =>` doesn't contain validation
135+
136+
```js
137+
${1:value}.indexOf(${2:value2}) === -1
138+
```
139+
140+
***
141+
142+
## DOM manipulations
143+
144+
#### `ael =>` add event listener
145+
146+
```js
147+
document.addEventListener("${1:event}", (${2:param}) => {
148+
149+
})
150+
```
151+
152+
#### `rel =>` remove event listener
153+
154+
```js
155+
document.removeEventListener("${1:event}", (${2:param}) => {
156+
157+
})
158+
```
159+
160+
#### `ce =>` create element
161+
162+
```js
163+
document.createElement("${1:element}")
164+
```
165+
166+
#### `gei =>` get element by id
167+
168+
```js
169+
document.getElementById("${1:id}")
170+
```
171+
172+
#### `gec =>` get element by class name
173+
174+
```js
175+
document.getElementsByClassName("${1:class}")
176+
```
177+
178+
#### `qs =>` query selector
179+
180+
```js
181+
document.querySelector("${1:selector}")
182+
```
183+
184+
#### `qsa =>` query selector all
185+
186+
```js
187+
document.querySelectorAll("${1:selector}")
188+
```
189+
190+
***
191+
192+
## Others
193+
194+
#### `od =>` object destructuring
195+
196+
```js
197+
const { ${1:name} } = ${2:value}
198+
```
199+
200+
#### `cl =>` console log
201+
202+
```js
203+
console.log(${1:value})
204+
```
205+
206+
***
207+
208+
## Questions, problems or something else?
209+
210+
### There is a bug? Leave an issue on the [issues](https://github.com/mdyakov/SnipJS/issues) page or send a [pull request](https://github.com/mdyakov/SnipJS/pulls) with new features.
211+
212+
### For questions, do not hesitate to write me an email - *dimitar.dyakov98@gmail.com*
213+
214+
### Leave a star if you like and find the snippets helpful!
215+
216+
***
217+
218+
**Code by Dimitar Dyakov. Copyright 2019**

snippets/snippets.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
},
8686
"Remove event listener": {
8787
"prefix": "rel",
88-
"body": "document.removeEventListener(\"${1:event}\", (${2:param}) => {\n\t${0}\n});"
88+
"body": "document.removeEventListener(\"${1:event}\", (${2:param}) => {\n\t${0}\n})"
8989
},
9090
"Create element": {
9191
"prefix": "ce",
@@ -97,7 +97,7 @@
9797
},
9898
"Get element by class name": {
9999
"prefix": "gec",
100-
"body": "document.getElementsByClassName(\"${1:className}\")"
100+
"body": "document.getElementsByClassName(\"${1:class}\")"
101101
},
102102
"Query selector": {
103103
"prefix": "qs",

0 commit comments

Comments
 (0)