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 1729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1740 { | 1740 { |
1741 return this._targetObject; | 1741 return this._targetObject; |
1742 }, | 1742 }, |
1743 | 1743 |
1744 clear: function() | 1744 clear: function() |
1745 { | 1745 { |
1746 this._targetObject = null; | 1746 this._targetObject = null; |
1747 } | 1747 } |
1748 }; | 1748 }; |
1749 | 1749 |
1750 /** | |
1751 * @param {function()} callback | |
1752 */ | |
1753 self.setImmediate = (function() { | |
pfeldman
2014/09/26 09:42:20
@vsevik, @dgozman: do you want to count the number
| |
1754 var callbacks = []; | |
1755 function run() { | |
1756 var cbList = callbacks.slice(); | |
1757 callbacks.length = 0; | |
1758 cbList.forEach(function(callback) { callback(); }); | |
1759 }; | |
1760 return function setImmediate(callback) { | |
1761 if (!callbacks.length) | |
1762 new Promise(function(resolve,reject){ resolve(null);}).then(run); | |
pfeldman
2014/09/26 09:42:20
self.setImmediate = function(callback)
{
Promi
| |
1763 callbacks.push(callback); | |
1764 }; | |
1765 })(); | |
OLD | NEW |