generated from GerritPlehn/ts-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc2fc78
commit 669580c
Showing
1 changed file
with
21 additions
and
8 deletions.
There are no files selected for viewing
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
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() |