Skip to content

Instantly share code, notes, and snippets.

@gandalfar gandalfar/code.js
Last active Jan 14, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.