Line 250: |
Line 250: |
| | | |
| function checkdive( array, read){ | | function checkdive( array, read){ |
− | if ( check(array, read) !== undefined) { | + | if ( ( array !== undefined ) && ( read !== undefined ) ) { |
− | return dive(array, read);
| + | if ( check(array, read) !== undefined) { |
− | } else if ( Array.isArray(array) ) {
| + | return dive(array, read); |
− | var potential_return = [];
| + | } else if ( Array.isArray(array) ) { |
− | Object.keys(array).forEach( function(item){
| + | var potential_return = []; |
− | if ( check(array[item], read) !== undefined ) {
| + | Object.keys(array).forEach( function(item){ |
− | potential_return.push( dive( array[item], read) );
| + | if ( check(array[item], read) !== undefined ) { |
− | }
| + | potential_return.push( dive( array[item], read) ); |
− | });
| + | } |
− | return potential_return;
| + | }); |
− | }
| + | return potential_return; |
− | if ( array === read ) {
| + | } |
− | return read;
| + | if ( array === read ) { |
− | }
| + | return read; |
− | if (Object.keys( array ).length > 0 ){
| + | } |
− | Object.keys( array ).forEach( function ( piece ) {
| + | if (Object.keys( array ).length > 0 ){ |
− | if ( array[ piece ] === read ) { return read };
| + | Object.keys( array ).forEach( function ( piece ) { |
− | });
| + | if ( array[ piece ] === read ) { return read }; |
| + | }); |
| + | } |
| } | | } |
| } | | } |