njs_promise_reject_function(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
    njs_index_t unused)
{
    njs_value_t            *value;
    njs_native_frame_t     *active_frame;
    njs_promise_context_t  *context;

    active_frame = vm->top_frame;
    context = active_frame->function->context;

    if (*context->resolved_ref) {
        njs_vm_retval_set(vm, &njs_value_undefined);
        return NJS_OK;
    }

    *context->resolved_ref = 1;

    value = njs_promise_reject(vm, njs_promise(&context->promise),
                               njs_arg(args, nargs, 1));
    if (njs_slow_path(value->type == NJS_NULL)) {
        return NJS_ERROR;
    }

    njs_vm_retval_set(vm, value);

    return NJS_OK;
}
njs_promise_reject_function(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
    njs_index_t unused)
{
    njs_value_t            *value;
    njs_native_frame_t     *active_frame;
    njs_promise_context_t  *context;

    active_frame = vm->top_frame;
    context = active_frame->function->context;

    if (*context->resolved_ref) {
        njs_vm_retval_set(vm, &njs_value_undefined);
        return NJS_OK;
    }

    *context->resolved_ref = 1;

    value = njs_promise_reject(vm, njs_promise(&context->promise),
                               njs_arg(args, nargs, 1));
    if (njs_slow_path(value->type == NJS_NULL)) {
        return NJS_ERROR;
    }

    njs_vm_retval_set(vm, value);

    return NJS_OK;
}