<commit_before>// Copyright 2016-2018, University of Colorado Boulder

/**
 * IO type for JS's built-in Array type.
 *
 * @author <NAME> (PhET Interactive Simulations)
 * @author <NAME> (PhET Interactive Simulations)
 */
define( function( require ) {
  'use strict';

  // modules
  var ObjectIO = require( 'TANDEM/types/ObjectIO' );
  var phetioInherit = require( 'TANDEM/phetioInherit' );
  var tandemNamespace = require( 'TANDEM/tandemNamespace' );

  /**
   * Parametric IO type constructor.  Given an element type, this function returns an appropriate array IO type.
   * @param {ObjectIO} elementType - IO type of the individual elements in the array. If loaded by phet (not phet-io)
   *                                    it will be the function returned by the 'ifphetio!' plugin.
   * @constructor
   */
  function ArrayIO( elementType ) {

    /**
     * This type constructor is parameterized based on the elementType.
     * @param {Object[]} array - the array to be wrapped
     * @param {string} phetioID
     * @constructor
     */
    var ArrayIOImpl = function ArrayIOImpl( array, phetioID ) {
      assert && assert( Array.isArray( array ), 'ArrayIO should wrap array instances' );
      ObjectIO.call( this, array, phetioID );
    };
    return phetioInherit( ObjectIO, 'ArrayIO', ArrayIOImpl, {}, {
      parameterTypes: [ elementType ],
      documentation: 'A wrapper for the built-in JS array type, with the element type specified.',
      elementType: elementType,

      /**
       * @override
       * @public
       * @param {*} instance
       * @returns {boolean}
       */
      isInstance: function( instance ) { return Array.isArray( instance ); },

      /**
       * Serialize an array by serializing each element
       * @param {Object[]} array
       * @returns {Array}
       * @override
       */
      toStateObject: function( array ) {
        assert && assert( Array.isArray( array ), 'ArrayIO should wrap array instances' );
        assert && assert( elementType.toStateObject, elementType.typeName + ' does not have a toStateObject method.' );

        var json = [];
        for ( var i = 0; i < array.length; i++ ) {
          json.push( elementType.toStateObject( array[ i ] ) );
        }
        return json;
      },

      /**
       * Deserialize from a serialized state.
       * @param {Object} stateObject - from toStateObject
       * @returns {Object[]}
       * @override
       */
      fromStateObject: function( stateObject ) {<commit_msg>check element types in ArrayIO.isInstance() too, https://github.com/phetsims/axon/issues/190<commit_after>// Copyright 2016-2018, University of Colorado Boulder

/**
 * IO type for JS's built-in Array type.
 *
 * @author <NAME> (PhET Interactive Simulations)
 * @author <NAME> (PhET Interactive Simulations)
 */
define( function( require ) {
  'use strict';

  // modules
  var ObjectIO = require( 'TANDEM/types/ObjectIO' );
  var phetioInherit = require( 'TANDEM/phetioInherit' );
  var tandemNamespace = require( 'TANDEM/tandemNamespace' );

  /**
   * Parametric IO type constructor.  Given an element type, this function returns an appropriate array IO type.
   * @param {ObjectIO} elementType - IO type of the individual elements in the array. If loaded by phet (not phet-io)
   *                                    it will be the function returned by the 'ifphetio!' plugin.
   * @constructor
   */
  function ArrayIO( elementType ) {

    /**
     * This type constructor is parameterized based on the elementType.
     * @param {Object[]} array - the array to be wrapped
     * @param {string} phetioID
     * @constructor
     */
    var ArrayIOImpl = function ArrayIOImpl( array, phetioID ) {
      assert && assert( Array.isArray( array ), 'ArrayIO should wrap array instances' );
      ObjectIO.call( this, array, phetioID );
    };
    return phetioInherit( ObjectIO, 'ArrayIO', ArrayIOImpl, {}, {
      parameterTypes: [ elementType ],
      documentation: 'A wrapper for the built-in JS array type, with the element type specified.',
      elementType: elementType,

      /**
       * @override
       * @public
       * @param {*} instance
       * @returns {boolean}
       */
      isInstance: function( instance ) {
        if ( !Array.isArray( instance ) ) {
          return false;
        }

        // default to true until something isn't correct
        var isCorrectType = true;
        instance.forEach( function( element ) {
          if ( !elementType.isInstance( element ) ) {
            isCorrectType = false;
          }
        } );
        return isCorrectType;
      },

      /**
       * Serialize an array by serializing each element
       * @param {Object[]} array
       * @returns {Array}
       * @override
       */
      toStateObject: function( array ) {
        assert && assert( Array.isArray( array ), 'ArrayIO should wrap array instances' );
        assert && assert( elementType.toStateObject, elementType.typeName + ' does not have a toStateObject method.' );

        var json = [];
        for ( var i = 0; i < array.length; i++ ) {
          json.push( elementType.toStateObject( array[ i ] ) );
        }
        return json;
      },

      /**
       * Deserialize from a serialized state.
       * @param {Object} stateObject - from toStateObject
       * @returns {Object[]}
       * @override
       */
      fromStateObject: function( stateObject ) {
{'fraction_non_alphanumeric': 0.11061865189289012, 'fraction_numerical': 0.003878116343490305, 'mean_word_length': 2.385, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3263081', 'n_tokens_mistral': 1546, 'n_tokens_neox': 1500, 'n_words': 490}