Skip to content

Pass progress as percentage to onUpdate callback #50

Description

@Floriszenz

Currently, the onUpdate callback is called with a progress parameter, which represents the number of parsed lines.
When implementing a GUI, I might want to display the loading state using a determinate progress bar/spinner including a percentage. It would be great, if the onUpdate callback would give me a progress object, such as

interface Progress {
    lines: number;
    percentage?: number;
}

where percentage is a number between 0-1 if it is known (undefined otherwise). This should work for all local file types, such as Blob or ArrayBuffer, since the size is already known when starting to parse. Remote streams should work as well, if the Content-Length header is set.
But actually, the percentage would depend on the number of parsed bytes rather than parsed lines, since the size of a buffer or the Content-Length header indicate the byte length. Therefore, the interface should probably be

interface Progress {
    bytes: number;
    lines: number;
    percentage?: number;
}

or maybe even

interface Progress {
    bytes: number;
    lines: number;
    percentage?: number;
    totalBytes?: number;
}

for completeness.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions