UNPKG

1.38 kBJavaScriptView Raw
1/**
2 * -------------------------------------------------------------------------------------------
3 * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
4 * See License in the project root for license information.
5 * -------------------------------------------------------------------------------------------
6 */
7/**
8 * @constant
9 * @function
10 * Validates availability of Promise and fetch in global context
11 * @returns The true in case the Promise and fetch available, otherwise throws error
12 */
13export const validatePolyFilling = () => {
14 if (typeof Promise === "undefined" && typeof fetch === "undefined") {
15 const error = new Error("Library cannot function without Promise and fetch. So, please provide polyfill for them.");
16 error.name = "PolyFillNotAvailable";
17 throw error;
18 }
19 else if (typeof Promise === "undefined") {
20 const error = new Error("Library cannot function without Promise. So, please provide polyfill for it.");
21 error.name = "PolyFillNotAvailable";
22 throw error;
23 }
24 else if (typeof fetch === "undefined") {
25 const error = new Error("Library cannot function without fetch. So, please provide polyfill for it.");
26 error.name = "PolyFillNotAvailable";
27 throw error;
28 }
29 return true;
30};
31//# sourceMappingURL=ValidatePolyFilling.js.map
\No newline at end of file