21 lines
No EOL
622 B
JavaScript
21 lines
No EOL
622 B
JavaScript
"use strict";
|
|
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT License.
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.maybeCast = void 0;
|
|
/**
|
|
* Maybe cast value to a particular type
|
|
*
|
|
* @template T type to maybe cast to
|
|
* @param {any} value value to maybe cast
|
|
* @param {Newable<T>} ctor optional class to perform instanceof check
|
|
* @returns {T} value, maybe casted to T
|
|
*/
|
|
function maybeCast(value, ctor) {
|
|
if (ctor != null && value instanceof ctor) {
|
|
return value;
|
|
}
|
|
return value;
|
|
}
|
|
exports.maybeCast = maybeCast;
|
|
//# sourceMappingURL=maybeCast.js.map
|