Modifies the result of each promise from a scalar value to a object containing its fieldname
576
function wrap(fieldName, promise, args) {
  return promise(args).then((result) => ({
    [fieldName]: result,
  }));
}
295703
function Q(value) {
    // If the object is already a Promise, return it directly.  This enables
    // the resolve function to both be used to created references from objects,
    // but to tolerably coerce non-promises to promises.
    if (value instanceof Promise) {
        return value;
    }

    // assimilate thenables
    if (isPromiseAlike(value)) {
        return coerce(value);
    } else {
        return fulfill(value);
    }
}
313550
def execute_fields_serially(
        self,
        parent_type: GraphQLObjectType,
        source_value: Any,
        path: Optional[ResponsePath],
        fields: Dict[str, List[FieldNode]],
    ) -> AwaitableOrValue[Dict[str, Any]]:
        
        results: Dict[str, Any] = {}
        for response_name, field_nodes in fields.items():
            field_path = add_path(path, response_name)
            result = self.resolve_field(
                parent_type, source_value, field_nodes, field_path
            )
            if result is INVALID:
                continue
            if isawaitable(results):
                # noinspection PyShadowingNames
                async def await_and_set_result(results, response_name, result):
                    awaited_results = await results
                    awaited_results[response_name] = (
                        await result if isawaitable(result) else result
                    )
                    return awaited_results

                # noinspection PyTypeChecker
                results = await_and_set_result(
                    cast(Awaitable, results), response_name, result
                )
            elif isawaitable(result):
                # noinspection PyShadowingNames
                async def set_result(results, response_name, result):
                    results[response_name] = await result
                    return results

                # noinspection PyTypeChecker
                results = set_result(results, response_name, result)
            else:
                results[response_name] = result
        if isawaitable(results):
            # noinspection PyShadowingNames
            async def get_results():
                return await cast(Awaitable, results)

            return get_results()
        return results
467294
function mapValues (obj, fn) {
  return Object.keys(obj).reduce(function (subresult, key) {
    subresult[key] = fn(obj[key], key)
    return subresult
  }, {})
}
659126
function promisify_object(template, object_creator) {
    object_creator = object_creator || new_object;
    var transformer = function (obj_promise) {
        var res = object_creator(obj_promise);
        for (var prop in template) {
            res[prop] = template[prop].for_property(obj_promise, prop);
        }
        return res;
    };

    transformer.for_property = function (parent_promise, prop) {
        return transformer(when(parent_promise, function (obj) {
            return obj[prop];
        }));
    };

    return transformer;
}
1227632
def transform_specialfield(jsonify,f,v):
  ""
  raw = f.ser(v) if is_serdes(f) else v
  return ujson.dumps(raw) if not isinstance(f,basestring) and jsonify else raw
1021220
def _scalar_property(fieldname):
    

    def _getter(self):
        """Scalar property getter."""
        return self._properties.get(fieldname)

    def _setter(self, value):
        """Scalar property setter."""
        self._patch_property(fieldname, value)

    return property(_getter, _setter)
511088
function serial(promises) {
    const results = [];

    return promises
        .reduce((chain, promise) =>
            chain.then(result => {
                results.push(result);
                return promise
            }), Promise.resolve())
        .then(result => {
            results.push(result);
            results.shift();
            return results;
        })
}
276394
function GenerateDefaultValues(neode, model, properties) {
    const output = GenerateDefaultValuesAsync(neode, model, properties);

    return Promise.resolve(output);
}
979040
def complete_object_value(
        self,
        return_type: GraphQLObjectType,
        field_nodes: List[FieldNode],
        info: GraphQLResolveInfo,
        path: ResponsePath,
        result: Any,
    ) -> AwaitableOrValue[Dict[str, Any]]:
        """"""
        # If there is an `is_type_of()` predicate function, call it with the current
        # result. If `is_type_of()` returns False, then raise an error rather than
        #  continuing execution.
        if return_type.is_type_of:
            is_type_of = return_type.is_type_of(result, info)

            if isawaitable(is_type_of):

                async def collect_and_execute_subfields_async():
                    if not await is_type_of:
                        raise invalid_return_type_error(
                            return_type, result, field_nodes
                        )
                    return self.collect_and_execute_subfields(
                        return_type, field_nodes, path, result
                    )

                return collect_and_execute_subfields_async()

            if not is_type_of:
                raise invalid_return_type_error(return_type, result, field_nodes)

        return self.collect_and_execute_subfields(
            return_type, field_nodes, path, result
        )
