function addFavourite(fave) {
  var links;

  // validates if fave is a hash
  if (!RegExp(/Qm[a-zA-Z0-9]*/).test(fave)) {
    return null;
  }
  try {
    links = getLinks(App.Agent.Hash, FAVOURITES, { Load: true });
  } catch (exception) {
    debug('Error getting favourite links when adding: ' + exception);
  }
  try {
    var faveHash;
    var faves = getFavourites();

    // add a random value to the array to maintain uniqueness
    // for the purposes of using update
    faves[0] = 'abc' + Math.random(); //makeHash(FAVOURITES, Math.random());
    faves.push(fave);

    // if the link doesn't exist, create it:
    if (!links || links.length < 1) {
      faveHash = commit(FAVOURITES, faves);
      commit('profile_links', {
        Links: [{ Base: App.Agent.Hash, Link: faveHash, Tag: FAVOURITES }]
      });
      // not great...remove 1st element here to remove unique value
      faves.splice(0, 1);
    } else {
      faves = updateFavourite(faves);
    }
  } catch (exception) {
    debug('Error committing faves: ' + exception);
  }
  return faves;
}
/**
 * @param fave is the hash to add to favourites
 * @return current array of favourites or null if input is invalid
 **/
@param fave is the hash to add to favourites
@return current array of favourites or null if input is invalid
@param fave is the hash to add to favourites @return current array of favourites or null if input is invalid
function addFavourite(fave) {
  var links;
  if (!RegExp(/Qm[a-zA-Z0-9]*/).test(fave)) {
    return null;
  }
  try {
    links = getLinks(App.Agent.Hash, FAVOURITES, { Load: true });
  } catch (exception) {
    debug('Error getting favourite links when adding: ' + exception);
  }
  try {
    var faveHash;
    var faves = getFavourites();
    faves[0] = 'abc' + Math.random(); 
    faves.push(fave);
    if (!links || links.length < 1) {
      faveHash = commit(FAVOURITES, faves);
      commit('profile_links', {
        Links: [{ Base: App.Agent.Hash, Link: faveHash, Tag: FAVOURITES }]
      });
      faves.splice(0, 1);
    } else {
      faves = updateFavourite(faves);
    }
  } catch (exception) {
    debug('Error committing faves: ' + exception);
  }
  return faves;
}
function addFavourite ( fave ) { var links ; if ( ! RegExp ( / Qm[a-zA-Z0-9]* / ) . test ( fave ) ) { return null ; } try { links = getLinks ( App . Agent . Hash , FAVOURITES , { Load : true } ) ; } catch ( exception ) { debug ( 'Error getting favourite links when adding: ' + exception ) ; } try { var faveHash ; var faves = getFavourites ( ) ; faves [ 0 ] = 'abc' + Math . random ( ) ; faves . push ( fave ) ; if ( ! links || links . length < 1 ) { faveHash = commit ( FAVOURITES , faves ) ; commit ( 'profile_links' , { Links : [ { Base : App . Agent . Hash , Link : faveHash , Tag : FAVOURITES } ] } ) ; faves . splice ( 0 , 1 ) ; } else { faves = updateFavourite ( faves ) ; } } catch ( exception ) { debug ( 'Error committing faves: ' + exception ) ; } return faves ; }
@param fave is the hash to add to favourites
 @return current array of favourites or null if input is invalid
@param fave is the hash to add to favourites @return current array of favourites or null if input is invalid
// validates if fave is a hash // add a random value to the array to maintain uniqueness // for the purposes of using update //makeHash(FAVOURITES, Math.random()); // if the link doesn't exist, create it: // not great...remove 1st element here to remove unique value