| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c6ab449 commit 943852a
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -694,7 +694,26 @@ function isArrayBufferDetached(value) { | |||
| 694 | 694 | return false; | |
| 695 | 695 | } | |
| 696 | 696 | ||
| 697 | + /** | ||
| 698 | + * Helper function to lazy-load an initialize-once value. | ||
| 699 | + * @template T Return value of initializer | ||
| 700 | + * @param {()=>T} initializer Initializer of the lazily loaded value. | ||
| 701 | + * @returns {()=>T} | ||
| 702 | + */ | ||
| 703 | + function getLazy(initializer) { | ||
| 704 | + let value; | ||
| 705 | + let initialized = false; | ||
| 706 | + return function() { | ||
| 707 | + if (initialized === false) { | ||
| 708 | + value = initializer(); | ||
| 709 | + initialized = true; | ||
| 710 | + } | ||
| 711 | + return value; | ||
| 712 | + }; | ||
| 713 | + } | ||
| 714 | + | ||
| 697 | 715 | module.exports = { | |
| 716 | + getLazy, | ||
| 698 | 717 | assertCrypto, | |
| 699 | 718 | cachedResult, | |
| 700 | 719 | convertToValidSignal, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments