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.
32 lines (31 loc) • 905 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.parse = exports.crawl = void 0;
const lib_1 = require("../lib");
const crawl = (word) => {
return (0, lib_1.request)({
protocol: 'https',
hostname: 'sozluk.gov.tr',
path: `/gts?ara=${encodeURIComponent(word)}`,
headers: {
'content-type': 'text/json',
},
});
};
exports.crawl = crawl;
const parse = (json) => {
const response = JSON.parse(json);
if (!Array.isArray(response) || ('error' in response && response.error)) {
return {
definitions: [],
exists: false,
};
}
const [wordInfo] = response;
const definitions = wordInfo.anlamlarListe.map((entry) => entry.anlam.replace('►', '').trim());
return {
definitions,
exists: definitions.length > 0,
};
};
exports.parse = parse;