UNPKG

@tidecloak/js

Version:

TideCloak client side JS SDK

57 lines 2.41 kB
"use strict"; // // Tide Protocol - Infrastructure for a TRUE Zero-Trust paradigm // Copyright (C) 2022 Tide Foundation Ltd // // This program is free software and is subject to the terms of // the Tide Community Open Code License as published by the // Tide Foundation Limited. You may modify it and redistribute // it in accordance with and subject to the terms of that License. // This program is distributed WITHOUT WARRANTY of any kind, // including without any implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. // See the Tide Community Open Code License for more details. // You should have received a copy of the Tide Community Open // Code License along with this program. // If not, see https://tide.org/licenses_tcoc2-0-0-en // var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const NodeClient_js_1 = __importDefault(require("../Clients/NodeClient.js")); const OrkInfo_js_1 = __importDefault(require("../Models/Infos/OrkInfo.js")); const NetworkClient_js_1 = __importDefault(require("../Clients/NetworkClient.js")); class SimulatorFlow { /** * * @returns {OrkInfo[]} */ static async GetSomeOrks() { const allOrks = await new NetworkClient_js_1.default().GetSomeORKs(); const promises = allOrks.map(ork => new NodeClient_js_1.default(ork.orkURL).isActive()); const settled = await Promise.allSettled(promises); var activeOrks = []; settled.forEach((promise, i) => { if (promise.status === "fulfilled") activeOrks.push(allOrks[i]); // create new ork list on orks which replied }); return activeOrks; } /** * @param {OrkInfo[]} orks * @returns {OrkInfo[]} */ static async FilterInactiveOrks(orks) { const promises = orks.map(ork => new NodeClient_js_1.default(ork.orkURL).isActive()); const settled = await Promise.allSettled(promises); var activeOrks = []; settled.forEach((promise, i) => { if (promise.status === "fulfilled") activeOrks.push(orks[i]); // create new ork list on orks which replied }); return activeOrks; } } exports.default = SimulatorFlow; //# sourceMappingURL=SimulatorFlow.js.map