<commit_before>
/* =========================================================================
 * Svelto - Core - Readify
 * =========================================================================
 * Copyright (c) 2015-2017 <NAME>
 * Licensed under MIT (https://github.com/svelto/svelto/blob/master/LICENSE)
 * =========================================================================
 * @require core/svelto/svelto.js
 * ========================================================================= */

//TODO: Maybe rename it, `Readify` doesn't sound right
//FIXME: We actually `require` Widget, but requiring it creates a circular dependency...

(function ( $, _, Svelto, Widgets ) {

  'use strict';

  /* READIFY */

  class Readify {

    constructor () {

      this.queue = [];

    }

    /* METHODS */

    get () {

      return this.queue;

    }

    add ( fn ) {

      if ( this._isReady ) {

        this.worker ( fn );

      } else {

        this.queue.push ( fn );

      }

    }

    remove ( fn ) {

      _.pull ( this.queue, fn );

    }

    ready () {

      this._isReady = true;

      this.queue.forEach ( this.worker.bind ( this ) );

      this.queue = [];

    }

    worker ( fn ) {

      if ( 'config' in fn ) { //FIXME: Not really future proof

        let Widget = fn,
            ready = Widget.ready || Widget.__proto__.ready || Widgets.Widget.ready, //IE10 support -- static property
            initReady = Widget._initReady || Widget.__proto__._initReady || Widgets.Widget._initReady, //IE10 support -- static property
            setReady = Widget._setReady || Widget.__proto__._setReady || Widgets.Widget._setReady; //IE10 support -- static property

        initReady.bind ( Widget )();

        ready.bind ( Widget )( setReady.bind ( Widget ) );

      } else {

        fn ();

      }

    }

  }

  /* EXPORT */

  Svelto.Readify = new Readify ();

  /* READY */

  $(Svelto.Readify.ready.bind ( Svelto.Readify ));

}( Svelto.$, Svelto._, Svelto, Svelto.Widgets ));<commit_msg>Readify: default ready state coming from `window.__svelto_readify_ready`<commit_after>
/* =========================================================================
 * Svelto - Core - Readify
 * =========================================================================
 * Copyright (c) 2015-2017 <NAME>
 * Licensed under MIT (https://github.com/svelto/svelto/blob/master/LICENSE)
 * =========================================================================
 * @require core/svelto/svelto.js
 * ========================================================================= */

//TODO: Maybe rename it, `Readify` doesn't sound right
//FIXME: We actually `require` Widget, but requiring it creates a circular dependency...

(function ( $, _, Svelto, Widgets ) {

  'use strict';

  /* READIFY */

  class Readify {

    constructor () {

      this.queue = [];
      this._isReady = !!window.__svelto_readify_ready;

    }

    /* METHODS */

    get () {

      return this.queue;

    }

    add ( fn ) {

      if ( this._isReady ) {

        this.worker ( fn );

      } else {

        this.queue.push ( fn );

      }

    }

    remove ( fn ) {

      _.pull ( this.queue, fn );

    }

    isReady () {

      return this._isReady;

    }

    ready () {

      if ( this._isReady ) return;

      this._isReady = true;

      this.queue.forEach ( this.worker.bind ( this ) );

      this.queue = [];

    }

    worker ( fn ) {

      if ( 'config' in fn ) { //FIXME: Not really future proof

        let Widget = fn,
            ready = Widget.ready || Widget.__proto__.ready || Widgets.Widget.ready, //IE10 support -- static property
            initReady = Widget._initReady || Widget.__proto__._initReady || Widgets.Widget._initReady, //IE10 support -- static property
            setReady = Widget._setReady || Widget.__proto__._setReady || Widgets.Widget._setReady; //IE10 support -- static property

        initReady.bind ( Widget )();

        ready.bind ( Widget )( setReady.bind ( Widget ) );

      } else {

        fn ();

      }

    }

  }

  /* EXPORT */

  Svelto.Readify = new Readify ();

  /* READY */

  if ( !Svelto.Readify.isReady () ) {

    $(Svelto.Readify.ready.bind ( Svelto.Readify ));

  }

}( Svelto.$, Svelto._, Svelto, Svelto.Widgets ));
{'fraction_non_alphanumeric': 0.26094040968342647, 'fraction_numerical': 0.006517690875232775, 'mean_word_length': 2.44035228182546, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '6315846', 'n_tokens_mistral': 1323, 'n_tokens_neox': 1208, 'n_words': 268}