njs_promise_create_resolving_functions(njs_vm_t *vm, njs_promise_t *promise,
    njs_value_t *dst)
{
    unsigned               i;
    njs_function_t         *function;
    njs_promise_context_t  *context, *resolve_context;

    i = 0;

    /* Some compilers give at error an uninitialized context if using for. */
    do {
        function = njs_promise_create_function(vm,
                                               sizeof(njs_promise_context_t));
        if (njs_slow_path(function == NULL)) {
            return NJS_ERROR;
        }

        function->args_count = 1;

        context = function->context;
        context->resolved_ref = &context->resolved;

        njs_set_promise(&context->promise, promise);
        njs_set_function(&dst[i], function);

    } while (++i < 2);

    njs_function(&dst[0])->u.native = njs_promise_resolve_function;
    njs_function(&dst[1])->u.native = njs_promise_reject_function;

    resolve_context = njs_function(&dst[0])->context;
    resolve_context->resolved_ref = &context->resolved;

    return NJS_OK;
}
njs_promise_create_resolving_functions(njs_vm_t *vm, njs_promise_t *promise,
    njs_value_t *dst)
{
    unsigned               i;
    njs_function_t         *function;
    njs_promise_context_t  *context, *resolve_context;

    i = 0;

     
    do {
        function = njs_promise_create_function(vm,
                                               sizeof(njs_promise_context_t));
        if (njs_slow_path(function == NULL)) {
            return NJS_ERROR;
        }

        function->args_count = 1;

        context = function->context;
        context->resolved_ref = &context->resolved;

        njs_set_promise(&context->promise, promise);
        njs_set_function(&dst[i], function);

    } while (++i < 2);

    njs_function(&dst[0])->u.native = njs_promise_resolve_function;
    njs_function(&dst[1])->u.native = njs_promise_reject_function;

    resolve_context = njs_function(&dst[0])->context;
    resolve_context->resolved_ref = &context->resolved;

    return NJS_OK;
}