From 45a1938aea3a96f7ef5214316ddf95f6b0c8fa93 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Sat, 3 Aug 2024 15:25:41 +0900 Subject: [PATCH] Create hartool.js --- lib/hartool.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 lib/hartool.js diff --git a/lib/hartool.js b/lib/hartool.js new file mode 100644 index 0000000..e56242a --- /dev/null +++ b/lib/hartool.js @@ -0,0 +1,44 @@ +// hartool.js +// https://github.com/gnh1201/welsonjs +var PipeIPC = require("lib/pipe-ipc"); + +var HARObject = function() { + this.filename = null; + this.data = null; + this.entryIndex = 0; + + this.setEntryIndex = function(index) { + this.entryIndex = index; + }; + + this.load = function(filename) { + this.filename = filename; + this.data = JSON.parse(FILE.readFile(filename, PipeIPC.CdoUTF_8)); + return this; + }; + + this.walk = function(onEntry) { + if (this.data = null) + return; + + var entries = this.data.entries; + while (this.entryIndex < entries.length) { + var entry = this.data.entries[entryIndex]; + + try { + onEntry(this, entry, entry.request, entry.response); + } catch (e) { + console.error(e.message); + } + + this.entryIndex++; + } + }; +}; + +exports.HARObject = HARObject; + +exports.VERSIONINFO = "HAR tool version 0.1"; +exports.AUTHOR = "abuse@catswords.net"; +exports.global = global; +exports.require = require;