UNPKG

scrabble-solver

Version:

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

18 lines (17 loc) 737 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.findFirstWordIndex = void 0; const findFirstWordIndex = (lines, locale) => { const firstWordIndex = lines.findIndex((line, index) => { const nextLine = line[index + 1] || ''; const isNextLineInOrder = line.localeCompare(nextLine, locale) > 0; const hasWhitespace = Boolean(line.match(/\s/)); const isEmpty = line.trim().length === 0; return !isEmpty && !hasWhitespace && isNextLineInOrder; }); if (typeof firstWordIndex === 'undefined') { throw new Error('Cannot find index of the first word in the file'); } return firstWordIndex; }; exports.findFirstWordIndex = findFirstWordIndex;