Skip to content

Commit

Permalink
$mol_key: symbol support
Browse files Browse the repository at this point in the history
  • Loading branch information
jin committed Jan 3, 2024
1 parent b474abd commit 7203c87
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions key/key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ namespace $ {
export function $mol_key< Value >( value : Value ) : string {

if( typeof value === 'bigint' ) return value.toString() + 'n'
if( typeof value === 'symbol' ) return value.description!
if( !value ) return JSON.stringify( value )
if( typeof value !== 'object' && typeof value !== 'function' ) return JSON.stringify( value )

return JSON.stringify( value, ( field, value )=> {

if( typeof value === 'bigint' ) return value.toString() + 'n'
if( typeof value === 'symbol' ) return value.description
if( !value ) return value
if( typeof value !== 'object' && typeof value !== 'function' ) return value
if( Array.isArray( value ) ) return value
Expand Down

0 comments on commit 7203c87

Please sign in to comment.