mherkender / lua.js

An ECMAscript framework to compile and run Lua code, allowing Lua to run in a browser or in Flash
http://blog.brokenfunction.com/
600 stars 73 forks source link

Fix string.* functions to coerce number into string like Lua does #31

Closed elisee closed 11 years ago

elisee commented 11 years ago

Lua uses luaL_checklstring on arguments in string.* functions to ensure they are strings or numbers and coerce numbers into strings.

This pull request introduces a check_string() function that does the same and uses it for supported string.* functions.

For instance, this allows running string.len( 456 ) and get back 3, like the original Lua allows.

elisee commented 11 years ago

Bump (because I might have more patches coming soon and I'd like to get this one in first)

mherkender commented 11 years ago

Looking forward to the new patches. Sorry for the delay!