Simple React Typeahead & Faster Array Filter

Here is a super simple yet nicely working React typeahead I created couple of days ago after pretty much not being able to find any bug free & lightweight typeahead for React.

It’s weird because while there are too many Typeahead[s] for AngularJS, while I guess React is still in the awkward teenage phase.

Also, I ended up creating a custom Array filter, because well, it is evidently much faster than the native Array.prototype.filter().

The faster Array filter can be defined as:

Array.prototype.where = Array.prototype.where || function(t) {
  var results = [];

  for(var i = 0, len = this.length; i < len; i++) {
    var item = this[i];

    if (t(item)) {
      results.push(item);
    }
  }

  return results;
};

Although I don’t think there is going to be any noticeable difference unless the size of array is quite large.