looks-same
Advanced tools
Comparing version 5.0.1 to 5.0.2
26
index.js
@@ -16,20 +16,2 @@ 'use strict'; | ||
const getDiffArea = (diffPixelsCoords) => { | ||
const xs = []; | ||
const ys = []; | ||
diffPixelsCoords.forEach((coords) => { | ||
xs.push(coords[0]); | ||
ys.push(coords[1]); | ||
}); | ||
const top = _.min(ys); | ||
const bottom = _.max(ys); | ||
const left = _.min(xs); | ||
const right = _.max(xs); | ||
return {left, top, right, bottom}; | ||
}; | ||
const makeAntialiasingComparator = (comparator, png1, png2, opts) => { | ||
@@ -179,5 +161,5 @@ const antialiasingComparator = new AntialiasingComparator(comparator, png1, png2, opts); | ||
getDiffPixelsCoords(first, second, comparator, {stopOnFirstFail}, (result) => { | ||
const diffBounds = getDiffArea(result); | ||
const diffBounds = result.area; | ||
callback(null, {equal: result.length === 0, diffBounds}); | ||
callback(null, {equal: result.isEmpty(), diffBounds}); | ||
}); | ||
@@ -210,7 +192,7 @@ }); | ||
getDiffPixelsCoords(first, second, comparator, opts, (result) => { | ||
if (!result.length) { | ||
if (result.isEmpty()) { | ||
return callback(null, null); | ||
} | ||
callback(null, getDiffArea(result)); | ||
callback(null, result.area); | ||
}); | ||
@@ -217,0 +199,0 @@ }); |
'use strict'; | ||
const DiffArea = require('./diff-area'); | ||
const png = require('../lib/png'); | ||
@@ -40,2 +42,3 @@ | ||
} | ||
const stopOnFirstFail = opts.hasOwnProperty('stopOnFirstFail') ? opts.stopOnFirstFail : false; | ||
@@ -46,3 +49,3 @@ | ||
const diffPixelsCoords = []; | ||
const diffArea = new DiffArea(); | ||
@@ -63,6 +66,6 @@ const processRow = (y) => { | ||
if (!result) { | ||
diffPixelsCoords.push([x, y]); | ||
diffArea.update(x, y); | ||
if (stopOnFirstFail) { | ||
return callback(diffPixelsCoords); | ||
return callback(diffArea); | ||
} | ||
@@ -76,3 +79,3 @@ } | ||
} else { | ||
callback(diffPixelsCoords); | ||
callback(diffArea); | ||
} | ||
@@ -79,0 +82,0 @@ }); |
{ | ||
"name": "looks-same", | ||
"version": "5.0.1", | ||
"version": "5.0.2", | ||
"description": "Pure node.js library for comparing PNG-images, taking into account human color perception.", | ||
@@ -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
36847
17
827