UNPKG

sortier

Version:
26 lines (25 loc) 898 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StringUtils = void 0; class StringUtils { static getBlankLineLocations(string, rangeStart = 0, rangeEnd = string.length) { const regex = /\n\s*\n/gim; let result; const contextBarrierIndices = []; while ((result = regex.exec(string))) { if (rangeStart < result.index && result.index < rangeEnd) { contextBarrierIndices.push(result.index); } } return contextBarrierIndices; } static stringEndsWithAny(text, endings) { // If the user didn't override the parser type, try to infer it let endsWithAny = false; for (const extension of endings) { endsWithAny = endsWithAny || text.endsWith(extension); } return endsWithAny; } } exports.StringUtils = StringUtils;