njs_promise_trigger_reactions(njs_vm_t *vm, njs_value_t *value,
    njs_queue_t *queue)
{
    njs_int_t               ret;
    njs_value_t             arguments[2];
    njs_function_t          *function;
    njs_queue_link_t        *link;
    njs_promise_reaction_t  *reaction;

    for (link = njs_queue_first(queue);
         link != njs_queue_tail(queue);
         link = njs_queue_next(link))
    {
        reaction = njs_queue_link_data(link, njs_promise_reaction_t, link);

        function = njs_promise_create_function(vm,
                                               sizeof(njs_promise_context_t));
        function->u.native = njs_promise_reaction_job;

        njs_set_data(&arguments[0], reaction, 0);
        arguments[1] = *value;

        ret = njs_promise_add_event(vm, function, arguments, 2);
        if (njs_slow_path(ret != NJS_OK)) {
            return njs_value_arg(&njs_value_null);
        }
    }

    return njs_value_arg(&njs_value_undefined);
}
njs_promise_trigger_reactions(njs_vm_t *vm, njs_value_t *value,
    njs_queue_t *queue)
{
    njs_int_t               ret;
    njs_value_t             arguments[2];
    njs_function_t          *function;
    njs_queue_link_t        *link;
    njs_promise_reaction_t  *reaction;

    for (link = njs_queue_first(queue);
         link != njs_queue_tail(queue);
         link = njs_queue_next(link))
    {
        reaction = njs_queue_link_data(link, njs_promise_reaction_t, link);

        function = njs_promise_create_function(vm,
                                               sizeof(njs_promise_context_t));
        function->u.native = njs_promise_reaction_job;

        njs_set_data(&arguments[0], reaction, 0);
        arguments[1] = *value;

        ret = njs_promise_add_event(vm, function, arguments, 2);
        if (njs_slow_path(ret != NJS_OK)) {
            return njs_value_arg(&njs_value_null);
        }
    }

    return njs_value_arg(&njs_value_undefined);
}