index.js
function _deTokenize( container, arr ) {
  var val,
      tokens = [];

  function _parseFloat( str ) {
    return parseFloat( unFormatUSD(str) );
  }

  for ( var i = 0, len = arr.length; i < len; i++ ) {
    var token = arr[i];
    // @TODO DRY this up.
    if ( token.type === 'function' ) {
      tokens.push( token.value );
    } else if ( token.type === 'operator' || token.type === 'number' ) {
      tokens.push( token.value );
    } else {
      try {
        // @TODO accommodate radio and other elements that don't use .value
        val = _getDOMElement( container, token.value );
        // Grab the value or the placeholder or default to 0.
        val = unFormatUSD( val.value || val.getAttribute('placeholder') || 0 );
        // Make it a number if it's a number.
        val = isNaN( val ) ? val : _parseFloat( val );
        tokens.push( val );
      } catch ( e ) {}
    }
  }
  // @TODO This feels a little repetitive.
  if ( typeof tokens[0] === 'function' ) {
    return tokens[0]();
  }
  val = tokens.length > 1 ? eval( tokens.join(' ') ) : tokens.join(' ');
  return isNaN( val ) ? val : _parseFloat( val );
}
function _deTokenize( container, arr ) {
  var val,
      tokens = [];

  function _parseFloat( str ) {
    return parseFloat( unFormatUSD(str) );
  }

  for ( var i = 0, len = arr.length; i < len; i++ ) {
    var token = arr[i];
    // @TODO DRY this up.
    if ( token.type === 'function' ) {
      tokens.push( token.value );
    } else if ( token.type === 'operator' || token.type === 'number' ) {
      tokens.push( token.value );
    } else {
      try {
        // @TODO accommodate radio and other elements that don't use .value
        val = _getDOMElement( container, token.value );
        // Grab the value or the placeholder or default to 0.
        val = unFormatUSD( val.value || val.getAttribute('placeholder') || 0 );
        // Make it a number if it's a number.
        val = isNaN( val ) ? val : _parseFloat( val );
        tokens.push( val );
      } catch ( e ) {}
    }
  }
  // @TODO This feels a little repetitive.
  if ( typeof tokens[0] === 'function' ) {
    return tokens[0]();
  }
  val = tokens.length > 1 ? eval( tokens.join(' ') ) : tokens.join(' ');
  return isNaN( val ) ? val : _parseFloat( val );
}
function _deTokenize ( container , arr ) { var val , tokens = [ ] ; function _parseFloat ( str ) { return parseFloat ( unFormatUSD ( str ) ) ; } for ( var i = 0 , len = arr . length ; i < len ; i ++ ) { var token = arr [ i ] ; // @TODO DRY this up. if ( token . type === 'function' ) { tokens . push ( token . value ) ; } else if ( token . type === 'operator' || token . type === 'number' ) { tokens . push ( token . value ) ; } else { try { // @TODO accommodate radio and other elements that don't use .value val = _getDOMElement ( container , token . value ) ; // Grab the value or the placeholder or default to 0. val = unFormatUSD ( val . value || val . getAttribute ( 'placeholder' ) || 0 ) ; // Make it a number if it's a number. val = isNaN ( val ) ? val : _parseFloat ( val ) ; tokens . push ( val ) ; } catch ( e ) { } } } // @TODO This feels a little repetitive. if ( typeof tokens [ 0 ] === 'function' ) { return tokens [ 0 ] ( ) ; } val = tokens . length > 1 ? eval ( tokens . join ( ' ' ) ) : tokens . join ( ' ' ) ; return isNaN ( val ) ? val : _parseFloat ( val ) ; }
Process an array of tokens, returning a single value.
@param  {object} container DOM element node of parent container.
@param  {array} arr Array of tokens created from _tokenize.
@return {string|number} The value of the processed tokens.
Process an array of tokens returning a single value .