UNPKG

federer

Version:

Experiments in asynchronous federated learning and decentralized learning

32 lines 1.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PathOrURL = void 0; const tslib_1 = require("tslib"); const fs = tslib_1.__importStar(require("fs")); const tf = tslib_1.__importStar(require("@tensorflow/tfjs-node")); const node_fetch_1 = tslib_1.__importDefault(require("node-fetch")); exports.PathOrURL = { isPath(pathOrURL) { return !this.isURL(pathOrURL); }, isURL(pathOrURL) { return pathOrURL.startsWith("http:") || pathOrURL.startsWith("https:"); }, async read(pathOrURL) { if (this.isPath(pathOrURL)) { return fs.promises.readFile(pathOrURL); } else { return (await node_fetch_1.default(pathOrURL)).buffer(); } }, getTfIOHandler(pathOrURL) { if (this.isPath(pathOrURL)) { return tf.io.fileSystem(pathOrURL); } else { return tf.io.browserHTTPRequest(pathOrURL); } }, }; //# sourceMappingURL=path-or-url.js.map