@@ -32,7 +32,7 @@ define(function (require) {
3232} ) ;
3333} ) ( typeof define === 'function' && define . amd ? define : function ( factory ) { module . exports = factory ( require ) ; } ) ;
3434
35- } , { "./Scheduler" :3 , "./env" :5 , "./makePromise" :6 } ] , 3 :[ function ( require , module , exports ) {
35+ } , { "./Scheduler" :3 , "./env" :5 , "./makePromise" :7 } ] , 3 :[ function ( require , module , exports ) {
3636/** @license MIT License (c) copyright 2010-2014 original author or authors */
3737/** @author Brian Cavalier */
3838/** @author John Hann */
@@ -123,6 +123,7 @@ define(function() {
123123define ( function ( require ) {
124124
125125 var setTimer = require ( '../env' ) . setTimer ;
126+ var format = require ( '../format' ) ;
126127
127128 return function unhandledRejection ( Promise ) {
128129 var logError = noop ;
@@ -162,15 +163,15 @@ define(function(require) {
162163 function report ( r ) {
163164 if ( ! r . handled ) {
164165 reported . push ( r ) ;
165- logError ( 'Potentially unhandled rejection [' + r . id + '] ' + formatError ( r . value ) ) ;
166+ logError ( 'Potentially unhandled rejection [' + r . id + '] ' + format . formatError ( r . value ) ) ;
166167 }
167168 }
168169
169170 function unreport ( r ) {
170171 var i = reported . indexOf ( r ) ;
171172 if ( i >= 0 ) {
172173 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 ) ) ;
174175 }
175176 }
176177
@@ -191,28 +192,6 @@ define(function(require) {
191192 return Promise ;
192193 } ;
193194
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-
216195 function throwit ( e ) {
217196 throw e ;
218197 }
@@ -222,7 +201,7 @@ define(function(require) {
222201} ) ;
223202} ( typeof define === 'function' && define . amd ? define : function ( factory ) { module . exports = factory ( require ) ; } ) ) ;
224203
225- } , { "../env" :5 } ] , 5 :[ function ( require , module , exports ) {
204+ } , { "../env" :5 , "../format" : 6 } ] , 5 :[ function ( require , module , exports ) {
226205/** @license MIT License (c) copyright 2010-2014 original author or authors */
227206/** @author Brian Cavalier */
228207/** @author John Hann */
@@ -302,6 +281,64 @@ define(function(require) {
302281/** @author Brian Cavalier */
303282/** @author John Hann */
304283
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+
305342( function ( define ) { 'use strict' ;
306343define ( function ( ) {
307344
@@ -1329,7 +1366,8 @@ function logloads(loads) {
13291366
13301367( function ( ) {
13311368 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 ( ) { } ;
13331371
13341372 // IE8 support
13351373 var indexOf = Array . prototype . indexOf || function ( item ) {
@@ -1397,7 +1435,7 @@ function logloads(loads) {
13971435 load = createLoad ( name ) ;
13981436 load . status = 'linked' ;
13991437 // https://bugs.ecmascript.org/show_bug.cgi?id=2795
1400- // load.module = loader.modules[name];
1438+ load . module = loader . modules [ name ] ;
14011439 return load ;
14021440 }
14031441
@@ -1473,7 +1511,7 @@ function logloads(loads) {
14731511 if ( instantiateResult === undefined ) {
14741512 load . address = load . address || '<Anonymous Module ' + ++ anonCnt + '>' ;
14751513
1476- // NB instead of load.kind, use load.isDeclarative
1514+ // instead of load.kind, use load.isDeclarative
14771515 load . isDeclarative = true ;
14781516 // parse sets load.declare, load.depsList
14791517 loader . loaderObj . parse ( load ) ;
@@ -1565,12 +1603,10 @@ function logloads(loads) {
15651603 if ( loader . modules [ name ] )
15661604 throw new TypeError ( '"' + name + '" already exists in the module table' ) ;
15671605
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
15711607 for ( var i = 0 , l = loader . loads . length ; i < l ; i ++ )
15721608 if ( loader . loads [ i ] . name == name )
1573- throw new TypeError ( '"' + name + '" already loading' ) ;
1609+ return resolve ( loader . loads [ i ] . linkSets [ 0 ] . done ) ;
15741610
15751611 var load = createLoad ( name ) ;
15761612
@@ -2308,8 +2344,6 @@ function logloads(loads) {
23082344
23092345 console . assert ( load . source , 'Non-empty source' ) ;
23102346
2311- var depsList ;
2312-
23132347 load . isDeclarative = true ;
23142348
23152349 var options = this . traceurOptions || { } ;
@@ -2327,8 +2361,10 @@ function logloads(loads) {
23272361
23282362 var sourceMap = compiler . getSourceMap ( ) ;
23292363
2330- if ( __global . btoa && sourceMap )
2364+ if ( __global . btoa && sourceMap ) {
2365+ source += '\n//# sourceURL=' + load . address + '!eval' ;
23312366 source += '\n//# sourceMappingURL=data:application/json;base64,' + btoa ( unescape ( encodeURIComponent ( sourceMap ) ) ) + '\n' ;
2367+ }
23322368
23332369 source = 'var __moduleAddress = "' + load . address + '";' + source ;
23342370
0 commit comments