(#15) - use binarySearch instead of linear search

Tests pass here and in PouchDB.  Note that I've rebased on top of #14 in anticipation of that getting merged.