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 56d7a8b commit 489736a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lib/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var through = require('@ljharb/through');
var resumer = require('@ljharb/resumer');
var inspect = require('object-inspect');
var callBound = require('call-bind/callBound');
var has = require('has');
var hasOwn = require('hasown');
var $exec = callBound('RegExp.prototype.exec');
var $split = callBound('String.prototype.split');
var $replace = callBound('String.prototype.replace');
Expand Down Expand Up @@ -60,7 +60,7 @@ function encodeResult(res, count) {
output += outer + '---\n';
output += inner + 'operator: ' + res.operator + '\n';

if (has(res, 'expected') || has(res, 'actual')) {
if (hasOwn(res, 'expected') || hasOwn(res, 'actual')) {
var ex = inspect(res.expected, { depth: res.objectPrintDepth });
var ac = inspect(res.actual, { depth: res.objectPrintDepth });

Expand Down Expand Up @@ -123,7 +123,7 @@ Results.prototype.createStream = function (opts) {
skip: t._skip,
todo: t._todo
};
if (has(extra, 'parent')) {
if (hasOwn(extra, 'parent')) {
row.parent = extra.parent;
}
output.queue(row);
Expand Down
8 changes: 4 additions & 4 deletions lib/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var defined = require('defined');
var path = require('path');
var inherits = require('inherits');
var EventEmitter = require('events').EventEmitter;
var has = require('has');
var hasOwn = require('hasown');
var isRegExp = require('is-regex');
var trim = require('string.prototype.trim');
var callBind = require('call-bind');
Expand Down Expand Up @@ -467,10 +467,10 @@ Test.prototype._assert = function assert(ok, opts) {
operator: defined(extra.operator, opts.operator),
objectPrintDepth: self._objectPrintDepth
};
if (has(opts, 'actual') || has(extra, 'actual')) {
if (hasOwn(opts, 'actual') || hasOwn(extra, 'actual')) {
res.actual = defined(extra.actual, opts.actual);
}
if (has(opts, 'expected') || has(extra, 'expected')) {
if (hasOwn(opts, 'expected') || hasOwn(extra, 'expected')) {
res.expected = defined(extra.expected, opts.expected);
}
this._ok = !!(this._ok && ok);
Expand Down Expand Up @@ -797,7 +797,7 @@ Test.prototype['throws'] = function (fn, expected, msg, extra) {
fn();
} catch (err) {
caught = { error: err };
if (Object(err) === err && 'message' in err && (!isEnumerable(err, 'message') || !has(err, 'message'))) {
if (Object(err) === err && 'message' in err && (!isEnumerable(err, 'message') || !hasOwn(err, 'message'))) {
try {
var message = err.message;
delete err.message;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"for-each": "^0.3.3",
"get-package-type": "^0.1.0",
"glob": "^7.2.3",
"has": "^1.0.3",
"has-dynamic-import": "^2.0.1",
"hasown": "^2.0.0",
"inherits": "^2.0.4",
"is-regex": "^1.1.4",
"minimist": "^1.2.8",
Expand Down

0 comments on commit 489736a

Please sign in to comment.