@@ -32,7 +32,7 @@ define(function (require) {
32
32
} ) ;
33
33
} ) ( typeof define === 'function' && define . amd ? define : function ( factory ) { module . exports = factory ( require ) ; } ) ;
34
34
35
- } , { "./Scheduler" :3 , "./env" :5 , "./makePromise" :6 } ] , 3 :[ function ( require , module , exports ) {
35
+ } , { "./Scheduler" :3 , "./env" :5 , "./makePromise" :7 } ] , 3 :[ function ( require , module , exports ) {
36
36
/** @license MIT License (c) copyright 2010-2014 original author or authors */
37
37
/** @author Brian Cavalier */
38
38
/** @author John Hann */
@@ -123,6 +123,7 @@ define(function() {
123
123
define ( function ( require ) {
124
124
125
125
var setTimer = require ( '../env' ) . setTimer ;
126
+ var format = require ( '../format' ) ;
126
127
127
128
return function unhandledRejection ( Promise ) {
128
129
var logError = noop ;
@@ -162,15 +163,15 @@ define(function(require) {
162
163
function report ( r ) {
163
164
if ( ! r . handled ) {
164
165
reported . push ( r ) ;
165
- logError ( 'Potentially unhandled rejection [' + r . id + '] ' + formatError ( r . value ) ) ;
166
+ logError ( 'Potentially unhandled rejection [' + r . id + '] ' + format . formatError ( r . value ) ) ;
166
167
}
167
168
}
168
169
169
170
function unreport ( r ) {
170
171
var i = reported . indexOf ( r ) ;
171
172
if ( i >= 0 ) {
172
173
reported . splice ( i , 1 ) ;
173
- logInfo ( 'Handled previous rejection [' + r . id + '] ' + formatObject ( r . value ) ) ;
174
+ logInfo ( 'Handled previous rejection [' + r . id + '] ' + format . formatObject ( r . value ) ) ;
174
175
}
175
176
}
176
177
@@ -191,28 +192,6 @@ define(function(require) {
191
192
return Promise ;
192
193
} ;
193
194
194
- function formatError ( e ) {
195
- var s = typeof e === 'object' && e . stack ? e . stack : formatObject ( e ) ;
196
- return e instanceof Error ? s : s + ' (WARNING: non-Error used)' ;
197
- }
198
-
199
- function formatObject ( o ) {
200
- var s = String ( o ) ;
201
- if ( s === '[object Object]' && typeof JSON !== 'undefined' ) {
202
- s = tryStringify ( o , s ) ;
203
- }
204
- return s ;
205
- }
206
-
207
- function tryStringify ( e , defaultValue ) {
208
- try {
209
- return JSON . stringify ( e ) ;
210
- } catch ( e ) {
211
- // Ignore. Cannot JSON.stringify e, stick with String(e)
212
- return defaultValue ;
213
- }
214
- }
215
-
216
195
function throwit ( e ) {
217
196
throw e ;
218
197
}
@@ -222,7 +201,7 @@ define(function(require) {
222
201
} ) ;
223
202
} ( typeof define === 'function' && define . amd ? define : function ( factory ) { module . exports = factory ( require ) ; } ) ) ;
224
203
225
- } , { "../env" :5 } ] , 5 :[ function ( require , module , exports ) {
204
+ } , { "../env" :5 , "../format" : 6 } ] , 5 :[ function ( require , module , exports ) {
226
205
/** @license MIT License (c) copyright 2010-2014 original author or authors */
227
206
/** @author Brian Cavalier */
228
207
/** @author John Hann */
@@ -302,6 +281,64 @@ define(function(require) {
302
281
/** @author Brian Cavalier */
303
282
/** @author John Hann */
304
283
284
+ ( function ( define ) { 'use strict' ;
285
+ define ( function ( ) {
286
+
287
+ return {
288
+ formatError : formatError ,
289
+ formatObject : formatObject ,
290
+ tryStringify : tryStringify
291
+ } ;
292
+
293
+ /**
294
+ * Format an error into a string. If e is an Error and has a stack property,
295
+ * it's returned. Otherwise, e is formatted using formatObject, with a
296
+ * warning added about e not being a proper Error.
297
+ * @param {* } e
298
+ * @returns {String } formatted string, suitable for output to developers
299
+ */
300
+ function formatError ( e ) {
301
+ var s = typeof e === 'object' && e !== null && e . stack ? e . stack : formatObject ( e ) ;
302
+ return e instanceof Error ? s : s + ' (WARNING: non-Error used)' ;
303
+ }
304
+
305
+ /**
306
+ * Format an object, detecting "plain" objects and running them through
307
+ * JSON.stringify if possible.
308
+ * @param {Object } o
309
+ * @returns {string }
310
+ */
311
+ function formatObject ( o ) {
312
+ var s = String ( o ) ;
313
+ if ( s === '[object Object]' && typeof JSON !== 'undefined' ) {
314
+ s = tryStringify ( o , s ) ;
315
+ }
316
+ return s ;
317
+ }
318
+
319
+ /**
320
+ * Try to return the result of JSON.stringify(x). If that fails, return
321
+ * defaultValue
322
+ * @param {* } x
323
+ * @param {* } defaultValue
324
+ * @returns {String|* } JSON.stringify(x) or defaultValue
325
+ */
326
+ function tryStringify ( x , defaultValue ) {
327
+ try {
328
+ return JSON . stringify ( x ) ;
329
+ } catch ( e ) {
330
+ return defaultValue ;
331
+ }
332
+ }
333
+
334
+ } ) ;
335
+ } ( typeof define === 'function' && define . amd ? define : function ( factory ) { module . exports = factory ( ) ; } ) ) ;
336
+
337
+ } , { } ] , 7 :[ function ( require , module , exports ) {
338
+ /** @license MIT License (c) copyright 2010-2014 original author or authors */
339
+ /** @author Brian Cavalier */
340
+ /** @author John Hann */
341
+
305
342
( function ( define ) { 'use strict' ;
306
343
define ( function ( ) {
307
344
@@ -1329,7 +1366,8 @@ function logloads(loads) {
1329
1366
1330
1367
( function ( ) {
1331
1368
var Promise = __global . Promise || require ( 'when/es6-shim/Promise' ) ;
1332
- console . assert = console . assert || function ( ) { } ;
1369
+ if ( __global . console )
1370
+ console . assert = console . assert || function ( ) { } ;
1333
1371
1334
1372
// IE8 support
1335
1373
var indexOf = Array . prototype . indexOf || function ( item ) {
@@ -1397,7 +1435,7 @@ function logloads(loads) {
1397
1435
load = createLoad ( name ) ;
1398
1436
load . status = 'linked' ;
1399
1437
// https://bugs.ecmascript.org/show_bug.cgi?id=2795
1400
- // load.module = loader.modules[name];
1438
+ load . module = loader . modules [ name ] ;
1401
1439
return load ;
1402
1440
}
1403
1441
@@ -1473,7 +1511,7 @@ function logloads(loads) {
1473
1511
if ( instantiateResult === undefined ) {
1474
1512
load . address = load . address || '<Anonymous Module ' + ++ anonCnt + '>' ;
1475
1513
1476
- // NB instead of load.kind, use load.isDeclarative
1514
+ // instead of load.kind, use load.isDeclarative
1477
1515
load . isDeclarative = true ;
1478
1516
// parse sets load.declare, load.depsList
1479
1517
loader . loaderObj . parse ( load ) ;
@@ -1565,12 +1603,10 @@ function logloads(loads) {
1565
1603
if ( loader . modules [ name ] )
1566
1604
throw new TypeError ( '"' + name + '" already exists in the module table' ) ;
1567
1605
1568
- // NB this still seems wrong for LoadModule as we may load a dependency
1569
- // of another module directly before it has finished loading.
1570
- // see https://bugs.ecmascript.org/show_bug.cgi?id=2994
1606
+ // adjusted to pick up existing loads
1571
1607
for ( var i = 0 , l = loader . loads . length ; i < l ; i ++ )
1572
1608
if ( loader . loads [ i ] . name == name )
1573
- throw new TypeError ( '"' + name + '" already loading' ) ;
1609
+ return resolve ( loader . loads [ i ] . linkSets [ 0 ] . done ) ;
1574
1610
1575
1611
var load = createLoad ( name ) ;
1576
1612
@@ -2308,8 +2344,6 @@ function logloads(loads) {
2308
2344
2309
2345
console . assert ( load . source , 'Non-empty source' ) ;
2310
2346
2311
- var depsList ;
2312
-
2313
2347
load . isDeclarative = true ;
2314
2348
2315
2349
var options = this . traceurOptions || { } ;
@@ -2327,8 +2361,10 @@ function logloads(loads) {
2327
2361
2328
2362
var sourceMap = compiler . getSourceMap ( ) ;
2329
2363
2330
- if ( __global . btoa && sourceMap )
2364
+ if ( __global . btoa && sourceMap ) {
2365
+ source += '\n//# sourceURL=' + load . address + '!eval' ;
2331
2366
source += '\n//# sourceMappingURL=data:application/json;base64,' + btoa ( unescape ( encodeURIComponent ( sourceMap ) ) ) + '\n' ;
2367
+ }
2332
2368
2333
2369
source = 'var __moduleAddress = "' + load . address + '";' + source ;
2334
2370
0 commit comments