<commit_before>/*jshint white: false, strict: false, plusplus: false, onevar: false,
  nomen: false */
/*global define: false, console: false, window: false, setTimeout: false */

define( function ( require ) {

        return function( options ) {

            option = options || {};

            var _type = options.type || undefined;
            var _cache = options.cache || null;
            var _object = options.object;

            var Resource = function( options ) {
            
                options = options || {};

                var _source = options.source || null;
                if( !_source ) {
                    var _constructor = options.constructor || null;
                    var _parameters = options.parameters || {};
                }

                var _onComplete = options.onComplete || function( instance ) {};
                var _onError = options.onError || function( error ) {};

                _cache = options.cache || _cache; 

                var instance;
                if( _source ) {
                    if( _cache && _cache.contains( _source ) ) {
                        // Find the instance in the cache and return it
                    } else {
                        // Fetch the instance from its source
                        var xhr = new XMLHttpRequest();
                        xhr.open( 'GET', _source, true );
                        xhr.onreadystatechange = function() {
                            if( 4 != xhr.readyState ) {
                                return;
                            }
                            var response = JSON.parse( xhr.responseText );
                            instance = new _object( response.source );
                            _onComplete( instance );
                        };
                        xhr.send( null );
                    }
                }
                if( !instance && _constructor ) {
                    // Use the constructor to build an instance of object
                }

                if( _cache && instance ) {
                    // Cache the instance that we fetched or constructed
                }

            };
<commit_msg>Complete implementation (minus cache) for Resource.<commit_after>/*jshint white: false, strict: false, plusplus: false, onevar: false,
  nomen: false */
/*global define: false, console: false, window: false, setTimeout: false */

define( function ( require ) {

        return function( options ) {

            option = options || {};

            var _type = options.type || undefined;
            var _cache = options.cache || null;
            var _object = options.object;

            var Resource = function( options ) {
            
                options = options || {};

                var _source = options.source || null;
                if( !_source ) {
                    var _constructor = options.constructor || null;
                    var _parameters = options.parameters || {};
                }

                var _onComplete = options.onComplete || function( instance ) {};
                var _onError = options.onError || function( error ) {};

                _cache = options.cache || _cache; 

                var instance;
                if( _source ) {
                    if( _cache && _cache.contains( _source ) ) {
                        // Find the instance in the cache and return it
                        instance = _cache.find( _source );                        
                        _onComplete( instance );
                    } else {
                        // Fetch the instance from its source
                        var xhr = new XMLHttpRequest();
                        xhr.open( 'GET', _source, true );
                        xhr.onreadystatechange = function() {
                            if( 4 != xhr.readyState ) {
                                return;
                            }
                            var response = JSON.parse( xhr.responseText );
                            instance = new _object( response.source );
                            if( _cache ) _cache.add( instance );
                            _onComplete( instance );
                        };
                        xhr.send( null );
                    }
                    return;
                }
                if( !instance && _constructor ) {
                    // Use the constructor to build an instance of object
                    instance = _constructor.apply( null, _parameters );
                    if( _cache ) _cache.add( instance );
                    _onComplete( instance );
                    return;
                }
            };

{'fraction_non_alphanumeric': 0.08736415938632006, 'fraction_numerical': 0.0004261666311527807, 'mean_word_length': 1.0444250871080138, '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': '4585548', 'n_tokens_mistral': 1062, 'n_tokens_neox': 976, 'n_words': 303}