runtimejs / runtime

[not maintained] Lightweight JavaScript library operating system for the cloud
http://runtimejs.org
Apache License 2.0
1.93k stars 128 forks source link

runtime.tty.print(): little problem #53

Closed facekapow closed 9 years ago

facekapow commented 9 years ago

This is an issue I discovered while working with runtime-node-net. runtime's runtime.tty.print() function only accepts strings. You'd at least expect an error when given something else, but no. I tried printing an integer an nothing happened, no errors, nothing. Calling toString() on the number printed it. So I propose that the function should call toString() on the argument, which i'm believe is what console.log() does.

iefserge commented 9 years ago

:+1: ah yeah, sorry, you're right, it needs to call String(text) internally. I can fix this now or would you like to open a PR?

facekapow commented 9 years ago

PR? Yeah.

facekapow commented 9 years ago

Ok, Pull Request submitted. Waiting for merge.

piranna commented 9 years ago

it needs to call String(text) internally

Really? I think it's a waste of resources to create a String object instead of calling the .toString() method to get the string literal representation...

iefserge commented 9 years ago

@piranna String(obj) is the same as obj.toString(), but also converts primitive values like null and undefined

piranna commented 9 years ago

:+1: