title: Manipulating values from outside Promise structures?
body: <p>I'm using Promises to synchronize my hashing functions within my node application:</p>
  
  <pre><code>var example_int = '1000121';
  
  function MakeRequest(value){
      var hash_result = RequestHash(example_int);
      hash_result.then(function(v){
        //Do stuff with v...
      })
  }
  
  function RequestHash(value){
      return(Hash(value))
  }
  
  function Hash(value){
      var HashPromise = new Promise(function(resolve, reject){
          var crypto = require('crypto');
          var hash = crypto.createHash('md5');
  
          hash.on('readable', () =&gt; {
              var data = hash.read();
              if(data){
                  var output = data.toString('hex');
                  resolve(output);
              }
          })
          hash.write(value);
          hash.end();               
      })
      return(HashPromise);
  }
  
  MakeRequest();
  </code></pre>
  
  <p>However, I want to be able to access the resulting hash values from <strong>outside</strong> the Promise functions. My initial approach was to use re-assignment:</p>
  
  <pre><code>var example_int = '1000121';
  
  function MakeRequest(value){
      var hash_result = RequestHash(example_int);
      //Hash output assigned to example_int....
  }
  
  function RequestHash(value){
      return(Hash(value))
  }
  
  function Hash(value){
      var HashPromise = new Promise(function(resolve, reject){
          var crypto = require('crypto');
          var hash = crypto.createHash('md5');
  
          hash.on('readable', () =&gt; {
              var data = hash.read();
              if(data){
                  var output = data.toString('hex');
                  example_int = output; //Re-assignment...
                  resolve(output);
              }
          })
          hash.write(value);
          hash.end();               
      })
      return(HashPromise);
  }
  
  MakeRequest();
  </code></pre>
  
  <p>Is there a safer way and/or more efficient method of performing this without the reliance on re-assingment?</p>