docs: function getRequire(theRequire, theExports, opts) {
  	var didWrap // did wrap initApi
  	requireState = {}
  	if (!opts) opts = {}
  
  	// obtain replacement require
  	if (typeof theRequire != 'function') throw Error(arguments.callee.name + ' invoked with require argument not function, type: ' + typeof theRequire)
  	var result = apirequire.getApiRequire(state, theRequire)
  	result.dirname = __dirname // absolute path can distinguish between multiple instances
  
  	// find possible api name
  	var apiName = typeof opts.api === 'string' && opts.api
  
  	// get emitter
  	if (opts.emScope instanceof events.EventEmitter && apiName) {
  		result.emitter = opts.emScope
  		result.emitter.id = apiName
  	} else {
  		var emitterId = typeof opts.emScope === 'string' && opts.emScope || apiName
  		if (emitterId) {
  			result.emitter = new events.EventEmitter
  			result.emitter.id = emitterId
  		}
  	}
  	apperror.addErrorListener(result.emitter)
  
  	// wrap initApi
  	if (opts.initApi) {
  		if  (typeof opts.initApi != 'function') throw Error(arguments.callee.name + ' invoked with opts.initApi not function')
  		if (!theExports) throw Error(arguments.callee.name + ' invoked with exports null')
  		if  (!apiName) throw Error(arguments.callee.name + ' invoked with opts.initApi but no api name')
  		theExports.initApi = initapiwrapper.getWrapper(opts.initApi, state, requireState)
  		didWrap = true
  		if (typeof opts.apiState == 'function') theExports.apiState = opts.apiState
  		theExports = null
  	}
  
  	// if api, add it to apiList and monitor ready
  	if (apiName) { // to get here, there must be an emitter
  		if (!didWrap) throw new Error('InitApi missing for api: ' + apiName)
  		var api = apilist.addApi(result.emitter, opts)
  		if (typeof api === 'string') throw new Error(api)
  		else requireState.apiObject = api
  	}
  
  	// get possible rqs
  	var rqScope = opts.rqScope === true ? apiName : typeof opts.rqScope === 'string' && opts.rqScope
  	if (rqScope) {
  		var errorCallback = typeof opts.cb == 'function' ? opts.cb : function () {}
  		var timeoutMs = opts.timeoutMs != null ? opts.timeoutMs : undefined
  		// getRqs may throw
  		result.rqs = rqsm.getRqs(errorCallback, rqScope, timeoutMs)
  	}
  
  	return result
  }