Return value after 500ms using promises.

@param  {Any} value
@return {Promise}
@api private
500293
function async(value, bool) {
   var def = promise()
   setTimeout(function() {
 	   if(!bool) def.fulfill(value)
     else def.reject('error')
   }, 10)
   return def.promise
 }
702484
function wrap(value, callback) {
  return Promise.resolve(value).then(
    obj => {
      if (callback) {
        callback(null, obj);
      }
      return obj;
    },
    err => {
      if (callback) {
        callback(err);
      }
      throw err;
    }
  );
}
145435
function(value) {
      var args = [].slice.call(arguments, 1);
      if (typeof value === 'function') {
        value = value.apply(null, args);
      }
      return value;
    }
211834
async def request(self, value: Any) -> Any:
        
        await self.send(value)
        return await self.recv()
1181510
function(value) {
        return {
          value: value,
          then: function(fn) {
            this.value = fn(this.value);
            return this;
          },
          end: function() {
            return this.value;
          }
        };
      }
1335411
function when (val, fn) {
  if (isPromise(val)) {
    return val.then(fn);
  } else {
    return fn(val);
  }
}
408952
function wait() {
  var ms = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;

  return new Promise(function (res) {
    return setTimeout(res, ms);
  });
}
659362
function(value) {
        switch (values.typeOf(value)) {
            case 'Null':
            case 'Boolean':
            case 'String':
            case 'Number':
                return value;

            case 'RegExp':
                return String(value);

            case 'Date':
            case 'Duration':
                return value.valueOf();

            case 'Filter':
                return value.source;

            case 'Array':
                return _.map(value, this.toJSONCompatible, this);

            case 'Object':
                return _.mapObject(value, this.toJSONCompatible, this);
        }
    }
512291
function doSomethingUninteresting(data) {
  // simulate latency
  var wait = randomWait(1000);
  return Promise.delay(wait).then(
    () => `It took me ${wait} milliseconds to notice you gave me ${data}.`
  );
}
1252598
def resolve(self, value):
        """"""
        if self is value:
            raise TypeError('Cannot resolve promise with itself.')

        if isinstance(value, Promise):
            value.done(self.resolve, self.reject)
            return

        if self._state != 'pending':
            raise RuntimeError('Promise is no longer pending.')

        self.value = value
        self._state = 'resolved'
        callbacks = self._callbacks
        self._callbacks = None
        for callback in callbacks:
            callback(value)
1084147
function ( obj, arg, state ) {
		if ( obj.state > promise.state.PENDING ) {
			return;
		}

		obj.value = arg;
		obj.state = state;

		if ( !obj.deferred ) {
			promise.delay( function () {
				obj.process();
			});

			obj.deferred = true;
		}

		return obj;
	}
1038556
def timeout(self, value):
        '''
        
        '''
        if not self.params:
            self.params = dict(timeout=value)
            return self
        self.params['timeout'] = value
        return self
289828
function ( value ) {
		var tmp;

		if ( value === null || value === undefined ) {
			return undefined;
		}
		else if ( value === "true" ) {
			return true;
		}
		else if ( value === "false" ) {
			return false;
		}
		else if ( value === "null" ) {
			return null;
		}
		else if ( value === "undefined" ) {
			return undefined;
		}
		else if ( value === "" ) {
			return value;
		}
		else if ( !isNaN( tmp = Number( value ) ) ) {
			return tmp;
		}
		else if ( regex.json_wrap.test( value ) ) {
			return json.decode( value, true ) || value;
		}
		else {
			return value;
		}
	}
158794
function waitUntil(fun) {
    var timeout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
    var interval = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 20;

    var timedOut = false;
    var ok = false;

    if (timeout !== 0) (0, _wait2['default'])(timeout).then(function () {
        return timedOut = true;
    });

    return new Promise(function (resolve, reject) {
        var runLoop = function runLoop() {
            if (ok) {
                resolve();
                return;
            }
            if (timedOut) {
                reject(new Error('AsyncTestUtil.waitUntil(): reached timeout of ' + timeout + 'ms'));
                return;
            }
            (0, _wait2['default'])(interval).then(function () {
                var value = (0, _promisify2['default'])(fun());
                value.then(function (val) {
                    ok = val;
                    runLoop();
                });
            });
        };
        runLoop();
    });
}
1080787
function(cb, next, method) {
        return function(value) {
            if (typeof cb !== 'function')                            /*  [Promises/A+ 2.2.1, 2.2.7.3, 2.2.7.4]  */
                next[method].call(next, value);                      /*  [Promises/A+ 2.2.7.3, 2.2.7.4]  */
            else {
                var result;
                try {
                    if (value instanceof Promise) {
                        result = value.then(cb);
                    }
                    else result = cb(value);
                }                          /*  [Promises/A+ 2.2.2.1, 2.2.3.1, 2.2.5, 3.2]  */
                catch (e) {
                    next.reject(e);                                  /*  [Promises/A+ 2.2.7.2]  */
                    return;
                }
                resolve(next, result);                               /*  [Promises/A+ 2.2.7.1]  */
            }
        };
    }
456521
async function onetime() {
    if (called) return value;

    called = 1;
    value = await fn.apply(this, arguments);
    fn = null;

    return value;
  }
72557
function fulfillPromise(promise, value) {
  if (promise.state !== PENDING) {return;}

  setValue(promise, value);
  setState(promise, UNFULFILLED);

  setImmediate(function() {
    setState(promise, FULFILLED);
    invokeFunctions(promise);
  });
}