Last active
January 14, 2017 20:40
-
-
Save jurecuhalev/4bff9938ac543e3af6659054f1882b39 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string = new Promise(function(resolve) { | |
// original code was just: | |
// resolve(ctx.processString(contents, relativePath)); | |
// | |
// I want to emulate that and also invalidate cache in catch() | |
try { | |
resolve(ctx.processString(contents, relativePath)); | |
} catch(e) { | |
return cache.remove(key).then(function(){ | |
throw e; | |
}); | |
} | |
}).then(function(result) { | |
if (typeof result === 'string') { | |
return { output: result }; | |
} else { | |
return result; | |
} | |
}).then(function(value) { | |
var stringValue = JSON.stringify(value); | |
return cache.set(key, stringValue).then(function() { | |
return value; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment