You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: promises.go
    path of file: ./repos/k6/js/promises
    
    the code of the file until where you have to start completion: // Package promises provides helpers for working with promises in k6.
package promises

import (
	"github.com/dop251/goja"
	"go.k6.io/k6/js/modules"
)

// New can be used to create promises that will be dispatched to k6's event loop.
//
// Calling the function will create a goja promise and return its `resolve` and `reject` callbacks, wrapped
// in such a way that it will block 
    
func New(vu modules.VU) (p *goja.Promise, resolve func(result any), reject func(reason any)) {
	p, resolveFunc, rejectFunc := vu.Runtime().NewPromise()
	callback := vu.RegisterCallback()

	resolve = func(result any) {
		callback(func() error {
			resolveFunc(result)
			return nil
		})
	}

	reject = func(reason any) {
		callback(func() error {
			rejectFunc(reason)
			return nil
		})
	}

	return p, resolve, reject
}