src/vs/base/common/lazy.ts

57 LOC · 57 covered · 0 uncovered · 12 ranges · 17530 concepts · 6 introducers · 10898 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the filechatAgents.ts ×2 · 19 introduced LOCchatAgents.ts ×2synchronizer.test|title=TestSynchronizer - Auto Sync accept delete during conflicts|occurrence=1 · 0 introduced LOCsynchronizer.test|title=…synchronizer.test|title=TestSynchronizer - Auto Sync accept deleted local during conflicts|occurrence=1 · 0 introduced LOCsynchronizer.test|title=…synchronizer.test|title=TestSynchronizer - Auto Sync accept new content during conflicts|occurrence=1 · 0 introduced LOCsynchronizer.test|title=…synchronizer.test|title=TestSynchronizer - Auto Sync accept remote during conflicts|occurrence=1 · 0 introduced LOCsynchronizer.test|title=…synchronizer.test|title=TestSynchronizer - Auto Sync accept local during conflicts|occurrence=1 · 0 introduced LOCsynchronizer.test|title=…synchronizer.test|title=TestSynchronizer - Manual Sync preview -> merge -> apply|occurrence=1 · 0 introduced LOCsynchronizer.test|title=…synchronizer.test|title=TestSynchronizer - Auto Sync accept preview during conflicts|occurrence=1 · 0 introduced LOCsynchronizer.test|title=…synchronizer.test|title=TestSynchronizer - Manual Sync preview|occurrence=1 · 0 introduced LOCsynchronizer.test|title=…synchronizer.test|title=TestSynchronizer - Auto Sync status is set to hasConflicts when asked to sync if there are conflicts|occurrence=1 · 0 introduced LOCsynchronizer.test|title=…synchronizer.test|title=TestSynchronizer - Manual Sync preview -> accept|occurrence=1 · 0 introduced LOCsynchronizer.test|title=…synchronizer.test|title=TestSynchronizer - Last Sync Data last sync data is null when not synced before|occurrence=1 · 0 introduced LOCsynchronizer.test|title=…userDataSyncStoreService.test|title=UserDataSyncStoreService test headers are reset after session is cleared|occurrence=1 · 0 introduced LOCuserDataSyncStoreService…userDataSyncStoreService.test|title=UserDataSyncStoreService test headers are send for read request|occurrence=1 · 0 introduced LOCuserDataSyncStoreService…userDataSyncStoreService.test|title=UserDataSyncStoreService test session id header is set from the second manifest request after session is created|occurrence=1 · 0 introduced LOCuserDataSyncStoreService…userDataSyncStoreService.test|title=UserDataSyncStoreService test headers are send for write request|occurrence=1 · 0 introduced LOCuserDataSyncStoreService…annotations.ts ×3 · 33 introduced LOCannotations.ts ×3fileBackedInstalledPluginsStore.ts ×1 · 3 introduced LOCfileBackedInstalledPlugi…pluginMarketplaceService.ts ×19 · 110 introduced LOCpluginMarketplaceService…pluginMarketplaceService.ts ×16 · 85 introduced LOCpluginMarketplaceService…pluginMarketplaceService.ts ×6 · 13 introduced LOCpluginMarketplaceService…1dsAppender.ts ×11 · 106 introduced LOC1dsAppender.ts ×11configurationModels.ts ×1 · 8 introduced LOCconfigurationModels.ts ×…configurationService.test|title=ConfigurationService.test.ts config gets flattened|occurrence=1 · 0 introduced LOCconfigurationService.tes…configurationService.test|title=ConfigurationService.test.ts simple|occurrence=1 · 0 introduced LOCconfigurationService.tes…mcpRegistryInputStorage.test|title=Workbench - MCP - RegistryInputStorage updates to plain text values overwrite existing values|occurrence=1, mcpRegistryInputStorage.test|title=Workbench - MCP - RegistryInputStorage setPlainText stores values that can be retrieved with getMap|occurrence=1 · 0 introduced LOCmcpRegistryInputStorage.…mcpRegistryInputStorage.ts ×1 · 3 introduced LOCmcpRegistryInputStorage.…mcpRegistryInputStorage.ts ×5 · 18 introduced LOCmcpRegistryInputStorage.…claudeSessionCustomizationDiscovery.test|title=claudeSessionCustomizationDiscovery ClaudeCustomizationWatcher ignores SDK runtime churn under `.claude` (transcripts, history, tasks, ...)|occurrence=1 · 0 introduced LOCclaudeSessionCustomizati…claudeSessionCustomizationDiscovery.test|title=claudeSessionCustomizationDiscovery ClaudeCustomizationWatcher fires once (debounced) for changes under watched roots and ignores unrelated edits|occurrence=1 · 0 introduced LOCclaudeSessionCustomizati… CLAUDE.local.md edit|occurrence=1 · 0 introduced LOC CLAUDE.local.md edit|oc…snapshot.test|title=snapshot creates a snapshot|occurrence=1 · 0 introduced LOCsnapshot.test|title=snap…snapshot.ts ×6 · 11 introduced LOCsnapshot.ts ×6async.ts ×1 · 5 introduced LOCasync.ts ×1buffer.test|title=Buffer Performance issue with VSBuffer#slice #76076|occurrence=1 · 0 introduced LOCbuffer.test|title=Buffer…files.ts ×1 · 2 introduced LOCfiles.ts ×1files.ts ×5 · 9 introduced LOCfiles.ts ×5snapshot.ts ×5 · 11 introduced LOCsnapshot.ts ×5strings.test|title=Strings trimWhitespace|occurrence=1 · 0 introduced LOCstrings.test|title=Strin…strings.ts ×2 · 10 introduced LOCstrings.ts ×2strings.ts ×101 · 542 introduced LOCstrings.ts ×101chatSessionOperationLog.test|title=ChatSessionOperationLog LogAdapter handles deepCompare property changes|occurrence=1 · 0 introduced LOCchatSessionOperationLog.…buffer.ts ×42 · 483 introduced LOCbuffer.ts ×42objects.ts ×1 · 2 introduced LOCobjects.ts ×1date.ts ×1 · 8 introduced LOCdate.ts ×1date.ts ×10 · 46 introduced LOCdate.ts ×10lazy.ts ×1 · 2 introduced LOClazy.ts ×1lazy.ts ×2 · 3 introduced LOClazy.ts ×2lazy.test|title=Lazy lazy values should only be resolved once|occurrence=1 · 0 introduced LOClazy.test|title=Lazy laz…lazy.ts ×1 · 1 introduced LOClazy.ts ×1lazy.ts ×4 · 12 introduced LOClazy.ts ×4lazy.ts ×1 · 2 introduced LOClazy.ts ×1lazy.ts ×3 · 37 introduced LOClazy.ts ×3buffer.test|title=Buffer Performance issue with VSBuffer#slice #76076|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/buffer.test|title=Buffer Performance issue with VSBuffer#slice #76076|occurrence=1buffer.test|title=Buffer…date.test|title=Date getDurationString safeIntl Locale fallback|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/date.test|title=Date getDurationString safeIntl Locale fallback|occurrence=1date.test|title=Date get…lazy.test|title=Lazy Should throw when accessing lazy value in initializer|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/lazy.test|title=Lazy Should throw when accessing lazy value in initializer|occurrence=1lazy.test|title=Lazy Sho…lazy.test|title=Lazy lazy values handle error case|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/lazy.test|title=Lazy lazy values handle error case|occurrence=1lazy.test|title=Lazy laz…lazy.test|title=Lazy lazy values should only be resolved once|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/lazy.test|title=Lazy lazy values should only be resolved once|occurrence=1lazy.test|title=Lazy laz…strings.test|title=Strings trimWhitespace|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/strings.test|title=Strings trimWhitespace|occurrence=1strings.test|title=Strin…strings.test|title=htmlAttributeEncodeValue|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/strings.test|title=htmlAttributeEncodeValue|occurrence=1strings.test|title=htmlA…snapshot.test|title=snapshot creates a snapshot|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/node/snapshot.test|title=snapshot creates a snapshot|occurrence=1snapshot.test|title=snap…snapshot.test|title=snapshot formats object nicely|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/node/snapshot.test|title=snapshot formats object nicely|occurrence=1snapshot.test|title=snap…agentHostTelemetryService.test|title=AgentHostTelemetryService uses the built-in Copilot manifest version for internal telemetry|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/agentHostTelemetryService.test|title=AgentHostTelemetryService uses the built-in Copilot manifest version for internal telemetry|occurrence=1agentHostTelemetryServic… CLAUDE.local.md edit|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/customizations/claudeSessionCustomizationDiscovery.test|title=claudeSessionCustomizationDiscovery ClaudeCustomizationWatcher fires for a root-level CLAUDE.md / CLAUDE.local.md edit|occurrence=1 CLAUDE.local.md edit|oc…claudeSessionCustomizationDiscovery.test|title=claudeSessionCustomizationDiscovery ClaudeCustomizationWatcher fires once (debounced) for changes under watched roots and ignores unrelated edits|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/customizations/claudeSessionCustomizationDiscovery.test|title=claudeSessionCustomizationDiscovery ClaudeCustomizationWatcher fires once (debounced) for changes under watched roots and ignores unrelated edits|occurrence=1claudeSessionCustomizati…claudeSessionCustomizationDiscovery.test|title=claudeSessionCustomizationDiscovery ClaudeCustomizationWatcher ignores SDK runtime churn under `.claude` (transcripts, history, tasks, ...)|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/agentHost/test/node/customizations/claudeSessionCustomizationDiscovery.test|title=claudeSessionCustomizationDiscovery ClaudeCustomizationWatcher ignores SDK runtime churn under `.claude` (transcripts, history, tasks, ...)|occurrence=1claudeSessionCustomizati…configurationService.test|title=ConfigurationService.test.ts config gets flattened|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/configuration/test/common/configurationService.test|title=ConfigurationService.test.ts config gets flattened|occurrence=1configurationService.tes…configurationService.test|title=ConfigurationService.test.ts simple|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/configuration/test/common/configurationService.test|title=ConfigurationService.test.ts simple|occurrence=1configurationService.tes…configurationService.test|title=ConfigurationService.test.ts update configuration throws error for policy setting|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/configuration/test/common/configurationService.test|title=ConfigurationService.test.ts update configuration throws error for policy setting|occurrence=1configurationService.tes…synchronizer.test|title=TestSynchronizer - Auto Sync accept delete during conflicts|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/userDataSync/test/common/synchronizer.test|title=TestSynchronizer - Auto Sync accept delete during conflicts|occurrence=1synchronizer.test|title=…synchronizer.test|title=TestSynchronizer - Auto Sync accept deleted local during conflicts|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/userDataSync/test/common/synchronizer.test|title=TestSynchronizer - Auto Sync accept deleted local during conflicts|occurrence=1synchronizer.test|title=…synchronizer.test|title=TestSynchronizer - Auto Sync accept local during conflicts|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/userDataSync/test/common/synchronizer.test|title=TestSynchronizer - Auto Sync accept local during conflicts|occurrence=1synchronizer.test|title=…synchronizer.test|title=TestSynchronizer - Auto Sync accept new content during conflicts|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/userDataSync/test/common/synchronizer.test|title=TestSynchronizer - Auto Sync accept new content during conflicts|occurrence=1synchronizer.test|title=…synchronizer.test|title=TestSynchronizer - Auto Sync accept preview during conflicts|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/userDataSync/test/common/synchronizer.test|title=TestSynchronizer - Auto Sync accept preview during conflicts|occurrence=1synchronizer.test|title=…synchronizer.test|title=TestSynchronizer - Auto Sync accept remote during conflicts|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/userDataSync/test/common/synchronizer.test|title=TestSynchronizer - Auto Sync accept remote during conflicts|occurrence=1synchronizer.test|title=…synchronizer.test|title=TestSynchronizer - Auto Sync status is set to hasConflicts when asked to sync if there are conflicts|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/userDataSync/test/common/synchronizer.test|title=TestSynchronizer - Auto Sync status is set to hasConflicts when asked to sync if there are conflicts|occurrence=1synchronizer.test|title=…synchronizer.test|title=TestSynchronizer - Last Sync Data last sync data is null when not synced before|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/userDataSync/test/common/synchronizer.test|title=TestSynchronizer - Last Sync Data last sync data is null when not synced before|occurrence=1synchronizer.test|title=…synchronizer.test|title=TestSynchronizer - Manual Sync preview -> accept|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/userDataSync/test/common/synchronizer.test|title=TestSynchronizer - Manual Sync preview -> accept|occurrence=1synchronizer.test|title=…synchronizer.test|title=TestSynchronizer - Manual Sync preview -> merge -> apply|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/userDataSync/test/common/synchronizer.test|title=TestSynchronizer - Manual Sync preview -> merge -> apply|occurrence=1synchronizer.test|title=…synchronizer.test|title=TestSynchronizer - Manual Sync preview|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/userDataSync/test/common/synchronizer.test|title=TestSynchronizer - Manual Sync preview|occurrence=1synchronizer.test|title=…userDataSyncStoreService.test|title=UserDataSyncStoreService test headers are reset after session is cleared|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/userDataSync/test/common/userDataSyncStoreService.test|title=UserDataSyncStoreService test headers are reset after session is cleared|occurrence=1userDataSyncStoreService…userDataSyncStoreService.test|title=UserDataSyncStoreService test headers are send for read request|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/userDataSync/test/common/userDataSyncStoreService.test|title=UserDataSyncStoreService test headers are send for read request|occurrence=1userDataSyncStoreService…userDataSyncStoreService.test|title=UserDataSyncStoreService test headers are send for write request|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/userDataSync/test/common/userDataSyncStoreService.test|title=UserDataSyncStoreService test headers are send for write request|occurrence=1userDataSyncStoreService…userDataSyncStoreService.test|title=UserDataSyncStoreService test session id header is set from the second manifest request after session is created|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/platform/userDataSync/test/common/userDataSyncStoreService.test|title=UserDataSyncStoreService test session id header is set from the second manifest request after session is created|occurrence=1userDataSyncStoreService…chatService.test|title=ChatService sendRequest fails|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/chatService/chatService.test|title=ChatService sendRequest fails|occurrence=1chatService.test|title=C…chatSessionOperationLog.test|title=ChatSessionOperationLog LogAdapter handles deepCompare property changes|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/model/chatSessionOperationLog.test|title=ChatSessionOperationLog LogAdapter handles deepCompare property changes|occurrence=1chatSessionOperationLog.…pluginMarketplaceService.test|title=PluginMarketplaceService - GitHub marketplace refs fetches GitHub marketplace definitions from the configured ref|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/plugins/pluginMarketplaceService.test|title=PluginMarketplaceService - GitHub marketplace refs fetches GitHub marketplace definitions from the configured ref|occurrence=1pluginMarketplaceService…pluginMarketplaceService.test|title=PluginMarketplaceService - hydration after restart hydrates a github-sourced plugin from installed.json name and marketplace cache after restart|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/plugins/pluginMarketplaceService.test|title=PluginMarketplaceService - hydration after restart hydrates a github-sourced plugin from installed.json name and marketplace cache after restart|occurrence=1pluginMarketplaceService…pluginMarketplaceService.test|title=PluginMarketplaceService - hydration after restart persists plugin name when a plugin is added so it survives a restart|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/plugins/pluginMarketplaceService.test|title=PluginMarketplaceService - hydration after restart persists plugin name when a plugin is added so it survives a restart|occurrence=1pluginMarketplaceService…annotations.test|title=Annotations extractVulnerabilitiesFromText multiline|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/widget/annotations.test|title=Annotations extractVulnerabilitiesFromText multiline|occurrence=1annotations.test|title=A…annotations.test|title=Annotations extractVulnerabilitiesFromText multiple vulns|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/widget/annotations.test|title=Annotations extractVulnerabilitiesFromText multiple vulns|occurrence=1annotations.test|title=A…annotations.test|title=Annotations extractVulnerabilitiesFromText single line|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/widget/annotations.test|title=Annotations extractVulnerabilitiesFromText single line|occurrence=1annotations.test|title=A…mcpRegistryInputStorage.test|title=Workbench - MCP - RegistryInputStorage setPlainText stores values that can be retrieved with getMap|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/mcp/test/common/mcpRegistryInputStorage.test|title=Workbench - MCP - RegistryInputStorage setPlainText stores values that can be retrieved with getMap|occurrence=1mcpRegistryInputStorage.…mcpRegistryInputStorage.test|title=Workbench - MCP - RegistryInputStorage updates to plain text values overwrite existing values|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/mcp/test/common/mcpRegistryInputStorage.test|title=Workbench - MCP - RegistryInputStorage updates to plain text values overwrite existing values|occurrence=1mcpRegistryInputStorage.…Focused file · src/vs/base/common/lazy.ts · 57 LOCcommon/lazy.ts

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 > /*--------------------------------------------------------------------------------------------- lazy.ts ×3
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > enum LazyValueState {
7 > Uninitialized,
8 > Running,
9 > Completed,
10 > }
11 >
12 > export class Lazy<T> {
13 >
14 > private _state = LazyValueState.Uninitialized;
15 > private _value?: T;
16 > private _error: Error | undefined;
17 >
18 > constructor(
19 > private readonly executor: () => T, lazy.ts ×1
20 > ) { }
22 > /**
23 > * True if the lazy value has been resolved.
24 > */
25 > get hasValue(): boolean { return this._state === LazyValueState.Completed; }
26 >
27 > /**
28 > * Get the wrapped value.
29 > *
30 > * This will force evaluation of the lazy value if it has not been resolved yet. Lazy values are only
31 > * resolved once. `getValue` will re-throw exceptions that are hit while resolving the value
32 > */
33 > get value(): T {
34 > if (this._state === LazyValueState.Uninitialized) { lazy.ts ×4
35 > this._state = LazyValueState.Running;
36 > try {
37 > this._value = this.executor();
38 > } catch (err) {
39 > this._error = err; lazy.ts ×2
40 > } finally { lazy.ts ×4
41 > this._state = LazyValueState.Completed;
42 > }
43 > } else if (this._state === LazyValueState.Running) {
44 > throw new Error('Cannot read the value of a lazy that is being initialized'); lazy.ts ×1
45 > }
47 > if (this._error) {
48 > throw this._error; lazy.ts ×2
49 > }
50 > return this._value!; lazy.ts ×1
51 > } lazy.ts ×4
53 > /**
54 > * Get the wrapped value without forcing evaluation.
55 > */
56 > get rawValue(): T | undefined { return this._value; }
57 > }