/** @license MIT License (c) copyright 2011-2013 original author or authors */ /** * Licensed under the MIT License at: * http://www.opensource.org/licenses/mit-license.php * * @author Brian Cavalier * @author John Hann */ (function(define) { 'use strict'; define(function(require) { var when = require('./when'); var Promise = when.Promise; var toPromise = when.resolve; return { all: when.lift(all), map: map }; /** * Resolve all the key-value pairs in the supplied object or promise * for an object. * @param {Promise|object} object or promise for object whose key-value pairs * will be resolved * @returns {Promise} promise for an object with the fully resolved key-value pairs */ function all(object) { var p = Promise._defer(); var resolver = Promise._handler(p); var results = {}; var keys = Object.keys(object); var pending = keys.length; for(var i=0, k; i