Skip to content

Commit

Permalink
dev script
Browse files Browse the repository at this point in the history
  • Loading branch information
GerritPlehn committed Jan 10, 2023
1 parent bc2fc78 commit 669580c
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
const dummy: DummyObject = {
foo: 'Hello World',
bar: 2,
}
import { quickSort } from './quicksort.js'
import inquirer from 'inquirer'

const main = async () => {
await sleep(dummy.bar)
console.log(dummy.foo)
const items = ['Pizza', 'Pasta', 'Kebab']
const sortedArray = await quickSort(items, compareFn)
console.log(sortedArray)
}

const sleep = async (delaySeconds: number) => {
return new Promise((res) => setTimeout(res, delaySeconds * 1000))
const compareFn = async (a: string, b: string): Promise<number> => {
if (a === b) return 0
const answer = await inquirer.prompt([
{
type: 'list',
name: 'firstItem',
message: `Which item is better:`,
choices: [a, b, 'Equal'],
},
])
if (answer.firstItem === a) {
return 1
} else if (answer.firstItem === b) {
return -1
}
return 0
}

main()

0 comments on commit 669580c

Please sign in to comment.