Skip to content

Commit f66793a

Browse files
authored
Merge pull request #58 from nikeee/has-own
Replace `has-own-prop` with `Object.hasOwn`
2 parents ff630f0 + f72571b commit f66793a

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@
6363
"dependencies": {
6464
"array-timsort": "^1.0.3",
6565
"core-util-is": "^1.0.3",
66-
"esprima": "^4.0.1",
67-
"has-own-prop": "^2.0.0",
68-
"repeat-string": "^1.6.1"
66+
"esprima": "^4.0.1"
6967
}
7068
}

src/common.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const hasOwnProperty = require('has-own-prop')
21
const {
32
isObject,
43
isArray,
@@ -52,7 +51,7 @@ const copy_comments_by_kind = (
5251
target, source, target_key, source_key, prefix, remove_source
5352
) => {
5453
const source_prop = symbol(prefix, source_key)
55-
if (!hasOwnProperty(source, source_prop)) {
54+
if (!Object.hasOwn(source, source_prop)) {
5655
return
5756
}
5857

@@ -84,7 +83,7 @@ const swap_comments = (array, from, to) => {
8483

8584
SYMBOL_PREFIXES.forEach(prefix => {
8685
const target_prop = symbol(prefix, to)
87-
if (!hasOwnProperty(array, target_prop)) {
86+
if (!Object.hasOwn(array, target_prop)) {
8887
copy_comments_by_kind(array, array, to, from, prefix, true)
8988
return
9089
}
@@ -114,7 +113,7 @@ const assign = (target, source, keys) => {
114113
return
115114
}
116115

117-
if (!hasOwnProperty(source, key)) {
116+
if (!Object.hasOwn(source, key)) {
118117
return
119118
}
120119

src/stringify.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
const {
22
isArray, isObject, isFunction, isNumber, isString
33
} = require('core-util-is')
4-
const repeat = require('repeat-string')
54

65
const {
76
PREFIX_BEFORE_ALL,
@@ -308,7 +307,7 @@ const get_indent = space => isString(space)
308307
// If the space parameter is a string, it will be used as the indent string.
309308
? space
310309
: isNumber(space)
311-
? repeat(SPACE, space)
310+
? SPACE.repeat(space)
312311
: EMPTY
313312

314313
const {toString} = Object.prototype

test/others.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// eslint-disable-next-line import/no-unresolved
22
const test = require('ava')
3-
const hasOwnProperty = require('has-own-prop')
43

54
const {parse, stringify, assign} = require('..')
65

@@ -15,7 +14,7 @@ test('#33: assign: should ignore symbol keys', t => {
1514
const obj = {}
1615
const key = Symbol.for('before:a')
1716

18-
t.is(hasOwnProperty(parsed, key), true)
17+
t.is(Object.hasOwn(parsed, key), true)
1918

2019
assign(obj, parsed, [key])
2120

0 commit comments

Comments
 (0)