src/serialize.js
function serializeKey( name ) {
   const identifier = /^[A-Za-z$_][A-Za-z0-9$_]*$/.test( name );
   const keyword = [
      'if', 'else',
      'switch', 'case', 'default',
      'try', 'catch', 'finally',
      'function', 'return',
      'var', 'let', 'const'
   ].indexOf( name ) >= 0;

   return ( identifier && !keyword ) ? name : `"${name}"`;
}
function serializeKey( name ) {
   const identifier = /^[A-Za-z$_][A-Za-z0-9$_]*$/.test( name );
   const keyword = [
      'if', 'else',
      'switch', 'case', 'default',
      'try', 'catch', 'finally',
      'function', 'return',
      'var', 'let', 'const'
   ].indexOf( name ) >= 0;

   return ( identifier && !keyword ) ? name : `"${name}"`;
}
function serializeKey ( name ) { const identifier = / ^[A-Za-z$_][A-Za-z0-9$_]*$ / . test ( name ) ; const keyword = [ 'if' , 'else' , 'switch' , 'case' , 'default' , 'try' , 'catch' , 'finally' , 'function' , 'return' , 'var' , 'let' , 'const' ] . indexOf ( name ) >= 0 ; return ( identifier && ! keyword ) ? name : ` ${ name } ` ; }
Serialize an object key.
Wrap the key in quotes if it is either not a valid identifier or if it
is a problematic keyword.
@private
@param {String} name the key to serialize
@return {String} the serialized key
Serialize an object key . Wrap the key in quotes if it is either not a valid identifier or if it is a problematic keyword .