import { quoteString } from "./quote" ; import { Next , ToString } from "./types" ; import { objectToString } from "./object" ; import { functionToString } from "./function" ; /**
 * Stringify primitive values.
 */ const PRIMITIVE_TYPES = { string : quoteString , number : ( value ) => ( Object . is ( value , - 0 ) ? "-0" : String ( value ) ) , boolean : String , symbol : ( value , space , next ) => { const key = Symbol . keyFor ( value ) ; if ( key !== undefined ) return `Symbol.for(${ next ( key ) })` ; return `Symbol(${ next ( ( value as any ) . description ) })` ; } , bigint : ( value , space , next ) => { return `BigInt(${ next ( String ( value ) ) })` ; } , undefined : String , object : objectToString , function : functionToString , } ; /**
 * Stringify a value recursively.
 */ export const toString = ( value , space , next , key ) => { if ( value === null ) return "null" ; return PRIMITIVE_TYPES [ typeof value ] ( value , space , next , key ) ; } ;