mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 15:41:45 +00:00
minify
This commit is contained in:
39
dist/getBaseUrl.js
vendored
39
dist/getBaseUrl.js
vendored
@@ -1,38 +1 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getBaseUrl = void 0;
|
||||
// 1 hour
|
||||
const expireTime = 60 * 60 * 1000;
|
||||
const getBaseUrl = (providerValue) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
try {
|
||||
let baseUrl = "";
|
||||
const cacheKey = "CacheBaseUrl" + providerValue;
|
||||
const timeKey = "baseUrlTime" + providerValue;
|
||||
// const cachedUrl = cacheStorageService.getString(cacheKey);
|
||||
// const cachedTime = cacheStorageService.getObject<number>(timeKey);
|
||||
// if (cachedUrl && cachedTime && Date.now() - cachedTime < expireTime) {
|
||||
// baseUrl = cachedUrl;
|
||||
// } else {
|
||||
const baseUrlRes = yield fetch("https://himanshu8443.github.io/providers/modflix.json");
|
||||
const baseUrlData = yield baseUrlRes.json();
|
||||
baseUrl = baseUrlData[providerValue].url;
|
||||
// cacheStorageService.setString(cacheKey, baseUrl);
|
||||
// cacheStorageService.setObject(timeKey, Date.now());
|
||||
// }
|
||||
return baseUrl;
|
||||
}
|
||||
catch (error) {
|
||||
console.error(`Error fetching baseUrl: ${providerValue}`, error);
|
||||
return "";
|
||||
}
|
||||
});
|
||||
exports.getBaseUrl = getBaseUrl;
|
||||
"use strict";var __awaiter=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getBaseUrl=void 0;const expireTime=36e5,getBaseUrl=e=>__awaiter(void 0,void 0,void 0,function*(){try{let t="";const n=yield fetch("https://himanshu8443.github.io/providers/modflix.json");return t=(yield n.json())[e].url,t}catch(e){return""}});exports.getBaseUrl=getBaseUrl;
|
||||
Reference in New Issue
Block a user