Created
July 27, 2023 14:25
-
-
Save cderv/59e33962642001274829f3fe759c33ca to your computer and use it in GitHub Desktop.
Sort Text file content in Typescript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { readLines } from "https://deno.land/[email protected]/io/read_lines.ts"; | |
const f= await Deno.open('tests/timing-for-ci.txt'); | |
let counter = 0 | |
const timedTests = []; | |
const timed = []; | |
let test: string; | |
let time: string; | |
for await (let line of readLines(f)) { | |
if (counter === 0) { | |
test = line | |
console.log(test) | |
counter = 1 | |
} else if (counter === 1) { | |
time = line | |
counter = 2 | |
} | |
if (counter === 2) { | |
timedTests.push({ | |
test: test, | |
time: time | |
}) | |
counter = 0 | |
} | |
} | |
timedTests.sort((a, b) => { | |
const A = a.test; | |
const B = b.test; | |
return A.localeCompare(B); | |
}); | |
const f= await Deno.open(); | |
Deno.removeSync('tests/timing-for-ci.txt') | |
for (let test of timedTests) { | |
Deno.writeTextFileSync('tests/timing-for-ci.txt', `${test.test}\n`, { append: true}) | |
Deno.writeTextFileSync('tests/timing-for-ci.txt', `${test.time}\n`, { append: true}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment