"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const word_regexp_1 = require("./word-regexp");
function default_1(offset, text) {
    const wordDefinition = word_regexp_1.DEFAULT_WORD_REGEXP;
    wordDefinition.lastIndex = 0;
    let match;
    while ((match = wordDefinition.exec(text))) {
        const matchIndex = match.index || 0;
        if (matchIndex > offset) {
            // |nW -> matched only after the pos
            return null;
        }
        else if (wordDefinition.lastIndex >= offset) {
            // W|W -> match encloses pos
            return {
                word: match[0],
                startOffset: matchIndex,
                endOffset: wordDefinition.lastIndex
            };
        }
    }
    return null;
}
exports.default = default_1;
//# sourceMappingURL=index.js.map