OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1359 /** | 1359 /** |
1360 * @param {*} value | 1360 * @param {*} value |
1361 */ | 1361 */ |
1362 function suppressUnused(value) { | 1362 function suppressUnused(value) { |
1363 } | 1363 } |
1364 | 1364 |
1365 /** | 1365 /** |
1366 * @param {function()} callback | 1366 * @param {function()} callback |
1367 * @return {number} | 1367 * @return {number} |
1368 */ | 1368 */ |
1369 self.setImmediate = function(callback) { | 1369 self.setImmediate = function(callback) { |
PhistucK
2017/01/07 11:29:29
Why not callback, ...args?
It removes the need for
| |
1370 Promise.resolve().then(callback); | 1370 const args = [...arguments].slice(1); |
1371 Promise.resolve().then(() => callback(...args)); | |
1371 return 0; | 1372 return 0; |
1372 }; | 1373 }; |
1373 | 1374 |
1374 /** | 1375 /** |
1375 * @param {function(...?)} callback | 1376 * @param {function(...?)} callback |
1376 * @return {!Promise.<T>} | 1377 * @return {!Promise.<T>} |
1377 * @template T | 1378 * @template T |
1378 */ | 1379 */ |
1379 Promise.prototype.spread = function(callback) { | 1380 Promise.prototype.spread = function(callback) { |
1380 return this.then(spreadPromise); | 1381 return this.then(spreadPromise); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1433 while (leftIndex < leftKeys.length) { | 1434 while (leftIndex < leftKeys.length) { |
1434 var leftKey = leftKeys[leftIndex++]; | 1435 var leftKey = leftKeys[leftIndex++]; |
1435 removed.push(this.get(leftKey)); | 1436 removed.push(this.get(leftKey)); |
1436 } | 1437 } |
1437 while (rightIndex < rightKeys.length) { | 1438 while (rightIndex < rightKeys.length) { |
1438 var rightKey = rightKeys[rightIndex++]; | 1439 var rightKey = rightKeys[rightIndex++]; |
1439 added.push(other.get(rightKey)); | 1440 added.push(other.get(rightKey)); |
1440 } | 1441 } |
1441 return {added: added, removed: removed, equal: equal}; | 1442 return {added: added, removed: removed, equal: equal}; |
1442 }; | 1443 }; |
OLD | NEW |