lib/vendor/sugar.js
function(search, fn) {
      var match, i, len;
      if(isFunction(search)) {
        fn = search;
        search = /[\s\S]/g;
      } else if(!search) {
        search = /[\s\S]/g
      } else if(isString(search)) {
        search = regexp(escapeRegExp(search), 'gi');
      } else if(isRegExp(search)) {
        search = regexp(search.source, getRegExpFlags(search, 'g'));
      }
      match = this.match(search) || [];
      if(fn) {
        for(i = 0, len = match.length; i < len; i++) {
          match[i] = fn.call(this, match[i], i, match) || match[i];
        }
      }
      return match;
    }
function(search, fn) {
      var match, i, len;
      if(isFunction(search)) {
        fn = search;
        search = /[\s\S]/g;
      } else if(!search) {
        search = /[\s\S]/g
      } else if(isString(search)) {
        search = regexp(escapeRegExp(search), 'gi');
      } else if(isRegExp(search)) {
        search = regexp(search.source, getRegExpFlags(search, 'g'));
      }
      match = this.match(search) || [];
      if(fn) {
        for(i = 0, len = match.length; i < len; i++) {
          match[i] = fn.call(this, match[i], i, match) || match[i];
        }
      }
      return match;
    }
function ( search , fn ) { var match , i , len ; if ( isFunction ( search ) ) { fn = search ; search = / [\s\S] / g ; } else if ( ! search ) { search = / [\s\S] / g } else if ( isString ( search ) ) { search = regexp ( escapeRegExp ( search ) , 'gi' ) ; } else if ( isRegExp ( search ) ) { search = regexp ( search . source , getRegExpFlags ( search , 'g' ) ) ; } match = this . match ( search ) || [ ] ; if ( fn ) { for ( i = 0 , len = match . length ; i < len ; i ++ ) { match [ i ] = fn . call ( this , match [ i ] , i , match ) || match [ i ] ; } } return match ; }
*
@method each([search] = single character, [fn])
@returns Array
@short Runs callback [fn] against each occurence of [search].
@extra Returns an array of matches. [search] may be either a string or regex, and defaults to every character in the string.
@example

'jumpy'.each() -> ['j','u','m','p','y']
'jumpy'.each(/[r-z]/) -> ['u','y']
'jumpy'.each(/[r-z]/, function(m) {
// Called twice: "u", "y"
});

*
* @method each ( [ search ] = single character [ fn ] ) @returns Array @short Runs callback [ fn ] against each occurence of [ search ] . @extra Returns an array of matches . [ search ] may be either a string or regex and defaults to every character in the string . @example