All files / util text-manipulation.js

100% Statements 6/6
100% Branches 4/4
100% Functions 1/1
100% Lines 6/6
1 2 3 4 5 6 7 8 9 10 11 12  16x   16x 10x 6x 5x   1x      
export function partitionText(text, pattern, length) {
	const index = text.search(pattern);
 
	if (index === -1) {
		return ['', '', text];
	} else if (index === 0) {
		return ['', text.substr(0, length), text.substring(length)];
	} else {
		return [text.substring(0, index), text.substr(index, length), text.substring(index + length)];
	}
}