Skip to content

Commit 07665fc

Browse files
Merge pull request #114 from gemini-testing/TRIVIAL.remove_extra_deps
chore: remove extra deps
2 parents fbd86df + 28533c1 commit 07665fc

8 files changed

Lines changed: 42 additions & 248 deletions

File tree

index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
const _ = require('lodash');
43
const colorDiff = require('color-diff');
54
const img = require('./lib/image');
65
const areColorsSame = require('./lib/same-colors');
@@ -152,7 +151,7 @@ const buildDiffImage = async (img1, img2, options) => {
152151
};
153152

154153
const getToleranceFromOpts = (opts) => {
155-
if (!_.hasIn(opts, 'tolerance')) {
154+
if (!Object.hasOwn(opts, 'tolerance')) {
156155
return JND;
157156
}
158157

@@ -167,11 +166,13 @@ const prepareOpts = (opts) => {
167166
opts = opts || {};
168167
opts.tolerance = getToleranceFromOpts(opts);
169168

170-
return _.defaults(opts, {
169+
const defaults = {
171170
ignoreCaret: true,
172171
ignoreAntialiasing: true,
173172
antialiasingTolerance: 0
174-
});
173+
};
174+
175+
return Object.assign(defaults, opts);
175176
};
176177

177178
const getMaxDiffBounds = (first, second) => {

lib/img-buffer/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const fs = require('fs-extra');
3+
const fs = require('fs');
44
const NestedError = require('nested-error-stacks');
55
const OriginalBuffer = require('./original-buffer');
66
const BoundedBuffer = require('./bounded-buffer');
@@ -13,7 +13,7 @@ exports.create = (buffer, {boundingBox} = {}) => {
1313

1414
exports.fromFile = async (filePath, opts = {}) => {
1515
try {
16-
const buffer = await fs.readFile(filePath);
16+
const buffer = await fs.promises.readFile(filePath);
1717
return exports.create(buffer, opts);
1818
} catch (err) {
1919
throw new NestedError(`Can't load img file ${filePath}`, err);

lib/utils.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
const _ = require('lodash');
43
const parseColor = require('parse-color');
54
const img = require('./image');
65
const buffer = require('./img-buffer');
@@ -88,7 +87,7 @@ exports.formatImages = (img1, img2) => {
8887
validators.validateImages(img1, img2);
8988

9089
return [img1, img2].map((i) => {
91-
return _.isObject(i) && !Buffer.isBuffer(i) ? i : {source: i, boundingBox: null};
90+
return i !== null && typeof i === 'object' && !Buffer.isBuffer(i) ? i : {source: i, boundingBox: null};
9291
});
9392
};
9493

lib/validators.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
'use strict';
22

3-
const _ = require('lodash');
43
const {REQUIRED_IMAGE_FIELDS, REQUIRED_BOUNDING_BOX_FIELDS} = require('./constants');
54

65
const validateRequiredFields = (value, fields) => {
76
[].concat(fields).forEach((field) => {
8-
if (!_.hasIn(value, field)) {
7+
if (!value || !Object.hasOwn(value, field)) {
98
throw new TypeError(`Field "${field}" does not exist in ${JSON.stringify(value)}`);
109
}
1110
});
@@ -23,7 +22,7 @@ const validateBoundingBoxCoords = ({boundingBox}) => {
2322

2423
exports.validateImages = (img1, img2) => {
2524
[img1, img2].forEach((i) => {
26-
if (Buffer.isBuffer(i) || !_.isObject(i)) {
25+
if (Buffer.isBuffer(i) || i === null || typeof i !== 'object') {
2726
return;
2827
}
2928

0 commit comments

Comments
 (0)