diff --git a/lib/har.js b/lib/har.js index 8a94575..95e3b6f 100644 --- a/lib/har.js +++ b/lib/har.js @@ -9,11 +9,16 @@ var HARObject = function() { this.data = {}; this.entryIndex = 0; this.onEntry = null; + this.filters = []; this.setEntryIndex = function(index) { this.entryIndex = index; }; + this.addFilter = function(f) { + this.filters.push(f); + }; + this.load = function(filename) { this.filename = filename; this.data = JSON.parse(FILE.readFile(this.filename, PipeIPC.CdoUTF_8)); @@ -26,6 +31,17 @@ var HARObject = function() { while (this.entryIndex < entries.length) { var entry = entries[this.entryIndex]; + var i = 0; + while (i < this.filters.length && typeof this.filters[i] === "function") { + try { + if (!this.filters[i](entry)) + return; + } catch (e) { + console.error(e.message); + } + i++; + } + if (typeof callback !== "function") { console.log( '[' + entry.startedDateTime + ']', @@ -58,7 +74,7 @@ var HARObject = function() { exports.HARObject = HARObject; -exports.VERSIONINFO = "HAR(HTTP Archive) manipulate and replay tools version 0.1.3"; +exports.VERSIONINFO = "HAR(HTTP Archive) manipulate and replay tools version 0.1.4"; exports.AUTHOR = "abuse@catswords.net"; exports.global = global; exports.require = require;