<commit_before>(function() {
  'use strict';
  Polymer({
    is: 'paper-typeahead',
    properties: {
      input: String,
      hideResults: {
        type: Boolean,
        value: false
      },
      inputLabel: {
        type: String,
        value: ''
      },
      data: Array,
      filterFn: {
        type: Function,
        value: function() {
          return function(data, input) {
            var r = RegExp(input, 'i');

            if (input === '') {
              return [];
            }

            return data.filter(function(v) {
              return (r.test(v) ? v : null);
            });
          };
        }
      },
      filteredItems: {
        type: Array,
        computed: 'getFiltered(data, input, filterFn)'
      }
    },
    listeners: {
      'blur': 'onBlur',
    },
    onBlur: function() {
      this.hideResults = true;
    },
    onFocus: function() {
      this.hideResults = false;
    },
    selected: function(e) {
      this.input = e.detail.target;
      this.fire('itemSelected', {selected: e.detail.target});
      this.fire('blur');
    },
    checkKey: function(e) {
      if (e.which === 40 && this.input.length) {
        // has to be a nicer way to do this
        document.querySelector('[tabindex="0"]').focus();
        return;
      }

      if (e.which === 27) {
        this.hideResults = true;
      } else {
        this.hideResults = false;
      }
    },
    getFiltered: function(data, input, filterFn) {
      return filterFn.call(this, data, input);
    }
  });
})();
<commit_msg>Allow setting a max num of results<commit_after>(function() {
  'use strict';
  Polymer({
    is: 'paper-typeahead',
    properties: {
      input: String,
      hideResults: {
        type: Boolean,
        value: false
      },
      inputLabel: {
        type: String,
        value: ''
      },
      data: Array,
      filterFn: {
        type: Function,
        value: function() {
          return function(data, input) {
            var r = RegExp(input, 'i');

            if (input === '') {
              return [];
            }

            return data.filter(function(v) {
              return (r.test(v) ? v : null);
            });
          };
        }
      },
      maxResults: 50,
      filteredItems: {
        type: Array,
        computed: 'getFiltered(data, input, filterFn, maxResults)'
      }
    },
    listeners: {
      'blur': 'onBlur',
    },
    onBlur: function() {
      this.hideResults = true;
    },
    onFocus: function() {
      this.hideResults = false;
    },
    selected: function(e) {
      this.input = e.detail.target;
      this.fire('itemSelected', {selected: e.detail.target});
      this.fire('blur');
    },
    checkKey: function(e) {
      if (e.which === 40 && this.input.length) {
        // has to be a nicer way to do this
        document.querySelector('[tabindex="0"]').focus();
        return;
      }

      if (e.which === 27) {
        this.hideResults = true;
      } else {
        this.hideResults = false;
      }
    },
    getFiltered: function(data, input, filterFn, maxResults) {
      return filterFn.call(this, data, input).slice(0, maxResults);
    }
  });
})();

{'fraction_non_alphanumeric': 0.14912280701754385, 'fraction_numerical': 0.004072681704260651, 'mean_word_length': 1.6236647493837304, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '188104', 'n_tokens_mistral': 989, 'n_tokens_neox': 970, 'n_words': 211}