title: NodeJS, adding actions to a Promise in a While loop
body: <p>so I am fairly new to using Promises in NodeJS. I am trying to dynamically create a promise with a few actions depending on the characters in a string.</p>
  
  <pre><code>//let actions = [];
  getPromise = get(srcBucket, srcKey); // Get the image
  
  //Apply transformations to image.
  while (transformations.length &gt; 0) {
    let op = transformations.charAt(0);
    if (op == 'B') {
      getPromise.then(image =&gt; blur(image));
    } else if (op == 'R') {
      getPromise.then(image =&gt; resize(image));
    } else if (op == 'O') {
      getPromise.then(image =&gt; rotate(image));
    } else if (op == 'S') {
      getPromise.then(image =&gt; sepia(image));
    } else if (op == 'C') {
      getPromise.then(image =&gt; compress(image));
    }
    transformations = transformations.substring(1);
  }
  
  getPromise.then(modified =&gt; put(destBucket, destKey, modified))
    .then(() =&gt; putSAAFOutput(inspector))
    .then(() =&gt; {
    console.log('Success');
    return resolve('Success');
  })
  .catch(error =&gt; {
    console.error(error);
    return reject(error);
  });
  </code></pre>
  
  <p>The get method in the first line gets an image from Amazon S3. Then I want to make a number of transformations to that image based of the characters in the "transformations" string. Each of the transformation functions (blur, resize, sepia, etc) all return their own promises.</p>
  
  <p>When I run this function none of the transformations are being applied to the image! Any help would be really appreciated.</p>