mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-07 09:03:27 -05:00
* fix(tools/scripts) convert validate and get-lines to typescript files * fix(tools/scripts) refactor validate and get-lines to typescript * remove any type and eslint ignore * Update utils/validate.ts Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> * address comments * update .ignore files to ignore newly generated utils files * Update utils/get-lines.ts Co-authored-by: Shaun Hamilton <shauhami020@gmail.com> * remove unneeded ErrorInterface * add local type annotation to 'expected' variable Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com> Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>
11 lines
267 B
TypeScript
11 lines
267 B
TypeScript
export function getLines(contents: string, range?: number[]) {
|
|
if (!range) {
|
|
return '';
|
|
}
|
|
|
|
const lines = contents.split('\n');
|
|
const editableLines =
|
|
range[1] <= range[0] ? [] : lines.slice(range[0], range[1] - 1);
|
|
return editableLines.join('\n');
|
|
}
|