16 lines
420 B
JavaScript
16 lines
420 B
JavaScript
|
|
//#region src/compat/_internal/toKey.ts
|
||
|
|
/**
|
||
|
|
* Converts `value` to a string key if it's not a string or symbol.
|
||
|
|
*
|
||
|
|
* @private
|
||
|
|
* @param {*} value The value to inspect.
|
||
|
|
* @returns {string|symbol} Returns the key.
|
||
|
|
*/
|
||
|
|
function toKey(value) {
|
||
|
|
if (typeof value === "string" || typeof value === "symbol") return value;
|
||
|
|
if (Object.is(value?.valueOf?.(), -0)) return "-0";
|
||
|
|
return String(value);
|
||
|
|
}
|
||
|
|
//#endregion
|
||
|
|
export { toKey };
|