diff options
| author | ruki <waruqi@gmail.com> | 2018-11-08 00:43:05 +0800 |
|---|---|---|
| committer | ruki <waruqi@gmail.com> | 2018-11-07 22:18:30 +0800 |
| commit | 89e95b3f143682ed9a006991bacf45c9dcba4818 (patch) | |
| tree | 4f44cf41b828577d583890bdd5a1c31e8491a6ba /node_modules/when/keys.js | |
| parent | aa7f0199255277949790b41c56e8ec97dd4f0da4 (diff) | |
| download | xmake-docs-vuepress.tar.gz xmake-docs-vuepress.zip | |
remove node_modulesvuepress
Diffstat (limited to 'node_modules/when/keys.js')
| -rw-r--r-- | node_modules/when/keys.js | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/node_modules/when/keys.js b/node_modules/when/keys.js deleted file mode 100644 index 9bca6040..00000000 --- a/node_modules/when/keys.js +++ /dev/null @@ -1,80 +0,0 @@ -/** @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<keys.length; ++i) { - k = keys[i]; - Promise._handler(object[k]).fold(settleKey, k, results, resolver); - } - - if(pending === 0) { - resolver.resolve(results); - } - - return p; - - function settleKey(k, x, resolver) { - /*jshint validthis:true*/ - this[k] = x; - if(--pending === 0) { - resolver.resolve(results); - } - } - } - - /** - * Map values in the supplied object's keys - * @param {Promise|object} object or promise for object whose key-value pairs - * will be reduced - * @param {function(value:*, key:String):*} f mapping function which may - * return either a promise or a value - * @returns {Promise} promise for an object with the mapped and fully - * resolved key-value pairs - */ - function map(object, f) { - return toPromise(object).then(function(object) { - return all(Object.keys(object).reduce(function(o, k) { - o[k] = toPromise(object[k]).fold(mapWithKey, k); - return o; - }, {})); - }); - - function mapWithKey(k, x) { - return f(x, k); - } - } - -}); -})(typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); }); |
