(value)
| 2699 | } |
| 2700 | |
| 2701 | function hasBuiltInToString(value) { |
| 2702 | // Prevent triggering proxy traps. |
| 2703 | const getFullProxy = false; |
| 2704 | const proxyTarget = getProxyDetails(value, getFullProxy); |
| 2705 | if (proxyTarget !== undefined) { |
| 2706 | if (proxyTarget === null) { |
| 2707 | return true; |
| 2708 | } |
| 2709 | return hasBuiltInToString(proxyTarget); |
| 2710 | } |
| 2711 | |
| 2712 | let hasOwnToString = ObjectPrototypeHasOwnProperty; |
| 2713 | let hasOwnToPrimitive = ObjectPrototypeHasOwnProperty; |
| 2714 | |
| 2715 | // Count objects without `toString` and `Symbol.toPrimitive` function as built-in. |
| 2716 | if (typeof value.toString !== 'function') { |
| 2717 | if (typeof value[SymbolToPrimitive] !== 'function') { |
| 2718 | return true; |
| 2719 | } else if (ObjectPrototypeHasOwnProperty(value, SymbolToPrimitive)) { |
| 2720 | return false; |
| 2721 | } |
| 2722 | hasOwnToString = returnFalse; |
| 2723 | } else if (ObjectPrototypeHasOwnProperty(value, 'toString')) { |
| 2724 | return false; |
| 2725 | } else if (typeof value[SymbolToPrimitive] !== 'function') { |
| 2726 | hasOwnToPrimitive = returnFalse; |
| 2727 | } else if (ObjectPrototypeHasOwnProperty(value, SymbolToPrimitive)) { |
| 2728 | return false; |
| 2729 | } |
| 2730 | |
| 2731 | // Find the object that has the `toString` property or `Symbol.toPrimitive` property |
| 2732 | // as own property in the prototype chain. |
| 2733 | let pointer = value; |
| 2734 | do { |
| 2735 | pointer = ObjectGetPrototypeOf(pointer); |
| 2736 | } while (!hasOwnToString(pointer, 'toString') && |
| 2737 | !hasOwnToPrimitive(pointer, SymbolToPrimitive)); |
| 2738 | |
| 2739 | // Check closer if the object is a built-in. |
| 2740 | const descriptor = ObjectGetOwnPropertyDescriptor(pointer, 'constructor'); |
| 2741 | return descriptor !== undefined && |
| 2742 | typeof descriptor.value === 'function' && |
| 2743 | builtInObjects.has(descriptor.value.name); |
| 2744 | } |
| 2745 | |
| 2746 | function returnFalse() { |
| 2747 | return false; |
no test coverage detected
searching dependent graphs…