Skip to content

Add support for AsyncIterator #132

@Modeeeeeee

Description

@Modeeeeeee

Currently, the harFromMessages function in the chrome-har module does not support asynchronous iteration using for await...of. This limitation makes it difficult to process asynchronous streams of messages efficiently.
I would like to request adding support for for await...of to the harFromMessages function so that it can accept an AsyncIterator. This would allow users to process asynchronous streams of messages more efficiently.
As an alternative, users can manually collect all messages into an array before passing them to harFromMessages. However, this approach is not efficient for large streams of messages and can lead to high memory usage.

Here is an example of how the updated harFromMessages function could look with support for AsyncIterator:

async function harFromMessages(messages, options) {
options = Object.assign({}, defaultOptions, options);

const ignoredRequests = new Set(),
rootFrameMappings = new Map();

let pages = [],
entries = [],
entriesWithoutPage = [],
responsesWithoutPage = [],
paramsWithoutPage = [],
responseReceivedExtraInfos = [],
currentPageId;

for await (const message of messages) {
// Process each message
console.log(message);
}

// Rest of the function logic
}

module.exports = { harFromMessages };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions