buffer: misc logic simplification
authorTrevor Norris <trev.norris@gmail.com>
Tue, 23 Jul 2013 18:02:47 +0000 (11:02 -0700)
committerTrevor Norris <trev.norris@gmail.com>
Tue, 23 Jul 2013 18:02:47 +0000 (11:02 -0700)
commit8ce02cf0aa218b43077d2deb851a85739d625248
treec575d548fa516b03c6c119fd421b69d5820fb9fa
parentd74932e51837f87ef57c44204ccab2c3c2f05fa1
buffer: misc logic simplification

Includes:
* No need for `typeof` when checking undefined.
* length is coerced to uint so no need to check if < 0.
* Stay consistent and always throw `new` errors.
* Returning offset + magic number in every write is error prone. Instead
  return the central write function which returns the correct offset.
lib/buffer.js