Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var deferred = {};
var keys = require('when/keys');
if (data.picture) {
deferred.picture = webservices.image(data['picture']);
}
if (data.screen) {
deferred.screen = webservices.image(data['screen']);
}
if (Array.isArray(data.screens)) {
deferred.screens = when.map(data.screens, webservices.image);
} else if(typeof data.screens === 'object') {
deferred.screens = keys.map(data.screens, function(array) {
return when.map(array, webservices.image);
});
}
keys.all(deferred).then(
function(deferred) {
console.log(deferred.picture);
console.log(deferred.screen);
console.log(deferred.screens);
}
);
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.