Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
//serialize.js
/*global adventurejs A*/ 

/**
 * Convert an arbitrary string to an id useable by game objects.
 * <ul><li>convert ' ' to '_'</li>
 * <li>convert ' and ' to '&'</li>
 * <li>convert '.' to '$'</li>
 * </ul>
 * @method adventurejs#serialize
 * @memberOf adventurejs
 * @param {String} name 
 * @returns {String}
 */
adventurejs.serialize = function Adventurejs_serialize( name )
{
  "use strict";
  if( "string" !== typeof name ) return '';
  return name.replace(/ /g, "_").replace(/\./g, "$").toLowerCase();
};