From 13686d85f5365d11ae6243bdd84c7a0aeb8a13fa Mon Sep 17 00:00:00 2001 From: Nejc Zdovc Date: Wed, 28 Feb 2018 13:31:10 +0100 Subject: [PATCH] Adds null checks (#23) --- index.js | 8 +++++--- package.json | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index da5d135..dd21ca6 100644 --- a/index.js +++ b/index.js @@ -325,12 +325,14 @@ Synopsis.prototype._topN = function (n, scorekeeper, allP) { results = [] underscore.keys(this.publishers).forEach(function (publisher) { - if (!this.publishers[publisher].scores[scorekeeper]) return + if ( + !this.publishers[publisher].scores || + !this.publishers[publisher].scores[scorekeeper]) return - if (!this.publishers[publisher].options.stickyP) { + if (!this.publishers[publisher].options || !this.publishers[publisher].options.stickyP) { if ((!allP) && ((this.options.minPublisherDuration > this.publishers[publisher].duration) || - (this.options.minPublisherVisits > this.publishers[publisher].vists))) return + (this.options.minPublisherVisits > this.publishers[publisher].visits))) return } results.push(underscore.extend({ publisher: publisher }, underscore.omit(this.publishers[publisher], 'window'))) diff --git a/package.json b/package.json index a6f2a70..676cd88 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bat-publisher", - "version": "2.0.12", + "version": "2.0.13", "description": "Routines to identify publishers for the BAT.", "main": "index.js", "scripts": {