Skip to content

Commit f8c6ed1

Browse files
committed
Initial commit
0 parents  commit f8c6ed1

File tree

7 files changed

+213
-0
lines changed

7 files changed

+213
-0
lines changed

.gitignore

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Runtime data
7+
pids
8+
*.pid
9+
*.seed
10+
11+
# Directory for instrumented libs generated by jscoverage/JSCover
12+
lib-cov
13+
14+
# Coverage directory used by tools like istanbul
15+
coverage
16+
17+
# nyc test coverage
18+
.nyc_output
19+
20+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21+
.grunt
22+
23+
# node-waf configuration
24+
.lock-wscript
25+
26+
# Compiled binary addons (http://nodejs.org/api/addons.html)
27+
build/Release
28+
29+
# Dependency directories
30+
node_modules
31+
jspm_packages
32+
.vscode/**
33+
.vscode-test/**
34+
35+
# Optional npm cache directory
36+
.npm
37+
38+
# Optional REPL history
39+
.node_repl_history

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
## [1.0.0]
2+
- Initial release of SnipJS snippets.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Dimitar Dyakov
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# SnipJS
2+
3+
[logo]: https://github.com/mdyakov/SnipJS/logo.png
4+
5+
### A collection of common javascript statement snippets for faster development in [Visual Studio Code](https://code.visualstudio.com/).
6+

logo.png

4.51 KB
Loading

package.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "snipjs",
3+
"author": {
4+
"name": "Dimitar Dyakov",
5+
"email": "dimitar.dyakov98@gmail.com",
6+
"url": "https://www.linkedin.com/in/ddyakov/"
7+
},
8+
"keywords": ["javascript", "snippets", "vscode"],
9+
"repository": {
10+
"type": "git",
11+
"url": "https://github.com/mdyakov/SnipJS"
12+
},
13+
"displayName": "SnipJS",
14+
"description": "Common javascript statement snippets.",
15+
"version": "1.0.0",
16+
"icon": "logo.png",
17+
"engines": {
18+
"vscode": "^1.30.0"
19+
},
20+
"categories": [
21+
"Snippets"
22+
],
23+
"contributes": {
24+
"snippets": [
25+
{
26+
"language": "javascript",
27+
"path": "./snippets/snippets.json"
28+
},
29+
{
30+
"language": "typescript",
31+
"path": "./snippets/snippets.json"
32+
}
33+
]
34+
}
35+
}

snippets/snippets.json

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
{
2+
"Let assignment": {
3+
"prefix": "la",
4+
"body": "let ${1:name} = ${2:value}"
5+
},
6+
"Var assignment": {
7+
"prefix": "va",
8+
"body": "var ${1:name} = ${2:value}"
9+
},
10+
"Const assignment": {
11+
"prefix": "ca",
12+
"body": "const ${1:name} = ${2:value}"
13+
},
14+
"Object assignment": {
15+
"prefix": "oa",
16+
"body": [
17+
"let ${1:obj} = {",
18+
" \"${2:key}\": ${3:value}",
19+
"}"
20+
]
21+
},
22+
"Array assignment": {
23+
"prefix": "aa",
24+
"body": "let ${1:name} = [${2:value1}, ${3:value2}]"
25+
},
26+
"Object destructuring": {
27+
"prefix": "od",
28+
"body": "const { ${1:name} } = ${2:value}"
29+
},
30+
"Console log": {
31+
"prefix": "cl",
32+
"body": "console.log(${1:value})"
33+
},
34+
"Arrow function": {
35+
"prefix": "af",
36+
"body": "const ${1:name} = (${2:param}) => {\n\t${0}\n}"
37+
},
38+
"Named function": {
39+
"prefix": "nf",
40+
"body": "function ${1:name} (${2:param}) {\n\t${0}\n}"
41+
},
42+
"And condition": {
43+
"prefix": "ac",
44+
"body": "${1:condition1} && ${2:condition2}"
45+
},
46+
"Or condition": {
47+
"prefix": "oc",
48+
"body": "${1:condition1} || ${2:condition2}"
49+
},
50+
"Condition operator": {
51+
"prefix": "co",
52+
"body": "let ${1:name} = ${2:condition} ? ${3:value1} : ${4:value2}"
53+
},
54+
"Length validation": {
55+
"prefix": "lv",
56+
"body": "${1:value}.length === ${2:0}"
57+
},
58+
"Null validation": {
59+
"prefix": "nv",
60+
"body": "${1:value} === null"
61+
},
62+
"Not null validation": {
63+
"prefix": "nnv",
64+
"body": "${1:value} !== null"
65+
},
66+
"Undefined validation": {
67+
"prefix": "uv",
68+
"body": "typeof ${1:value} === \"undefined\""
69+
},
70+
"Contains validation": {
71+
"prefix": "cv",
72+
"body": "${1:value}.indexOf(${2:value2}) > -1"
73+
},
74+
"Doesn't contain validation": {
75+
"prefix": "dcv",
76+
"body": "${1:value}.indexOf(${2:value2}) === -1"
77+
},
78+
"Not undefined validation": {
79+
"prefix": "nuv",
80+
"body": "typeof ${1:value} !== \"undefined\""
81+
},
82+
"Add event listener": {
83+
"prefix": "ael",
84+
"body": "document.addEventListener(\"${1:event}\", (${2:param}) => {\n\t${0}\n})"
85+
},
86+
"Remove event listener": {
87+
"prefix": "rel",
88+
"body": "document.removeEventListener(\"${1:event}\", (${2:param}) => {\n\t${0}\n});"
89+
},
90+
"Create element": {
91+
"prefix": "ce",
92+
"body": "document.createElement(\"${1:element}\")"
93+
},
94+
"Get element by id": {
95+
"prefix": "gei",
96+
"body": "document.getElementById(\"${1:id}\")"
97+
},
98+
"Get element by class name": {
99+
"prefix": "gec",
100+
"body": "document.getElementsByClassName(\"${1:className}\")"
101+
},
102+
"Query selector": {
103+
"prefix": "qs",
104+
"body": "document.querySelector(\"${1:selector}\")"
105+
},
106+
"Query selector all": {
107+
"prefix": "qsa",
108+
"body": "document.querySelectorAll(\"${1:selector}\")"
109+
}
110+
}

0 commit comments

Comments
 (0)