index.js
function _tokenize( prop ) {

  var tokens = [],
      patterns,
      src = prop.source;

  src = typeof src !== 'string' ? src : src.split(' ');

  patterns = {
    operator: /^[+\-\*\/\%]$/, // +-*/%
    // @TODO Improve this regex to cover numbers like 1,000,000
    number: /^\$?\d+[\.,]?\d+$/
  };

  function _pushToken( val, type ) {
    var token = {
      value: val,
      type: type
    };
    tokens.push( token );
  }

  // Return early if it's a function.
  if ( typeof src === 'function' ) {
    _pushToken( src, 'function' );
    return tokens;
  }

  // @TODO DRY this up.
  for ( var i = 0, len = src.length; i < len; i++ ) {
    if ( patterns.operator.test(src[i]) ) {
      _pushToken( src[i].match(patterns.operator)[0], 'operator' );
    } else if ( patterns.number.test(src[i]) ) {
      _pushToken( parseFloat( src[i].match(patterns.number)[0] ), 'number' );
    } else {
      _pushToken( src[i], 'name' );
    }
  }
  return tokens;

}
function _tokenize( prop ) {

  var tokens = [],
      patterns,
      src = prop.source;

  src = typeof src !== 'string' ? src : src.split(' ');

  patterns = {
    operator: /^[+\-\*\/\%]$/, // +-*/%
    // @TODO Improve this regex to cover numbers like 1,000,000
    number: /^\$?\d+[\.,]?\d+$/
  };

  function _pushToken( val, type ) {
    var token = {
      value: val,
      type: type
    };
    tokens.push( token );
  }

  // Return early if it's a function.
  if ( typeof src === 'function' ) {
    _pushToken( src, 'function' );
    return tokens;
  }

  // @TODO DRY this up.
  for ( var i = 0, len = src.length; i < len; i++ ) {
    if ( patterns.operator.test(src[i]) ) {
      _pushToken( src[i].match(patterns.operator)[0], 'operator' );
    } else if ( patterns.number.test(src[i]) ) {
      _pushToken( parseFloat( src[i].match(patterns.number)[0] ), 'number' );
    } else {
      _pushToken( src[i], 'name' );
    }
  }
  return tokens;

}
function _tokenize ( prop ) { var tokens = [ ] , patterns , src = prop . source ; src = typeof src !== 'string' ? src : src . split ( ' ' ) ; patterns = { operator : / ^[+\-\*\/\%]$ / , // +-*/% // @TODO Improve this regex to cover numbers like 1,000,000 number : / ^\$?\d+[\.,]?\d+$ / } ; function _pushToken ( val , type ) { var token = { value : val , type : type } ; tokens . push ( token ) ; } // Return early if it's a function. if ( typeof src === 'function' ) { _pushToken ( src , 'function' ) ; return tokens ; } // @TODO DRY this up. for ( var i = 0 , len = src . length ; i < len ; i ++ ) { if ( patterns . operator . test ( src [ i ] ) ) { _pushToken ( src [ i ] . match ( patterns . operator ) [ 0 ] , 'operator' ) ; } else if ( patterns . number . test ( src [ i ] ) ) { _pushToken ( parseFloat ( src [ i ] . match ( patterns . number ) [ 0 ] ) , 'number' ) ; } else { _pushToken ( src [ i ] , 'name' ) ; } } return tokens ; }
Split source strings and taxonimize language.
@param  {string|function} src String to tokenize. If it's a function, leave it.
@return {array}      Array of objects, each a token.
Split source strings and taxonimize language .