Changeset 0c6b92a for imaps-frontend/node_modules/es-to-primitive/es2015.js
Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/node_modules/es-to-primitive/es2015.js
rd565449 r0c6b92a 8 8 var isSymbol = require('is-symbol'); 9 9 10 /** @type {(O: { valueOf?: () => unknown, toString?: () => unknown }, hint: 'number' | 'string' | 'default') => null | undefined | string | symbol | number | boolean | bigint} */ 10 11 var ordinaryToPrimitive = function OrdinaryToPrimitive(O, hint) { 11 12 if (typeof O === 'undefined' || O === null) { … … 15 16 throw new TypeError('hint must be "string" or "number"'); 16 17 } 18 /** @type {('toString' | 'valueOf')[]} */ 17 19 var methodNames = hint === 'string' ? ['toString', 'valueOf'] : ['valueOf', 'toString']; 18 20 var method, result, i; … … 29 31 }; 30 32 33 /** @type {<K extends PropertyKey>(O: Record<K, unknown>, P: K) => Function | undefined} */ 31 34 var GetMethod = function GetMethod(O, P) { 32 35 var func = O[P]; 33 36 if (func !== null && typeof func !== 'undefined') { 34 37 if (!isCallable(func)) { 35 throw new TypeError(func + ' returned for property ' + P+ ' of object ' + O + ' is not a function');38 throw new TypeError(func + ' returned for property ' + String(P) + ' of object ' + O + ' is not a function'); 36 39 } 37 40 return func; … … 40 43 }; 41 44 45 /** @type {import('./es2015')} */ 42 46 // http://www.ecma-international.org/ecma-262/6.0/#sec-toprimitive 43 47 module.exports = function ToPrimitive(input) { … … 45 49 return input; 46 50 } 51 /** @type {'default' | 'string' | 'number'} */ 47 52 var hint = 'default'; 48 53 if (arguments.length > 1) { … … 57 62 if (hasSymbols) { 58 63 if (Symbol.toPrimitive) { 59 exoticToPrim = GetMethod(input, Symbol.toPrimitive); 64 // eslint-disable-next-line no-extra-parens 65 exoticToPrim = GetMethod(/** @type {Record<PropertyKey, unknown>} */ (input), Symbol.toPrimitive); 60 66 } else if (isSymbol(input)) { 61 67 exoticToPrim = Symbol.prototype.valueOf; … … 72 78 hint = 'string'; 73 79 } 74 return ordinaryToPrimitive(input, hint === 'default' ? 'number' : hint); 80 // eslint-disable-next-line no-extra-parens 81 return ordinaryToPrimitive(/** @type {object} */ (input), hint === 'default' ? 'number' : hint); 75 82 };
Note:
See TracChangeset
for help on using the changeset viewer.