1
- "use strict" ;
2
-
3
1
define ( [ "exports" ] , function ( exports ) {
4
- var _slice = Array . prototype . slice ;
2
+ "use strict" ;
3
+
5
4
var _inherits = function ( child , parent ) {
5
+ if ( typeof parent !== "function" && parent !== null ) {
6
+ throw new TypeError ( "Super expression must either be null or a function, not " + typeof parent ) ;
7
+ }
6
8
child . prototype = Object . create ( parent && parent . prototype , {
7
9
constructor : {
8
10
value : child ,
@@ -14,147 +16,234 @@ define(["exports"], function (exports) {
14
16
if ( parent ) child . __proto__ = parent ;
15
17
} ;
16
18
19
+ var _prototypeProperties = function ( child , staticProps , instanceProps ) {
20
+ if ( staticProps ) Object . defineProperties ( child , staticProps ) ;
21
+ if ( instanceProps ) Object . defineProperties ( child . prototype , instanceProps ) ;
22
+ } ;
23
+
17
24
var Inject = function Inject ( ) {
18
- var keys = _slice . call ( arguments ) ;
25
+ var keys = [ ] ;
26
+
27
+ for ( var _key = 0 ; _key < arguments . length ; _key ++ ) {
28
+ keys [ _key ] = arguments [ _key ] ;
29
+ }
19
30
20
31
this . keys = keys ;
21
32
} ;
22
33
23
34
exports . Inject = Inject ;
24
- var Registration = function Registration ( ) { } ;
35
+ var Registration = ( function ( ) {
36
+ var Registration = function Registration ( ) { } ;
37
+
38
+ _prototypeProperties ( Registration , null , {
39
+ register : {
40
+ value : function ( container , key , fn ) {
41
+ throw new Error ( "A custom Registration must implement register(container, key, fn)." ) ;
42
+ } ,
43
+ writable : true ,
44
+ enumerable : true ,
45
+ configurable : true
46
+ }
47
+ } ) ;
25
48
26
- Registration . prototype . register = function ( container , key , fn ) {
27
- throw new Error ( "A custom Registration must implement register(container, key, fn)." ) ;
28
- } ;
49
+ return Registration ;
50
+ } ) ( ) ;
29
51
30
52
exports . Registration = Registration ;
31
- var Transient = ( function ( ) {
32
- var _Registration = Registration ;
53
+ var Transient = ( function ( Registration ) {
33
54
var Transient = function Transient ( key ) {
34
55
this . key = key ;
35
56
} ;
36
57
37
- _inherits ( Transient , _Registration ) ;
58
+ _inherits ( Transient , Registration ) ;
38
59
39
- Transient . prototype . register = function ( container , key , fn ) {
40
- container . registerTransient ( this . key || key , fn ) ;
41
- } ;
60
+ _prototypeProperties ( Transient , null , {
61
+ register : {
62
+ value : function ( container , key , fn ) {
63
+ container . registerTransient ( this . key || key , fn ) ;
64
+ } ,
65
+ writable : true ,
66
+ enumerable : true ,
67
+ configurable : true
68
+ }
69
+ } ) ;
42
70
43
71
return Transient ;
44
- } ) ( ) ;
72
+ } ) ( Registration ) ;
45
73
46
74
exports . Transient = Transient ;
47
- var Singleton = ( function ( ) {
48
- var _Registration2 = Registration ;
75
+ var Singleton = ( function ( Registration ) {
49
76
var Singleton = function Singleton ( key ) {
50
77
this . key = key ;
51
78
} ;
52
79
53
- _inherits ( Singleton , _Registration2 ) ;
80
+ _inherits ( Singleton , Registration ) ;
54
81
55
- Singleton . prototype . register = function ( container , key , fn ) {
56
- container . registerSingleton ( this . key || key , fn ) ;
57
- } ;
82
+ _prototypeProperties ( Singleton , null , {
83
+ register : {
84
+ value : function ( container , key , fn ) {
85
+ container . registerSingleton ( this . key || key , fn ) ;
86
+ } ,
87
+ writable : true ,
88
+ enumerable : true ,
89
+ configurable : true
90
+ }
91
+ } ) ;
58
92
59
93
return Singleton ;
60
- } ) ( ) ;
94
+ } ) ( Registration ) ;
61
95
62
96
exports . Singleton = Singleton ;
63
- var Resolver = function Resolver ( ) { } ;
97
+ var Resolver = ( function ( ) {
98
+ var Resolver = function Resolver ( ) { } ;
99
+
100
+ _prototypeProperties ( Resolver , null , {
101
+ get : {
102
+ value : function ( container ) {
103
+ throw new Error ( "A custom Resolver must implement get(container) and return the resolved instance(s)." ) ;
104
+ } ,
105
+ writable : true ,
106
+ enumerable : true ,
107
+ configurable : true
108
+ }
109
+ } ) ;
64
110
65
- Resolver . prototype . get = function ( container ) {
66
- throw new Error ( "A custom Resolver must implement get(container) and return the resolved instance(s)." ) ;
67
- } ;
111
+ return Resolver ;
112
+ } ) ( ) ;
68
113
69
114
exports . Resolver = Resolver ;
70
- var Lazy = ( function ( ) {
71
- var _Resolver = Resolver ;
115
+ var Lazy = ( function ( Resolver ) {
72
116
var Lazy = function Lazy ( key ) {
73
117
this . key = key ;
74
118
} ;
75
119
76
- _inherits ( Lazy , _Resolver ) ;
77
-
78
- Lazy . prototype . get = function ( container ) {
79
- var _this = this ;
80
- return function ( ) {
81
- return container . get ( _this . key ) ;
82
- } ;
83
- } ;
120
+ _inherits ( Lazy , Resolver ) ;
84
121
85
- Lazy . of = function ( key ) {
86
- return new Lazy ( key ) ;
87
- } ;
122
+ _prototypeProperties ( Lazy , {
123
+ of : {
124
+ value : function ( key ) {
125
+ return new Lazy ( key ) ;
126
+ } ,
127
+ writable : true ,
128
+ enumerable : true ,
129
+ configurable : true
130
+ }
131
+ } , {
132
+ get : {
133
+ value : function ( container ) {
134
+ var _this = this ;
135
+ return function ( ) {
136
+ return container . get ( _this . key ) ;
137
+ } ;
138
+ } ,
139
+ writable : true ,
140
+ enumerable : true ,
141
+ configurable : true
142
+ }
143
+ } ) ;
88
144
89
145
return Lazy ;
90
- } ) ( ) ;
146
+ } ) ( Resolver ) ;
91
147
92
148
exports . Lazy = Lazy ;
93
- var All = ( function ( ) {
94
- var _Resolver2 = Resolver ;
149
+ var All = ( function ( Resolver ) {
95
150
var All = function All ( key ) {
96
151
this . key = key ;
97
152
} ;
98
153
99
- _inherits ( All , _Resolver2 ) ;
100
-
101
- All . prototype . get = function ( container ) {
102
- return container . getAll ( this . key ) ;
103
- } ;
154
+ _inherits ( All , Resolver ) ;
104
155
105
- All . of = function ( key ) {
106
- return new All ( key ) ;
107
- } ;
156
+ _prototypeProperties ( All , {
157
+ of : {
158
+ value : function ( key ) {
159
+ return new All ( key ) ;
160
+ } ,
161
+ writable : true ,
162
+ enumerable : true ,
163
+ configurable : true
164
+ }
165
+ } , {
166
+ get : {
167
+ value : function ( container ) {
168
+ return container . getAll ( this . key ) ;
169
+ } ,
170
+ writable : true ,
171
+ enumerable : true ,
172
+ configurable : true
173
+ }
174
+ } ) ;
108
175
109
176
return All ;
110
- } ) ( ) ;
177
+ } ) ( Resolver ) ;
111
178
112
179
exports . All = All ;
113
- var Optional = ( function ( ) {
114
- var _Resolver3 = Resolver ;
180
+ var Optional = ( function ( Resolver ) {
115
181
var Optional = function Optional ( key ) {
116
182
var checkParent = arguments [ 1 ] === undefined ? false : arguments [ 1 ] ;
117
183
this . key = key ;
118
184
this . checkParent = checkParent ;
119
185
} ;
120
186
121
- _inherits ( Optional , _Resolver3 ) ;
187
+ _inherits ( Optional , Resolver ) ;
122
188
123
- Optional . prototype . get = function ( container ) {
124
- if ( container . hasHandler ( this . key , this . checkParent ) ) {
125
- return container . get ( this . key ) ;
189
+ _prototypeProperties ( Optional , {
190
+ of : {
191
+ value : function ( key ) {
192
+ var checkParent = arguments [ 1 ] === undefined ? false : arguments [ 1 ] ;
193
+ return new Optional ( key , checkParent ) ;
194
+ } ,
195
+ writable : true ,
196
+ enumerable : true ,
197
+ configurable : true
126
198
}
127
-
128
- return null ;
129
- } ;
130
-
131
- Optional . of = function ( key ) {
132
- var checkParent = arguments [ 1 ] === undefined ? false : arguments [ 1 ] ;
133
- return new Optional ( key , checkParent ) ;
134
- } ;
199
+ } , {
200
+ get : {
201
+ value : function ( container ) {
202
+ if ( container . hasHandler ( this . key , this . checkParent ) ) {
203
+ return container . get ( this . key ) ;
204
+ }
205
+
206
+ return null ;
207
+ } ,
208
+ writable : true ,
209
+ enumerable : true ,
210
+ configurable : true
211
+ }
212
+ } ) ;
135
213
136
214
return Optional ;
137
- } ) ( ) ;
215
+ } ) ( Resolver ) ;
138
216
139
217
exports . Optional = Optional ;
140
- var Parent = ( function ( ) {
141
- var _Resolver4 = Resolver ;
218
+ var Parent = ( function ( Resolver ) {
142
219
var Parent = function Parent ( key ) {
143
220
this . key = key ;
144
221
} ;
145
222
146
- _inherits ( Parent , _Resolver4 ) ;
147
-
148
- Parent . prototype . get = function ( container ) {
149
- return container . parent ? container . parent . get ( this . key ) : null ;
150
- } ;
223
+ _inherits ( Parent , Resolver ) ;
151
224
152
- Parent . of = function ( key ) {
153
- return new Parent ( key ) ;
154
- } ;
225
+ _prototypeProperties ( Parent , {
226
+ of : {
227
+ value : function ( key ) {
228
+ return new Parent ( key ) ;
229
+ } ,
230
+ writable : true ,
231
+ enumerable : true ,
232
+ configurable : true
233
+ }
234
+ } , {
235
+ get : {
236
+ value : function ( container ) {
237
+ return container . parent ? container . parent . get ( this . key ) : null ;
238
+ } ,
239
+ writable : true ,
240
+ enumerable : true ,
241
+ configurable : true
242
+ }
243
+ } ) ;
155
244
156
245
return Parent ;
157
- } ) ( ) ;
246
+ } ) ( Resolver ) ;
158
247
159
248
exports . Parent = Parent ;
160
249
} ) ;
0 commit comments