Skip to content

Commit

Permalink
fixup! Add ConvertFilenameIterator
Browse files Browse the repository at this point in the history
  • Loading branch information
tamuratak committed Oct 25, 2023
1 parent 5d1eefc commit acb3f2f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/utils/convertfilename.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ export async function convertFilenameEncoding(filePath: string) {
export class ConvertFilenameIterator implements IterableIterator<string> {
private readonly fileNameBuffer: Buffer
private index = 0
private nextValue: string | undefined
private computedNextValue: string | undefined

constructor(filePath: string) {
this.fileNameBuffer = Buffer.from(filePath, 'binary')
this.nextValue = this.computeNext()
this.computedNextValue = this.computeNext()
}

private computeNext() {
Expand All @@ -56,12 +56,12 @@ export class ConvertFilenameIterator implements IterableIterator<string> {
}

next() {
const value = this.nextValue
const value = this.computedNextValue
if (value === undefined) {
throw new Error('Iterator is already done.')
}
this.nextValue = this.computeNext()
const done = this.next === undefined
this.computedNextValue = this.computeNext()
const done = this.computedNextValue === undefined
return { value, done }
}

Expand Down

0 comments on commit acb3f2f

Please sign in to comment.