<commit_before>import Ember from 'ember';
var Mixin = Ember.Mixin;
var defineProperty = Ember.defineProperty;
var debounce = Ember.run.debounce;
var capitalize = Ember.String.capitalize;

/**
  Creates debounced versions of properties listed in the `debouncedProperties`
  array. For each of these properties, a `debounced*` version is created with a
  default delay of 1000ms. You can override this by defining `*Delay`.


  ## Example (Ember App Kit)

  ```javascript
  // components/gravatar-image.js

  import DebouncedPropertiesMixin from 'appkit/mixins/debounced-properties';

  export default Ember.Component.extend(DebouncedPropertiesMixin, {
    tagName: 'img',
    attributeBindings: ['src'],

    debouncedProperties: ['email'],
    emailDelay: 2000, // optional, 1000ms by default,

    src: Ember.computed.alias('gravatarUrl'),
    gravatarUrl: function() {
      return '//www.gravatar.com/avatar/'+md5(this.get('email'));
    }.property('debouncedEmail')
  });
  ```

  ```handlebars
  {{gravatar-image email='<EMAIL>'}}
  ```
*/
export default Mixin.create({
  concatenatedProperties: ['debouncedProperties'],
  debouncedProperties: [],

  init: function() {
    this._super();

    var props = this.get('debouncedProperties');

    for (var i=0, len=props.length; i<len; i++) {
      var property = props[i];
      var setterName = 'setDebounced'+capitalize(property);
      var observerName = property+'DidChange';

      defineCallbackMethod(this, property, setterName);
      setupObserver(this, property, setterName, observerName);
      this.addObserver(property, this, this[observerName]);
    }
  }
});


function setupObserver(obj, property, setterName, observerName) {<commit_msg>Remove example from mixin<commit_after>import Ember from 'ember';
var Mixin = Ember.Mixin;
var defineProperty = Ember.defineProperty;
var debounce = Ember.run.debounce;
var capitalize = Ember.String.capitalize;


export default Mixin.create({
  concatenatedProperties: ['debouncedProperties'],
  debouncedProperties: [],

  init: function() {
    this._super();

    var props = this.get('debouncedProperties');

    for (var i=0, len=props.length; i<len; i++) {
      var property = props[i];
      var setterName = 'setDebounced'+capitalize(property);
      var observerName = property+'DidChange';

      defineCallbackMethod(this, property, setterName);
      setupObserver(this, property, setterName, observerName);
      this.addObserver(property, this, this[observerName]);
    }
  }
});


function setupObserver(obj, property, setterName, observerName) {
{'fraction_non_alphanumeric': 0.12889408099688474, 'fraction_numerical': 0.005841121495327103, 'mean_word_length': 4.3632567849686845, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '7435778', 'n_tokens_mistral': 803, 'n_tokens_neox': 754, 'n_words': 187}