File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- < link rel ="import " href ="zousan.html "/>
1+ < link rel ="import " href ="es6-promise.html "/>
2+ <!-- <link rel="import" href="zousan.html"/> -->
23< script >
34/**
45 * @license
1718 this . flight = [ ] ;
1819 this . concurrency = concurrency ;
1920 this . processHook = hook ;
20- this . promise = new Zousan ( ) ;
21+ this . defer = { } ;
22+ this . promise = new Promise ( function ( resolve , reject ) {
23+ this . defer . resolve = resolve ;
24+ this . defer . reject = reject ;
25+ } . bind ( this ) ) ;
2126
2227 }
2328
3439 } , this ) ;
3540
3641 if ( chunk && chunk . length > 0 ) {
37- var all = Zousan . all ( chunk ) ;
42+ var all = Promise . all ( chunk ) ;
3843 all . then ( this . next . bind ( this ) , this . fail . bind ( this ) ) ;
3944 } else {
40- this . promise . resolve ( this . results ) ;
45+ this . defer . resolve ( this . results ) ;
4146 }
4247 } ,
4348 fail : function ( val ) {
44- this . promise . reject ( val ) ;
49+ this . defer . reject ( val ) ;
4550 this . failures . push ( val ) ;
4651 } ,
4752 exec : function ( ) {
5257 this . flight . forEach ( function ( r ) {
5358 r . abort ( ) ;
5459 } ) ;
55- this . promise . reject ( new Error ( "Aborted" ) ) ;
60+ this . defer . reject ( new Error ( "Aborted" ) ) ;
5661 }
5762 } ;
5863
5964 scope . RequestQueue = RequestQueue ;
6065
61- } ) ( window . StrandLib = window . StrandLib || { } ) ;
62- </ script >
66+ } ) ( window . StrandLib = window . StrandLib || { } ) ;
67+ </ script >
Original file line number Diff line number Diff line change 1212< body >
1313 < script >
1414 function Req ( ) {
15- this . promise = new Zousan ( ) ;
15+ this . promise = new Promise ( function ( resolve ) {
16+ resolve ( { response :"yes" } ) ;
17+ } ) ;
1618 }
1719 Req . prototype = {
1820 exec : function ( ) {
19- this . promise . resolve ( { response :"yes" } ) ;
2021 return this . promise ;
2122 }
2223 } ;
2324
2425 function FReq ( ) {
25- this . promise = new Zousan ( ) ;
26+ this . promise = new Promise ( function ( resolve , reject ) {
27+ reject ( { response :"no" } ) ;
28+ } ) ;
2629 }
2730 FReq . prototype = {
2831 exec : function ( ) {
2932 this . promise . then ( function ( ) { } , function ( ) { } ) ;
30- this . promise . reject ( { response :"no" } ) ;
3133 return this . promise ;
3234 }
3335 } ;
3436 function AReq ( ) {
35- this . promise = new Zousan ( ) ;
37+ this . promise = new Promise ( function ( resolve ) {
38+ resolve ( { response :"yes" } ) ;
39+ } ) ;
3640 }
3741 AReq . prototype = {
3842 exec : function ( ) {
39- this . promise . resolve ( { response :"yes" } ) ;
4043 return this . promise ;
4144 } ,
4245 abort : sinon . spy ( )
4346 } ;
4447
4548 describe ( "RequestQueue" , function ( ) {
46-
49+
4750 it ( "should exist" , function ( ) {
4851 StrandLib . RequestQueue . should . be . a . function ;
4952 } ) ;
137140 } ) ;
138141 </ script >
139142</ body >
140- </ html >
143+ </ html >
You can’t perform that action at this time.
0 commit comments