GetOptionsObject.js 612 B

1234567891011121314151617181920
  1. 'use strict';
  2. var $TypeError = require('es-errors/type');
  3. // var OrdinaryObjectCreate = require('es-abstract/2024/OrdinaryObjectCreate');
  4. var Type = require('es-abstract/2024/Type');
  5. // https://tc39.es/proposal-joint-iteration/#sec-getoptionsobject
  6. module.exports = function GetOptionsObject(options) {
  7. if (typeof options === 'undefined') { // step 1
  8. // return OrdinaryObjectCreate(null); // step 1.a
  9. return { __proto__: null }; // step 1.a
  10. }
  11. if (Type(options) === 'Object') { // step 2
  12. return options; // step 2.a
  13. }
  14. throw new $TypeError('`options` must be an Object or undefined'); // step 3
  15. };