vm/src/lib.js
function (table, index) {	
			// SLOOOOOOOW...
			var found = (index === undefined),
				numValues = table.__shine.numValues,
				keys,
				key, value,
				i, l;

			if (found || (typeof index == 'number' && index > 0 && index == index >> 0)) {
				if ('keys' in Object) {
					// Use Object.keys, if available.
					keys = Object['keys'](numValues);
					
					if (found) {
						// First pass
						i = 1;

					} else if (i = keys.indexOf('' + index) + 1) {
						found = true;
					} 

					if (found) {
						while ((key = keys[i]) !== void 0 && (value = numValues[key]) === void 0) i++;
						if (value !== void 0) return [key >>= 0, value];
					}

				} else {
					// Else use for-in (faster than for loop on tables with large holes)

					for (l in numValues) {	
						i = l >> 0;

						if (!found) {
							if (i === index) found = true;
			
						} else if (numValues[i] !== undefined) {
							return [i, numValues[i]];
						}
					}
				}
			}
			
			for (i in table) {
				if (table.hasOwnProperty(i) && !(i in shine.Table.prototype) && i !== '__shine') {
					if (!found) {
						if (i == index) found = true;
	
					} else if (table.hasOwnProperty(i) && table[i] !== undefined && ('' + i).substr(0, 2) != '__') {
						return [i, table[i]];
					}
				}
			}
	
			for (i in table.__shine.keys) {
				if (table.__shine.keys.hasOwnProperty(i)) {
					var key = table.__shine.keys[i];
	
					if (!found) {
						if (key === index) found = true;
		
					} else if (table.__shine.values[i] !== undefined) {
						return [key, table.__shine.values[i]];
					}
				}
			}
		
			return shine.gc.createArray();
		}
function (table, index) {	
			// SLOOOOOOOW...
			var found = (index === undefined),
				numValues = table.__shine.numValues,
				keys,
				key, value,
				i, l;

			if (found || (typeof index == 'number' && index > 0 && index == index >> 0)) {
				if ('keys' in Object) {
					// Use Object.keys, if available.
					keys = Object['keys'](numValues);
					
					if (found) {
						// First pass
						i = 1;

					} else if (i = keys.indexOf('' + index) + 1) {
						found = true;
					} 

					if (found) {
						while ((key = keys[i]) !== void 0 && (value = numValues[key]) === void 0) i++;
						if (value !== void 0) return [key >>= 0, value];
					}

				} else {
					// Else use for-in (faster than for loop on tables with large holes)

					for (l in numValues) {	
						i = l >> 0;

						if (!found) {
							if (i === index) found = true;
			
						} else if (numValues[i] !== undefined) {
							return [i, numValues[i]];
						}
					}
				}
			}
			
			for (i in table) {
				if (table.hasOwnProperty(i) && !(i in shine.Table.prototype) && i !== '__shine') {
					if (!found) {
						if (i == index) found = true;
	
					} else if (table.hasOwnProperty(i) && table[i] !== undefined && ('' + i).substr(0, 2) != '__') {
						return [i, table[i]];
					}
				}
			}
	
			for (i in table.__shine.keys) {
				if (table.__shine.keys.hasOwnProperty(i)) {
					var key = table.__shine.keys[i];
	
					if (!found) {
						if (key === index) found = true;
		
					} else if (table.__shine.values[i] !== undefined) {
						return [key, table.__shine.values[i]];
					}
				}
			}
		
			return shine.gc.createArray();
		}
function ( table , index ) { // SLOOOOOOOW... var found = ( index === undefined ) , numValues = table . __shine . numValues , keys , key , value , i , l ; if ( found || ( typeof index == 'number' && index > 0 && index == index >> 0 ) ) { if ( 'keys' in Object ) { // Use Object.keys, if available. keys = Object [ 'keys' ] ( numValues ) ; if ( found ) { // First pass i = 1 ; } else if ( i = keys . indexOf ( '' + index ) + 1 ) { found = true ; } if ( found ) { while ( ( key = keys [ i ] ) !== void 0 && ( value = numValues [ key ] ) === void 0 ) i ++ ; if ( value !== void 0 ) return [ key >>= 0 , value ] ; } } else { // Else use for-in (faster than for loop on tables with large holes) for ( l in numValues ) { i = l >> 0 ; if ( ! found ) { if ( i === index ) found = true ; } else if ( numValues [ i ] !== undefined ) { return [ i , numValues [ i ] ] ; } } } } for ( i in table ) { if ( table . hasOwnProperty ( i ) && ! ( i in shine . Table . prototype ) && i !== '__shine' ) { if ( ! found ) { if ( i == index ) found = true ; } else if ( table . hasOwnProperty ( i ) && table [ i ] !== undefined && ( '' + i ) . substr ( 0 , 2 ) != '__' ) { return [ i , table [ i ] ] ; } } } for ( i in table . __shine . keys ) { if ( table . __shine . keys . hasOwnProperty ( i ) ) { var key = table . __shine . keys [ i ] ; if ( ! found ) { if ( key === index ) found = true ; } else if ( table . __shine . values [ i ] !== undefined ) { return [ key , table . __shine . values [ i ] ] ; } } } return shine . gc . createArray ( ) ; }
Implementation of Lua's next function.
@param {object} table The table that will receive the metatable.
@param {object} index Index of the item to return.
Implementation of Lua s next function .