Update har.js

This commit is contained in:
Namhyeon Go 2024-08-03 16:45:07 +09:00 committed by GitHub
parent 5ff6680cee
commit 92e611f49a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -12,10 +12,6 @@ var HARObject = function() {
this.setEntryIndex = function(index) {
this.entryIndex = index;
};
this.setOnEntry = function(callback) {
this.onEntry = callback;
};
this.load = function(filename) {
this.filename = filename;
@ -24,12 +20,12 @@ var HARObject = function() {
return this;
};
this.play = function() {
this.play = function(callback) {
var entries = this.data.log.entries;
while (this.entryIndex < entries.length) {
var entry = entries[this.entryIndex];
if (typeof this.onEntry !== "function") {
if (typeof callback !== "function") {
console.log(
'[' + entry.startedDateTime + ']',
'"' + [entry.request.method, entry.request.url, entry.request.httpVersion].join(' ') + '"',
@ -40,7 +36,7 @@ var HARObject = function() {
);
} else {
try {
this.onEntry(this, entry, entry.request, entry.response, this.entryIndex);
callback(this, entry, entry.request, entry.response, this.entryIndex);
} catch (e) {
console.error(e.message);
}
@ -61,7 +57,7 @@ var HARObject = function() {
exports.HARObject = HARObject;
exports.VERSIONINFO = "HAR manipulate and replay tools version 0.1.2";
exports.VERSIONINFO = "HAR manipulate and replay tools version 0.1.3";
exports.AUTHOR = "abuse@catswords.net";
exports.global = global;
exports.require = require;