UNPKG

react-native-integrate

Version:

Automate integration of additional code into React Native projects

23 lines (22 loc) 804 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.findLineStart = findLineStart; exports.findLineEnd = findLineEnd; function findLineStart(content, characterIndex, minIndex, includeLineBreak = false) { minIndex = Math.max(minIndex ?? 0, 0); let lineStart = characterIndex; while (lineStart > minIndex && content[lineStart] !== '\n') { lineStart--; } return !includeLineBreak && content[lineStart] === '\n' ? lineStart + 1 : lineStart; } function findLineEnd(content, characterIndex, maxIndex) { maxIndex = Math.min(maxIndex ?? content.length - 1, content.length - 1); let lineStart = characterIndex; while (lineStart < maxIndex && content[lineStart] !== '\n') { lineStart++; } return lineStart; }