UNPKG

scrabble-solver

Version:

Scrabble Solver 2 - Free, open-source, cross-platform, multi-language analysis tool for Scrabble, Scrabble Duel, Super Scrabble, Letter League, Crossplay, Literaki, and Kelimelik. Quickly find the top-scoring words using the given board and tiles.

29 lines (28 loc) 976 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.request = void 0; const types_1 = require("@scrabble-solver/types"); const follow_redirects_1 = require("follow-redirects"); const request = ({ protocol, ...options }) => { const agent = protocol === 'https' ? follow_redirects_1.https : follow_redirects_1.http; return new Promise((resolve, reject) => { return agent .get(options, (response) => { let data = ''; response.setEncoding('utf8'); response.on('data', (chunk) => { data += chunk; }); response.on('end', () => { try { resolve(data); } catch (error) { reject((0, types_1.isError)(error) ? error : new Error(String(error))); } }); }) .on('error', reject); }); }; exports.request = request;