Skip to content

Commit

Permalink
Make the bar move right, not left, to show progress
Browse files Browse the repository at this point in the history
  • Loading branch information
amcaplan committed Jan 23, 2025
1 parent c98b3ea commit 3303188
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('Tasks', () => {

// Then
expect(unstyled(renderInstance.lastFrame()!)).toMatchInlineSnapshot(`
"▁▂▂▃▃▄▄▅▅▆▆▇▇██▇▇▆▆▅▅▄▄▃▃▂▂▁▁▁▁▂▂▃▃▄▄▅▅▆▆▇▇██▇▇▆▆▅▅▄▄▃▃▂▂▁▁
"▁▁▁▂▂▃▃▄▄▅▅▆▆▇▇██▇▇▆▆▅▅▄▄▃▃▂▂▁▁▁▁▂▂▃▃▄▄▅▅▆▆▇▇██▇▇▆▆▅▅▄▄▃▃▂▂▁
task 1 ..."
`)
expect(firstTaskFunction).toHaveBeenCalled()
Expand Down Expand Up @@ -95,7 +95,7 @@ describe('Tasks', () => {

// Then
expect(unstyled(renderInstance.lastFrame()!)).toMatchInlineSnapshot(`
"▂▃▄▅▆▇█▇▆▅▄▃▂▁▁
"▁▁▂▃▄▅▆▇█▇▆▅▄▃▂
task 1 ..."
`)
expect(firstTaskFunction).toHaveBeenCalled()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@ function rainbow(text: string, frame: number) {
}

function rotated(text: string, steps: number) {
const textLength = text.length
return text
.split('')
.map((_, index) => {
return text[(index + steps) % textLength]
})
.join('')
const normalizedSteps = steps % text.length
const start = text.slice(-normalizedSteps)
const end = text.slice(0, -normalizedSteps)
return start + end
}

/**
Expand Down

0 comments on commit 3303188

Please sign in to comment.