UNPKG

semantic-analysis

Version:

Extensible semantic Structured Data analysis library for Microdata and JSON-LD

34 lines 1.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.VisitLog = void 0; var url_1 = require("../../util/url"); var VisitLog = /** @class */ (function () { function VisitLog() { /* Properties */ var _this = this; this.visited = new Set(); this.counts = new Map(); this.has = function (url) { return _this.visited.has(url); }; this.siteCount = function (url) { var _a; var host = (_a = url_1.createURL(url)) === null || _a === void 0 ? void 0 : _a.host; return host ? _this.counts.get(host) : undefined; }; } /* Visit Log */ VisitLog.prototype.add = function (url) { var _a, _b; this.visited.add(url); var host = (_a = url_1.createURL(url)) === null || _a === void 0 ? void 0 : _a.host; if (host) { var count = (_b = this.counts.get(host)) !== null && _b !== void 0 ? _b : 0; this.counts.set(host, count + 1); } else { console.error('Invalid URL: Host could not be extracted properly'); } }; return VisitLog; }()); exports.VisitLog = VisitLog; //# sourceMappingURL=VisitLog.js.map