JSCBC-12: Fix return code for write

2.0.2 use write notifications on a socket even if
we don't have any data to send to that socket to get
callbacks to process more input data (if we back off).

Another "bug" in libcouchbase tries to send 0 bytes, and
the bug here is that we return -1 for requests to send
0 bytes instead of returning 0 (that was the number of
bytes we sent)

Change-Id: Id7ecb8cc149f8d1ac7aa71d28968b12cdff05a75
Reviewed-on: http://review.couchbase.org/23864
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
JSCBC-13: All code should be uniform

Use astyle on the io code (except for the generated code)

Change-Id: I4f7b4bae9cf96b854300cced5d35ca1d51036abd
Reviewed-on: http://review.couchbase.org/23866
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Remove premature optimization

This codepath is not in the critical path, and explicitly
telling the compiler what to do seems really premature.
When it results in multiple lines of #ifdef code it seems
even more wrong

Change-Id: I7a052efc89fc3bf44cd8e7e8579a009834604ef0
Reviewed-on: http://review.couchbase.org/23867
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Remove unused code

Change-Id: I8f5dbf58adb015a1041c9f26a9770d25dad8e29a
Reviewed-on: http://review.couchbase.org/23868
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
JSCBC-11: Autocorrect common typos

The configuration settings isn't consistent in short/long
form of the names, and may be a bit misleading. This patch
autodetect (and corrects):

username -> user
pass -> password
passw -> password
passwd --> password
hostname -> hosts = [ hostname ]

Change-Id: I5cf962e7e7741c07b431dbbe3f0380a5668d4b62
Reviewed-on: http://review.couchbase.org/23869
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Replaced instanceof with typeof

Did some speed tests on jsperf.com, it appears the typeof check is
faster. ( http://jsperf.com/instanceof-vs-typeof2-function2). Not sure
if there are other considerations. Accuracy appears the same.

Change-Id: I0c622e33651efd57c1c17945e404a66da798095f
Reviewed-on: http://review.couchbase.org/23676
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Switched conditional operator to or

Found this to be slightly faster and it catches values like an empty
string as well.

Change-Id: I31669bf17dbe8330db48b5d03d6e19ac9668a259
Reviewed-on: http://review.couchbase.org/23682
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Use join() instead of replace()

Change-Id: I64bf5d4153c9ca645d455e266df339b30b6ed1d2
Reviewed-on: http://review.couchbase.org/23872
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Reviewed-by: Volker Mische <volker.mische@gmail.com>
Update npm package info

Change-Id: I9aef99660ec040dc3c697537c141ac793e3351c0
Reviewed-on: http://review.couchbase.org/23870
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Fixup example config.json file used by tests

Change-Id: Iacdb2313453ca630673c1de88c98c48f5af28555
Reviewed-on: http://review.couchbase.org/23924
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Refactor: Split up the command argument parsing

This changeset spit out the argument parsing from
using a centralized argument parsing, to one where
each operation parse its own argument set. By doing
so it makes it easier for us to change parameters
for _one_ of the commands, instead of having to
figure out the order (and impact) on other commands.

The patch renames the old "argument" class into
Operations and subclass that interface with a
specialized class per operation.

The "dict" style of parameters is dropped in this
commit, since we're going to refactor each of the
operations over to a dict in the future so that
they look like the signature in bucket.js.

Change-Id: I973f9dccd4f74a774a82f1a56cf8696a530fd03e
Reviewed-on: http://review.couchbase.org/23909
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Reviewed-by: Mark Getz <mark.getz@kellpro.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Use libcouchbase for design doc management

Change-Id: Ic8bfa244ebabb1f3350a395a8c003229eedfed8e
Reviewed-on: http://review.couchbase.org/23916
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Add supports for views through lcb

Change-Id: Id90006c4b86e85cd7e636649c4b773720e0f03c3
Reviewed-on: http://review.couchbase.org/23925
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Fix loss-of-context bug with endure.

Fixed bug which causes endure to fail hard when a couchbase error occurs.

Change-Id: I5eb590f06d35670a42e7f524e91575aa0d6caa9d
Reviewed-on: http://review.couchbase.org/23844
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Fix 00-args.t

Change-Id: I5efbbad4a2184db240dc70d3975d267f7ecacb2d
Reviewed-on: http://review.couchbase.org/23944
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Reviewed-by: Mark Everitt <meveritt@wizcorp.jp>
Tested-by: Mark Everitt <meveritt@wizcorp.jp>
Add support for hash key

Keys may now be objects that look like:
{ key: 'key', hashkey: 'hashkey' }

Change-Id: Ifc8fff9872903996daf0b596f1c5fda46a8ab24c
Reviewed-on: http://review.couchbase.org/23933
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Added missing semicolons

Change-Id: I6bd2e2c05bc814dea30420ccd0c93ecd8f364279
Reviewed-on: http://review.couchbase.org/23931
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Add include for free()

Change-Id: Ia29e3bf240659982fdd0109c230afe25d6e4fd77
Reviewed-on: http://review.couchbase.org/23958
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Refactor: Use a common class for http-related commands

Change-Id: I6c7a1f654b9c4187e0897824a5010832de243e9a
Reviewed-on: http://review.couchbase.org/23979
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
Fix incorrect length cast

Change-Id: I68d716bd152f0dd1a0a6fbdbb9cd0889cae12e9d
Reviewed-on: http://review.couchbase.org/24056
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>