Comparing version 0.8.5 to 0.9.1
37
index.js
@@ -8,5 +8,5 @@ // jshint esversion: 6, globalstrict: true, strict: true, bitwise: false | ||
function PamDiff(options) { | ||
function PamDiff(options, callback) { | ||
if (!(this instanceof PamDiff)) { | ||
return new PamDiff(options); | ||
return new PamDiff(options, callback); | ||
} | ||
@@ -18,2 +18,3 @@ Transform.call(this, {objectMode: true}); | ||
this.setRegions(this._parseOptions('regions', options));//can be no regions or a single region or multiple regions. if no regions, all pixels will be compared. | ||
this._setCallback(callback);//callback function to be called when pixel difference is detected | ||
this._parseChunk = this._parseFirstChunk;//first parsing will be reading settings and configuring internal pixel reading | ||
@@ -92,2 +93,10 @@ } | ||
PamDiff.prototype._setCallback = function (callback) { | ||
if (typeof callback === 'function') { | ||
this._callback = callback; | ||
} else { | ||
delete this._callback; | ||
} | ||
}; | ||
PamDiff.prototype._parseOptions = function (option, options) { | ||
@@ -186,2 +195,5 @@ if (options && options.hasOwnProperty(option)) { | ||
const data = {trigger: regionDiffArray, pam: chunk.pam}; | ||
if (this._callback) { | ||
this._callback(data); | ||
} | ||
if (this._readableState.pipesCount > 0) { | ||
@@ -198,2 +210,5 @@ this.push(data); | ||
const data = {trigger: [{name: 'percent', percent: percent}], pam: chunk.pam}; | ||
if (this._callback) { | ||
this._callback(data); | ||
} | ||
if (this._readableState.pipesCount > 0) { | ||
@@ -242,2 +257,5 @@ this.push(data); | ||
const data = {trigger: regionDiffArray, pam: chunk.pam}; | ||
if (this._callback) { | ||
this._callback(data); | ||
} | ||
if (this._readableState.pipesCount > 0) { | ||
@@ -254,2 +272,5 @@ this.push(data); | ||
const data = {trigger: [{name: 'percent', percent: percent}], pam: chunk.pam}; | ||
if (this._callback) { | ||
this._callback(data); | ||
} | ||
if (this._readableState.pipesCount > 0) { | ||
@@ -298,2 +319,5 @@ this.push(data); | ||
const data = {trigger: regionDiffArray, pam: chunk.pam}; | ||
if (this._callback) { | ||
this._callback(data); | ||
} | ||
if (this._readableState.pipesCount > 0) { | ||
@@ -310,2 +334,5 @@ this.push(data); | ||
const data = {trigger: [{name: 'percent', percent: percent}], pam: chunk.pam}; | ||
if (this._callback) { | ||
this._callback(data); | ||
} | ||
if (this._readableState.pipesCount > 0) { | ||
@@ -354,2 +381,5 @@ this.push(data); | ||
const data = {trigger: regionDiffArray, pam: chunk.pam}; | ||
if (this._callback) { | ||
this._callback(data); | ||
} | ||
if (this._readableState.pipesCount > 0) { | ||
@@ -366,2 +396,5 @@ this.push(data); | ||
const data = {trigger: [{name: 'percent', percent: percent}], pam: chunk.pam}; | ||
if (this._callback) { | ||
this._callback(data); | ||
} | ||
if (this._readableState.pipesCount > 0) { | ||
@@ -368,0 +401,0 @@ this.push(data); |
{ | ||
"name": "pam-diff", | ||
"version": "0.8.5", | ||
"version": "0.9.1", | ||
"description": "Measure differences between pixel arrays extracted from pam images", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22352
416