| 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 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1437 function windowLoaded() { | 1437 function windowLoaded() { |
| 1438 self.removeEventListener('DOMContentLoaded', windowLoaded, false); | 1438 self.removeEventListener('DOMContentLoaded', windowLoaded, false); |
| 1439 callback(); | 1439 callback(); |
| 1440 } | 1440 } |
| 1441 | 1441 |
| 1442 if (document.readyState === 'complete' || document.readyState === 'interactive
') | 1442 if (document.readyState === 'complete' || document.readyState === 'interactive
') |
| 1443 callback(); | 1443 callback(); |
| 1444 else | 1444 else |
| 1445 self.addEventListener('DOMContentLoaded', windowLoaded, false); | 1445 self.addEventListener('DOMContentLoaded', windowLoaded, false); |
| 1446 } | 1446 } |
| 1447 |
| 1448 var _singletonSymbol = Symbol('singleton'); |
| 1449 |
| 1450 /** |
| 1451 * @template T |
| 1452 * @param {function(new:T, ...)} constructorFunction |
| 1453 * @return {!T} |
| 1454 */ |
| 1455 function singleton(constructorFunction) { |
| 1456 if (_singletonSymbol in constructorFunction) |
| 1457 return constructorFunction[_singletonSymbol]; |
| 1458 var instance = new constructorFunction(); |
| 1459 constructorFunction[_singletonSymbol] = instance; |
| 1460 return instance; |
| 1461 } |
| OLD | NEW |