File tree Expand file tree Collapse file tree 8 files changed +62
-14
lines changed Expand file tree Collapse file tree 8 files changed +62
-14
lines changed Original file line number Diff line number Diff line change 5
5
- [ jQuery] ( jquery/ )
6
6
- [ Patterns] ( patterns/ )
7
7
- [ Design Patterns] ( patterns/design-patterns/ )
8
+ - [ UMD] ( patterns/umd/ )
8
9
- [ Tests] ( tests/ )
9
10
- [ Common] ( common/ )
10
11
- [ Chai] ( chai/ )
Original file line number Diff line number Diff line change 11
11
### [ jdp.constructor] Contructor
12
12
13
13
``` javascript
14
-
14
+ var ${1 : ConstructorName} = (function () {
15
+ ' use strict' ;
16
+ function ${1:ConstructorName}($ {2 : args}) {
17
+ // enforces new
18
+ if (! (this instanceof ${1 : ConstructorName})) {
19
+ return new $ {1 : ConstructorName}(${2 : args});
20
+ }
21
+ ${3 : // constructor body
22
+ }
23
+ }
24
+ ${4 : ${1 : ConstructorName}.prototype .$ {5 : methodName} = function ($ {6 : args}) \{
25
+ ${7 : // method body
26
+ }
27
+ \}};
28
+ return ${1 : ConstructorName};
29
+ }());
15
30
```
16
31
17
32
### [ jdp.decorator] Decorator
53
68
### [ jdp.module] Module
54
69
55
70
``` javascript
56
-
71
+ var ${1 : moduleName} = (function () {
72
+ ' use strict' ;
73
+ var ${1 : moduleName} = {
74
+ init: {
75
+ $2
76
+ }
77
+ };
78
+ return ${1 : moduleName};
79
+ }());
57
80
```
58
81
59
82
### [ jdp.observer] Observer
65
88
### [ jdp.prototype] Prototype
66
89
67
90
``` javascript
68
-
91
+ function ${1:Car}() {
92
+ // constructor...
93
+ }
94
+ ${2 : ${1 : Car}.prototype .$ {3 : drive} = function () \{
95
+ ${4 : // body...
96
+ }
97
+ \};}
98
+ return ${1 : Car};
99
+ ${0 }
69
100
```
70
101
71
102
### [ jdp.rmodule] Revealing Module
77
108
### [ jdp.singleton] Singleton
78
109
79
110
``` javascript
80
-
111
+ var ${1 : name} = (function () {
112
+ ' use strict' ;
113
+ var instance;
114
+ ${1 : name} = function ($ {2 : args}) {
115
+ if (instance) {
116
+ return instance;
117
+ }
118
+ instance = this ;
119
+ ${3 : // your code goes here
120
+ }
121
+ };
122
+ return ${1 : name};
81
123
` ` `
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ var ${1:ConstructorName} = (function() {
9
9
}
10
10
${3:// constructor body}
11
11
}
12
- ${4:${1:ConstructorName}.prototype.${5:methodName} = function(${6:args}) {
12
+ ${4:${1:ConstructorName}.prototype.${5:methodName} = function(${6:args}) \ {
13
13
${7:// method body}
14
14
\}};
15
15
return ${1:ConstructorName};
Original file line number Diff line number Diff line change 1
1
<snippet >
2
2
<content ><![CDATA[
3
3
function ${1:Car}() {
4
- // constructor...
4
+ // constructor...
5
5
}
6
6
${2:${1:Car}.prototype.${3:drive} = function () \{
7
- ${4: // body...}
7
+ ${4: // body...}
8
8
\};}
9
9
return ${1:Car};
10
10
${0}
Original file line number Diff line number Diff line change 1
1
# Tests JavaScript Snippets
2
2
3
- - [ Structure ] ( structure /)
3
+ - [ Common ] ( common /)
4
4
- afterEach
5
5
- after
6
6
- beforeEach
42
42
- toMatch
43
43
- toThrowError
44
44
- toThrow
45
+ - [ Mocha] ( mocha/ )
46
+ -
45
47
- [ Node] ( node/ )
46
48
- assert
47
49
- ok
57
59
- notStrictEqual
58
60
- strictEqual
59
61
- throws
62
+ - [ QUnit] ( qunit/ )
63
+ -
60
64
- [ Sinon] ( sinon/ )
65
+ -
Original file line number Diff line number Diff line change 1
1
# Mocha JavaScript Snippets
2
2
3
- ## Prefix ` tb .*`
3
+ ## Prefix ` tm .*`
4
4
5
- ### [ tt.dequal ] deepEqual
5
+ ### [ tm. ]
6
6
7
7
``` javascript
8
8
Original file line number Diff line number Diff line change 1
1
# QUnit JavaScript Snippets
2
2
3
- ## Prefix ` tb .*`
3
+ ## Prefix ` tq .*`
4
4
5
- ### [ tt.dequal ] deepEqual
5
+ ### [ tq. ]
6
6
7
7
``` javascript
8
8
Original file line number Diff line number Diff line change 1
1
# Sinon JavaScript Snippets
2
2
3
- ## Prefix ` tb .*`
3
+ ## Prefix ` ts .*`
4
4
5
- ### [ tt.dequal ] deepEqual
5
+ ### [ ts. ]
6
6
7
7
``` javascript
8
8
You can’t perform that action at this time.
0 commit comments