@@ -24,7 +24,7 @@ function require(p, parent, orig){
24
24
if ( ! mod . exports ) {
25
25
mod . exports = { } ;
26
26
mod . client = mod . component = true ;
27
- mod . call ( mod . exports , mod , mod . exports , require . relative ( path ) ) ;
27
+ mod . call ( this , mod , mod . exports , require . relative ( path ) ) ;
28
28
}
29
29
30
30
return mod . exports ;
@@ -68,7 +68,7 @@ require.resolve = function(path){
68
68
|| require . modules [ index ] && index
69
69
|| require . modules [ indexJSON ] && indexJSON
70
70
|| require . modules [ orig ] && orig
71
- || null ;
71
+ || require . aliases [ index ] ;
72
72
} ;
73
73
74
74
/**
@@ -83,8 +83,7 @@ require.resolve = function(path){
83
83
require . normalize = function ( curr , path ) {
84
84
var segs = [ ] ;
85
85
86
- // foo
87
- if ( '.' != path [ 0 ] ) return path ;
86
+ if ( '.' != path . charAt ( 0 ) ) return path ;
88
87
89
88
curr = curr . split ( '/' ) ;
90
89
path = path . split ( '/' ) ;
@@ -137,15 +136,25 @@ require.alias = function(from, to){
137
136
require . relative = function ( parent ) {
138
137
var p = require . normalize ( parent , '..' ) ;
139
138
139
+ /**
140
+ * lastIndexOf helper.
141
+ */
142
+
143
+ function lastIndexOf ( arr , obj ) {
144
+ var i = arr . length ;
145
+ while ( i -- ) {
146
+ if ( arr [ i ] === obj ) return i ;
147
+ }
148
+ return - 1 ;
149
+ }
150
+
140
151
/**
141
152
* The relative require() itself.
142
153
*/
143
154
144
155
function fn ( path ) {
145
156
var orig = path ;
146
157
path = fn . resolve ( path ) ;
147
- var alias = require . aliases [ path + '/index.js' ] ;
148
- if ( alias ) path = alias ;
149
158
return require ( path , parent , orig ) ;
150
159
}
151
160
@@ -157,9 +166,9 @@ require.relative = function(parent) {
157
166
// resolve deps by returning
158
167
// the dep in the nearest "deps"
159
168
// directory
160
- if ( '.' != path [ 0 ] ) {
169
+ if ( '.' != path . charAt ( 0 ) ) {
161
170
var segs = parent . split ( '/' ) ;
162
- var i = segs . lastIndexOf ( 'deps' ) + 1 ;
171
+ var i = lastIndexOf ( segs , 'deps' ) + 1 ;
163
172
if ( ! i ) i = 0 ;
164
173
path = segs . slice ( 0 , i + 1 ) . join ( '/' ) + '/deps/' + path ;
165
174
return path ;
@@ -229,15 +238,44 @@ function pathtoRegexp(path, keys, options) {
229
238
230
239
return new RegExp ( '^' + path + '$' , sensitive ? '' : 'i' ) ;
231
240
} ;
241
+ } ) ;
242
+ require . register ( "MatthewMueller-debounce/index.js" , function ( module , exports , require ) {
243
+ /**
244
+ * Debounce
245
+ *
246
+ * Returns a function, that, as long as it continues to be invoked, will not
247
+ * be triggered. The function will be called after it stops being called for
248
+ * N milliseconds. If `immediate` is passed, trigger the function on the
249
+ * leading edge, instead of the trailing.
250
+ *
251
+ * @param {Function } func
252
+ * @param {Number } wait
253
+ * @param {Boolean } immediate
254
+ * @return {Function }
255
+ */
256
+
257
+ module . exports = function ( func , wait , immediate ) {
258
+ var timeout , result ;
259
+ return function ( ) {
260
+ var context = this , args = arguments ;
261
+ var later = function ( ) {
262
+ timeout = null ;
263
+ if ( ! immediate ) result = func . apply ( context , args ) ;
264
+ } ;
265
+ var callNow = immediate && ! timeout ;
266
+ clearTimeout ( timeout ) ;
267
+ timeout = setTimeout ( later , wait ) ;
268
+ if ( callNow ) result = func . apply ( context , args ) ;
269
+ return result ;
270
+ } ;
271
+ } ;
272
+
232
273
} ) ;
233
274
require . register ( "ert/index.js" , function ( module , exports , require ) {
234
275
$ ( function ( ) {
235
276
var pathRegexp = require ( 'path-to-regexp' ) ;
236
- var t ;
237
- $ ( '#inputRoute, #inputPath' ) . keyup ( function ( ) {
238
- clearTimeout ( t ) ;
239
- t = setTimeout ( update , 200 ) ;
240
- } ) ;
277
+ var debounce = require ( 'debounce' ) ;
278
+ $ ( '#inputRoute, #inputPath' ) . keyup ( debounce ( update , 200 ) ) ;
241
279
function update ( ) {
242
280
var keys = [ ] ;
243
281
var regexp = pathRegexp ( $ ( '#inputRoute' ) . val ( ) , keys ) ;
@@ -269,5 +307,7 @@ $(function () {
269
307
} ) ;
270
308
} ) ;
271
309
require . alias ( "component-path-to-regexp/index.js" , "ert/deps/path-to-regexp/index.js" ) ;
272
- window . ert = require ( "ert" ) ;
310
+
311
+ require . alias ( "MatthewMueller-debounce/index.js" , "ert/deps/debounce/index.js" ) ;
312
+ window . a = require ( "ert" ) ;
273
313
} ) ( ) ;
0 commit comments