Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
//indexOfSubarray.js
/*global adventurejs A*/ 

/**
 * Determine if one array is nested in another.
 * @method adventurejs#indexOfSubarray
 * @memberOf adventurejs
 * @param {Array} sub 0=log, 1=warn, 2=error 
 * @param {Array} arr 0=critical, 1=high, 2=medium, 3=low
 * @returns {int}
 */
adventurejs.indexOfSubarray = function Adventurejs_indexOfSubarray( sub, arr ) 
{
  var index = -1;
  var subJson = JSON.stringify( sub );
  if( false === Array.isArray( sub) 
  || false === Array.isArray( arr ) ) 
  {
    return index;
  }
  for( var i = 0; i < arr.length; i++ )
  {
    if( subJson === JSON.stringify( arr[i] ) ) 
    {
      index = i;
      break;
    }
  }
  return index;
};