Skip to content

Commit

Permalink
remove BufferSource
Browse files Browse the repository at this point in the history
  • Loading branch information
KhafraDev committed Aug 27, 2024
1 parent 668fae1 commit a7fa49b
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 36 deletions.
2 changes: 1 addition & 1 deletion lib/web/fetch/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ webidl.converters.XMLHttpRequestBodyInit = function (V, prefix, name) {
}

if (ArrayBuffer.isView(V) || types.isArrayBuffer(V)) {
return webidl.converters.BufferSource(V, prefix, name)
return V
}

if (V instanceof FormData) {
Expand Down
21 changes: 0 additions & 21 deletions lib/web/fetch/webidl.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,27 +654,6 @@ webidl.converters.DataView = function (V, prefix, name, opts) {
return V
}

// https://webidl.spec.whatwg.org/#BufferSource
webidl.converters.BufferSource = function (V, prefix, name, opts) {
if (types.isAnyArrayBuffer(V)) {
return webidl.converters.ArrayBuffer(V, prefix, name, { ...opts, allowShared: false })
}

if (types.isTypedArray(V)) {
return webidl.converters.TypedArray(V, V.constructor, prefix, name, { ...opts, allowShared: false })
}

if (types.isDataView(V)) {
return webidl.converters.DataView(V, prefix, name, { ...opts, allowShared: false })
}

throw webidl.errors.conversionFailed({
prefix,
argument: `${name} ("${webidl.util.Stringify(V)}")`,
types: ['BufferSource']
})
}

webidl.converters['sequence<ByteString>'] = webidl.sequenceConverter(
webidl.converters.ByteString
)
Expand Down
2 changes: 1 addition & 1 deletion lib/web/websocket/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ webidl.converters.WebSocketSendData = function (V) {
}

if (ArrayBuffer.isView(V) || types.isArrayBuffer(V)) {
return webidl.converters.BufferSource(V)
return V
}
}

Expand Down
13 changes: 0 additions & 13 deletions test/webidl/converters.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,6 @@ test('DataView', () => {
assert.equal(webidl.converters.DataView(view, 'converter', 'converter'), view)
})

test('BufferSource', () => {
assert.doesNotThrow(() => {
const buffer = new ArrayBuffer(16)
const view = new DataView(buffer, 0)

webidl.converters.BufferSource(view, 'converter', 'converter')
})

assert.throws(() => {
webidl.converters.BufferSource(3, 'converter', 'converter')
}, TypeError)
})

test('ByteString', () => {
assert.doesNotThrow(() => {
webidl.converters.ByteString('', 'converter', 'converter')
Expand Down

0 comments on commit a7fa49b

Please sign in to comment.