creationix / postgres-js

The postgres backend protocol implemented in pure JS for use with node.js
122 stars 26 forks source link

Clobbering of String.prototype #1

Closed rakeshpai closed 14 years ago

rakeshpai commented 14 years ago

It'd be ideal if you can create helper functions instead of using modifying the String.prototype in bits.js. This is so that you can play well with other libraries that might be used in the same context as this.

creationix commented 14 years ago

I actually have plans on doing that. Since string are immutable anyway the current method isn't even elegant. It will require a rewrite of all the bits file and change all the code that uses it (About half of postgres.js). Luckily they're small files. I've got some pressing deadlines for the next couple of days, so If you're adventurous you can submit a patch. Otherwise I'll probably get to it soon enough.

creationix commented 14 years ago

This issue is now fixed. Bits.js now uses Encoder and Decoder objects that are much easier to use and don't mess with String or Object's prototypes.

rakeshpai commented 14 years ago

+1. Awesome. Sorry for not being able to submit a patch for this.

creationix commented 14 years ago

No problem, I'm pleased with the new api. It feels more natural.