| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 function PromiseResolve(promise, x) { | 96 function PromiseResolve(promise, x) { |
| 97 PromiseDone(promise, +1, x, promiseOnResolve) | 97 PromiseDone(promise, +1, x, promiseOnResolve) |
| 98 } | 98 } |
| 99 | 99 |
| 100 function PromiseReject(promise, r) { | 100 function PromiseReject(promise, r) { |
| 101 PromiseDone(promise, -1, r, promiseOnReject) | 101 PromiseDone(promise, -1, r, promiseOnReject) |
| 102 } | 102 } |
| 103 | 103 |
| 104 | 104 |
| 105 // For API. |
| 106 |
| 107 function PromiseNopResolver() {} |
| 108 |
| 109 function PromiseCreate() { |
| 110 return new Promise(PromiseNopResolver) |
| 111 } |
| 112 |
| 113 |
| 105 // Convenience. | 114 // Convenience. |
| 106 | 115 |
| 107 function PromiseDeferred() { | 116 function PromiseDeferred() { |
| 108 if (this === $Promise) { | 117 if (this === $Promise) { |
| 109 // Optimized case, avoid extra closure. | 118 // Optimized case, avoid extra closure. |
| 110 var promise = PromiseInit(new Promise(promiseRaw)); | 119 var promise = PromiseInit(new Promise(promiseRaw)); |
| 111 return { | 120 return { |
| 112 promise: promise, | 121 promise: promise, |
| 113 resolve: function(x) { PromiseResolve(promise, x) }, | 122 resolve: function(x) { PromiseResolve(promise, x) }, |
| 114 reject: function(r) { PromiseReject(promise, r) } | 123 reject: function(r) { PromiseReject(promise, r) } |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 "cast", PromiseCast | 316 "cast", PromiseCast |
| 308 ]); | 317 ]); |
| 309 InstallFunctions($Promise.prototype, DONT_ENUM, [ | 318 InstallFunctions($Promise.prototype, DONT_ENUM, [ |
| 310 "chain", PromiseChain, | 319 "chain", PromiseChain, |
| 311 "then", PromiseThen, | 320 "then", PromiseThen, |
| 312 "catch", PromiseCatch | 321 "catch", PromiseCatch |
| 313 ]); | 322 ]); |
| 314 } | 323 } |
| 315 | 324 |
| 316 SetUpPromise(); | 325 SetUpPromise(); |
| OLD | NEW |