 <p>I wouldn't go for a <code>switch</code> at all.</p> <p>There is no reason to use chaining at all here. Just do</p> <pre><code>// if (!/^(original|large|medium|small)$/.test(style.name)) throw new Error(…); var x = gm(response.Body) .setFormat('jpg') .autoOrient() .resize(style.w, style.h, style.option); if (style.name == "medium" || style.name == "small") x = x.crop(style.w, style.h, style.crop.x_offset, style.crop.y_offset) .repage('+'); if (style.name == "large" || style.name == "small") x = x.quality(style.quality); if (style.name == "large" || style.name == "medium" || style.name == "small") // possibly better than if (style.name != "original") x = x.strip() .interlace('Plane'); x.toBuffer(next); </code></pre> <p>But if you're having a large set of options so that it gets unreadable, better factor out each transformation in a function:</p> <pre><code>function resizedJpg(x) { return x.setFormat('jpg').autoOrient().resize(style.w, style.h, style.option); } function cropped(x) { return x.crop(style.w, style.h, style.crop.x_offset, style.crop.y_offset).repage('+'); } function withQuality(x) { return x.quality(style.quality); } function stripped(x) { return x.strip().interlace('Plane'); } </code></pre> <p>And then apply them separately:</p> <pre><code>({ original: [resizedJpg], large: [resizedJpg, withQuality, stripped], medium: [resizedJpg, cropped, stripped], small: [resizedJpg, cropped, withQuality, stripped] }[style.name]).reduce(function(x, trans) { return trans(x); }, gm(response.Body)).toBuffer(next); </code></pre>