You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

29 lines
937 B

"use strict";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
class LazyValue {
constructor(_getValue) {
this._getValue = _getValue;
this._hasValue = false;
}
get value() {
if (!this._hasValue) {
this._hasValue = true;
this._value = this._getValue();
}
return this._value;
}
get hasValue() {
return this._hasValue;
}
map(f) {
return new LazyValue(() => f(this.value));
}
}
function lazy(getValue) {
return new LazyValue(getValue);
}
exports.lazy = lazy;