mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
buffer: fix validation of options in Blob
constructor
PR-URL: https://github.com/nodejs/node/pull/45156 Refs: https://webidl.spec.whatwg.org/#es-dictionary Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
parent
17ae2ab750
commit
d6ee27445b
3 changed files with 53 additions and 4 deletions
|
@ -257,6 +257,25 @@ const validateObject = hideStackFrames(
|
|||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @callback validateDictionary - We are using the Web IDL Standard definition
|
||||
* of "dictionary" here, which means any value
|
||||
* whose Type is either Undefined, Null, or
|
||||
* Object (which includes functions).
|
||||
* @param {*} value
|
||||
* @param {string} name
|
||||
* @see https://webidl.spec.whatwg.org/#es-dictionary
|
||||
* @see https://tc39.es/ecma262/#table-typeof-operator-results
|
||||
*/
|
||||
|
||||
/** @type {validateDictionary} */
|
||||
const validateDictionary = hideStackFrames(
|
||||
(value, name) => {
|
||||
if (value != null && typeof value !== 'object' && typeof value !== 'function') {
|
||||
throw new ERR_INVALID_ARG_TYPE(name, 'a dictionary', value);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @callback validateArray
|
||||
* @param {*} value
|
||||
|
@ -511,6 +530,7 @@ module.exports = {
|
|||
validateBooleanArray,
|
||||
validateBoolean,
|
||||
validateBuffer,
|
||||
validateDictionary,
|
||||
validateEncoding,
|
||||
validateFunction,
|
||||
validateInt32,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue