vm/moonshine.js
function (val, errorMessage) {
			switch(true) {
				case typeof val == 'string': 
					return val;

				case val === undefined:
				case val === null: 
					return 'nil';
				
				case val === Infinity: 
					return 'inf';

				case val === -Infinity: 
					return '-inf';

				case typeof val == 'number': 
				case typeof val == 'boolean': 
					return window.isNaN(val)? 'nan' : '' + val;

				default: 
					return throwCoerceError(val, errorMessage) || '';
			}
		}
function (val, errorMessage) {
			switch(true) {
				case typeof val == 'string': 
					return val;

				case val === undefined:
				case val === null: 
					return 'nil';
				
				case val === Infinity: 
					return 'inf';

				case val === -Infinity: 
					return '-inf';

				case typeof val == 'number': 
				case typeof val == 'boolean': 
					return window.isNaN(val)? 'nan' : '' + val;

				default: 
					return throwCoerceError(val, errorMessage) || '';
			}
		}
function ( val , errorMessage ) { switch ( true ) { case typeof val == 'string' : return val ; case val === undefined : case val === null : return 'nil' ; case val === Infinity : return 'inf' ; case val === - Infinity : return '-inf' ; case typeof val == 'number' : case typeof val == 'boolean' : return window . isNaN ( val ) ? 'nan' : '' + val ; default : return throwCoerceError ( val , errorMessage ) || '' ; } }
Coerces a value from its current type to a string in the same manner as Lua.
@param {Object} val The value to be converted.
@param {String} [error] The error message to throw if the conversion fails.
@returns {String} The converted value.
Coerces a value from its current type to a string in the same manner as Lua .