Skip to content

Commit

Permalink
[Refactor] use hasown instead of has
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Oct 21, 2023
1 parent 65f0b06 commit 590f3f6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
"es-get-iterator": "^1.1.3",
"es-to-primitive": "^1.2.1",
"functions-have-names": "^1.2.3",
"has": "^1.0.3",
"has-bigints": "^1.0.2",
"has-symbols": "^1.0.3",
"hasown": "^2.0.0",
"is-arrow-function": "^2.0.3",
"is-bigint": "^1.0.4",
"is-boolean-object": "^1.1.2",
Expand Down
12 changes: 6 additions & 6 deletions why.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var ObjectPrototype = Object.prototype;
var toStr = ObjectPrototype.toString;
var booleanValue = Boolean.prototype.valueOf;
var has = require('has');
var hasOwn = require('hasown');
var isArray = require('isarray');
var isArrowFunction = require('is-arrow-function');
var isBoolean = require('is-boolean-object');
Expand Down Expand Up @@ -155,8 +155,8 @@ module.exports = function whyNotEqual(value, other) {
var equal = '';
var valHasIndex, otherHasIndex;
while (equal === '' && index >= 0) {
valHasIndex = has(value, index);
otherHasIndex = has(other, index);
valHasIndex = hasOwn(value, index);
otherHasIndex = hasOwn(other, index);
if (!valHasIndex && otherHasIndex) { return 'second argument has index ' + index + '; first does not'; }
if (valHasIndex && !otherHasIndex) { return 'first argument has index ' + index + '; second does not'; }
equal = whyNotEqual(value[index], other[index]);
Expand Down Expand Up @@ -272,8 +272,8 @@ module.exports = function whyNotEqual(value, other) {

var key, valueKeyIsRecursive, otherKeyIsRecursive, keyWhy;
for (key in value) {
if (has(value, key)) {
if (!has(other, key)) { return 'first argument has key "' + key + '"; second does not'; }
if (hasOwn(value, key)) {
if (!hasOwn(other, key)) { return 'first argument has key "' + key + '"; second does not'; }
valueKeyIsRecursive = !!value[key] && value[key][key] === value;
otherKeyIsRecursive = !!other[key] && other[key][key] === other;
if (valueKeyIsRecursive !== otherKeyIsRecursive) {
Expand All @@ -289,7 +289,7 @@ module.exports = function whyNotEqual(value, other) {
}
}
for (key in other) {
if (has(other, key) && !has(value, key)) {
if (hasOwn(other, key) && !hasOwn(value, key)) {
return 'second argument has key "' + key + '"; first does not';
}
}
Expand Down

0 comments on commit 590f3f6

Please sign in to comment.