lib/core.js
function(in_thing, filter_function, sort_function){

	var ret = [];
	
	// Probably an not array then.
	if( typeof(in_thing) === 'undefined' ){
	    // this is a nothing, to nothing....
	}else if( typeof(in_thing) != 'object' ){
	    throw new Error('Unsupported type in bbop.core.pare: ' +
			    typeof(in_thing) );
	}else if( us.isArray(in_thing) ){
	    // An array; filter it if filter_function is defined.
	    if( filter_function ){	
		each(in_thing, function(item, index){
		    if( filter_function(item, index) ){
			// filter out item if true
		    }else{
			ret.push(item);
		    }
		});
	    }else{
		each(in_thing, function(item, index){ ret.push(item); });
	    }
	}else if( us.isFunction(in_thing) ){
	    // Skip is function (which is also an object).
	}else if( us.isObject(in_thing) ){
	    // Probably a hash; filter it if filter_function is defined.
	    if( filter_function ){	
		each(in_thing, function(val, key){
		    if( filter_function(key, val) ){
			// Remove matches to the filter.
		    }else{
			ret.push(val);
		    }
		});
	    }else{
		each(in_thing, function(val, key){ ret.push(val); });
	    }
	}else{
	    // No idea what this is--skip.
	}

	// For both: sort if there is anything.
	if( ret.length > 0 && sort_function ){
	    ret.sort(sort_function);	    
	}

	return ret;
    }
function(in_thing, filter_function, sort_function){

	var ret = [];
	
	// Probably an not array then.
	if( typeof(in_thing) === 'undefined' ){
	    // this is a nothing, to nothing....
	}else if( typeof(in_thing) != 'object' ){
	    throw new Error('Unsupported type in bbop.core.pare: ' +
			    typeof(in_thing) );
	}else if( us.isArray(in_thing) ){
	    // An array; filter it if filter_function is defined.
	    if( filter_function ){	
		each(in_thing, function(item, index){
		    if( filter_function(item, index) ){
			// filter out item if true
		    }else{
			ret.push(item);
		    }
		});
	    }else{
		each(in_thing, function(item, index){ ret.push(item); });
	    }
	}else if( us.isFunction(in_thing) ){
	    // Skip is function (which is also an object).
	}else if( us.isObject(in_thing) ){
	    // Probably a hash; filter it if filter_function is defined.
	    if( filter_function ){	
		each(in_thing, function(val, key){
		    if( filter_function(key, val) ){
			// Remove matches to the filter.
		    }else{
			ret.push(val);
		    }
		});
	    }else{
		each(in_thing, function(val, key){ ret.push(val); });
	    }
	}else{
	    // No idea what this is--skip.
	}

	// For both: sort if there is anything.
	if( ret.length > 0 && sort_function ){
	    ret.sort(sort_function);	    
	}

	return ret;
    }
function ( in_thing , filter_function , sort_function ) { var ret = [ ] ; // Probably an not array then. if ( typeof ( in_thing ) === 'undefined' ) { // this is a nothing, to nothing.... } else if ( typeof ( in_thing ) != 'object' ) { throw new Error ( 'Unsupported type in bbop.core.pare: ' + typeof ( in_thing ) ) ; } else if ( us . isArray ( in_thing ) ) { // An array; filter it if filter_function is defined. if ( filter_function ) { each ( in_thing , function ( item , index ) { if ( filter_function ( item , index ) ) { // filter out item if true } else { ret . push ( item ) ; } } ) ; } else { each ( in_thing , function ( item , index ) { ret . push ( item ) ; } ) ; } } else if ( us . isFunction ( in_thing ) ) { // Skip is function (which is also an object). } else if ( us . isObject ( in_thing ) ) { // Probably a hash; filter it if filter_function is defined. if ( filter_function ) { each ( in_thing , function ( val , key ) { if ( filter_function ( key , val ) ) { // Remove matches to the filter. } else { ret . push ( val ) ; } } ) ; } else { each ( in_thing , function ( val , key ) { ret . push ( val ) ; } ) ; } } else { // No idea what this is--skip. } // For both: sort if there is anything. if ( ret . length > 0 && sort_function ) { ret . sort ( sort_function ) ; } return ret ; }
Take an array or hash and pare it down using a couple of functions
to what we want.

Both parameters are optional in the sense that you can set them to
null and they will have no function; i.e. a null filter will let
everything through and a null sort will let things go in whatever
order.

@param {Array|Object} in_thing - hash or array
@param {Function} filter_function - hash (function(key, val)) or array (function(item, i)); this function must return boolean true or false.
@param {Function} sort_function - function to apply to elements: function(a, b); this function must return an integer as the usual sort functions do.
@returns {Array} array
Take an array or hash and pare it down using a couple of functions to what we want .