Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ jobs:
post-test-steps: |
- name: Coverage Report
uses: codecov/codecov-action@v2
include: |
- runs-on: ubuntu-latest
node-version: 16.5
automerge:
if: >
github.event_name == 'pull_request' &&
Expand Down
8 changes: 7 additions & 1 deletion lib/fetch/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,11 @@ function makeIterator (iterator, name) {
return Object.setPrototypeOf({}, i)
}

/**
* Fetch supports node >= 16.5.0, but Object.hasOwn was added in v16.9.0.
*/
const hasOwn = Object.hasOwn || ((dict, key) => Object.prototype.hasOwnProperty.call(dict, key))

module.exports = {
isAborted,
isCancelled,
Expand Down Expand Up @@ -463,5 +468,6 @@ module.exports = {
serializeJavascriptValueToJSONString,
makeIterator,
isValidHeaderName,
isValidHeaderValue
isValidHeaderValue,
hasOwn
}
7 changes: 4 additions & 3 deletions lib/fetch/webidl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

const { toUSVString, types } = require('util')
const { types } = require('util')
const { hasOwn, toUSVString } = require('./util')

const webidl = {}
webidl.converters = {}
Expand Down Expand Up @@ -315,7 +316,7 @@ webidl.dictionaryConverter = function (converters) {
const { key, defaultValue, required, converter } = options

if (required === true) {
if (!Object.hasOwn(dictionary, key)) {
if (!hasOwn(dictionary, key)) {
webidl.errors.exception({
header: 'Dictionary',
message: `Missing required key "${key}".`
Expand All @@ -324,7 +325,7 @@ webidl.dictionaryConverter = function (converters) {
}

let value = dictionary[key]
const hasDefault = Object.hasOwn(options, 'defaultValue')
const hasDefault = hasOwn(options, 'defaultValue')

// Only use defaultValue if value is undefined and
// a defaultValue options was provided.
Expand Down