Skip to content

Commit 690fc51

Browse files
authored
refactor: replace hasOwnProperty with Object.hasOwn (#1329)
1 parent a6efd03 commit 690fc51

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@ name: Node CI
33
on:
44
pull_request:
55
branches:
6-
- master
6+
- v3
77
push:
88
branches:
9-
- explore-new-api
9+
- v3
1010

1111
jobs:
1212
test:
1313
strategy:
14+
fail-fast: false
1415
matrix:
1516
os: [ubuntu-latest, macOS-latest, windows-latest]
16-
node: [12.20.0, 14.13.1, 16.0.0]
17+
node: [12.20.0, 14.13.1, 16.0.0, 16, 17, 18, 19, 20, 21, 22, 23, 24]
1718
runs-on: ${{ matrix.os }}
1819
steps:
1920
- uses: actions/checkout@v2

lib/read-body.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { promisify } from 'node:util'
44

55
import Busboy from '@fastify/busboy'
66
import { createWriteStream } from 'fs-temp'
7-
import hasOwnProperty from 'has-own-property'
87
import _onFinished from 'on-finished'
98
import FileType from 'stream-file-type'
109

@@ -29,7 +28,7 @@ function collectFields (busboy, limits) {
2928
if (valueTruncated) return reject(new MulterError('LIMIT_FIELD_VALUE', fieldname))
3029

3130
// Work around bug in Busboy (https://github.com/mscdex/busboy/issues/6)
32-
if (limits && hasOwnProperty(limits, 'fieldNameSize') && fieldname.length > limits.fieldNameSize) {
31+
if (limits && Object.hasOwn(limits, 'fieldNameSize') && fieldname.length > limits.fieldNameSize) {
3332
return reject(new MulterError('LIMIT_FIELD_KEY'))
3433
}
3534

@@ -54,7 +53,7 @@ function collectFiles (busboy, limits, fileFilter) {
5453
})
5554

5655
// Work around bug in Busboy (https://github.com/mscdex/busboy/issues/6)
57-
if (limits && hasOwnProperty(limits, 'fieldNameSize') && fieldname.length > limits.fieldNameSize) {
56+
if (limits && Object.hasOwn(limits, 'fieldNameSize') && fieldname.length > limits.fieldNameSize) {
5857
return reject(new MulterError('LIMIT_FIELD_KEY'))
5958
}
6059

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"append-field": "^2.0.0",
2626
"bytes": "^3.1.0",
2727
"fs-temp": "^2.0.1",
28-
"has-own-property": "^2.0.0",
2928
"on-finished": "^2.3.0",
3029
"stream-file-type": "^0.6.1",
3130
"type-is": "^1.6.18"
@@ -50,6 +49,6 @@
5049
"lib/"
5150
],
5251
"scripts": {
53-
"test": "standard && c8 --check-coverage --statements 100 mocha"
52+
"test": "standard && c8 --check-coverage --statements 100 mocha --exit"
5453
}
5554
}

test/body.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import stream from 'node:stream'
55
import { promisify } from 'node:util'
66

77
import FormData from 'form-data'
8-
import hasOwnProperty from 'has-own-property'
98
import recursiveNullify from 'recursive-nullify'
109
import testData from 'testdata-w3c-json-form'
1110

@@ -72,8 +71,8 @@ describe('body', () => {
7271

7372
await promisify(parser)(req, null)
7473

75-
assert.strictEqual(hasOwnProperty(req, 'body'), false)
76-
assert.strictEqual(hasOwnProperty(req, 'files'), false)
74+
assert.strictEqual(Object.hasOwn(req, 'body'), false)
75+
assert.strictEqual(Object.hasOwn(req, 'files'), false)
7776
})
7877

7978
it('should not process non-multipart GET request', async () => {
@@ -88,8 +87,8 @@ describe('body', () => {
8887

8988
await promisify(parser)(req, null)
9089

91-
assert.strictEqual(hasOwnProperty(req, 'body'), false)
92-
assert.strictEqual(hasOwnProperty(req, 'files'), false)
90+
assert.strictEqual(Object.hasOwn(req, 'body'), false)
91+
assert.strictEqual(Object.hasOwn(req, 'files'), false)
9392
})
9493

9594
for (const test of testData) {

0 commit comments

Comments
 (0)