434282
function( obj ) {
					if ( obj == null ) {
						obj = promise;
					} else {
						for ( var key in promise ) {
							obj[ key ] = promise[ key ];
						}
					}
					return obj;
				}
1022605
function(data) {
    return Promise.each(normalizer(data), function(datum) {
      return Promise.retry(function() {
        return compose.pull(datum.compose, datum.project, datum.opts);
      });
    })
    .then(function() {
      return Promise.each(normalizer(data), function(datum) {
        return Promise.retry(function() {
          return compose.build(datum.compose, datum.project, datum.opts);
        });
      });
    });
  }
1178197
function(object, resultFn) {
				var keys = Object.keys(object);
				if (keys.length === 0) {
					resultFn(object);
				} else {
					var resultCount = 0;
					keys.forEach(function(current) {
						(function(key) {
							(function(value, fn) {
								if (value && value.getPluginRepresentation) {
									value.getPluginRepresentation().then(function(newValue) {
										fn(newValue);
									});
								} else {
									fn(value);
								}
							}(object[key], function(newValue) {
								object[key] = newValue;
								if (++resultCount === keys.length) {
									resultFn(object);
								}
							}));
						}(current));
					});
				}
			}
640420
function promisify_value(result_transformer) {
    result_transformer = result_transformer || identity;

    var transformer = function (promise) {
        result_transformer(promise);
    };

    transformer.for_property = function (obj_promise, prop) {
        return when(obj_promise, function (obj) {
            result_transformer(obj[prop]);
        });
    };

    return transformer;
}
1005178
private static String joinSetAndGetValue(List<Field> fields,
			List<Object> values, Object obj, boolean withNull) {
		StringBuilder sb = new StringBuilder();
		int fieldSize = fields.size();
		for(int i = 0; i < fieldSize; i++) {
			Column column = fields.get(i).getAnnotation(Column.class);
			Object value = DOInfoReader.getValue(fields.get(i), obj);
			if(column.casVersion()) {
				if(value == null) {
					throw new CasVersionNotMatchException("casVersion column value is null");
				}
				Long _v = null;
				if(value instanceof Long) {
					_v = (Long) value;
				} else if (value instanceof Integer) {
					_v = ((Integer) value).longValue();
				} else {
					throw new CasVersionNotMatchException("casVersion column type must be Integer or Long");
				}
				sb.append(getColumnName(column)).append("=").append(_v + 1).append(",");
			} else {
				if(value != null && column.isJSON()) {
					value = JSON.toJson(value);
				}
				if(withNull || value != null) {
					sb.append(getColumnName(column)).append("=?,");
					values.add(value);
				}
			}
		}
		return sb.length() == 0 ? "" : sb.substring(0, sb.length() - 1);
	}
216007
function saveKeyValues(view, docIdsToChangesAndEmits, seq) {
  var seqDocId = '_local/lastSeq';
  return view.db.get(seqDocId)
  .catch(defaultsTo({_id: seqDocId, seq: 0}))
  .then(function (lastSeqDoc) {
    var docIds = Object.keys(docIdsToChangesAndEmits);
    return Promise.all(docIds.map(function (docId) {
      return getDocsToPersist(docId, view, docIdsToChangesAndEmits);
    })).then(function (listOfDocsToPersist) {
      var docsToPersist = flatten(listOfDocsToPersist);
      lastSeqDoc.seq = seq;
      docsToPersist.push(lastSeqDoc);
      // write all docs in a single operation, update the seq once
      return view.db.bulkDocs({docs : docsToPersist});
    });
  });
}
323901
function handlePromise(query, q, model, resultsPerPage) {
  return Promise.all([
    query.exec(),
    model.count(q).exec()
  ]).spread(function(results, count) {
    return [
      results,
      Math.ceil(count / resultsPerPage) || 1,
      count
    ]
  });
}