src/require.js
function _loadModuleText(target, source, sync=false) {
  const time = process.hrtime();
  const loadEventEvent = new emitter.Load({target, source, sync});
  const loadEvent = emitter.emit('load', loadEventEvent);

  const loaded = txtBuffer=>{
    try {
      const loadedEvent = emitter.emit('loaded', new emitter.Loaded({
        target,
        otherTarget: loadEventEvent.data.target,
        duration: process.hrtime(time),
        size: txtBuffer.byteLength,
        source,
        sync,
        data: txtBuffer
      }));
      return sync?txtBuffer:loadedEvent.then(()=>txtBuffer,loadError);
    } catch (error) {
      return loadError(error);
    }
  };

  const loadError = error=>{
    const _error = new emitter.Error({target, source, error});
    emitter.emit('error', _error);
    if (!_error.ignore || (_error.ignore && isFunction(_error.ignore) && !_error.ignore())) throw error;
  };

  if (!sync) return loadEvent.then(()=>readFile(loadEventEvent.data.target || target, fileCache).then(loaded, loadError), loadError);
  try {
    return loaded(readFileSync(loadEventEvent.data.target || target, fileCache));
  } catch(error) {
    loadError(error);
  }
}
function _loadModuleText(target, source, sync=false) {
  const time = process.hrtime();
  const loadEventEvent = new emitter.Load({target, source, sync});
  const loadEvent = emitter.emit('load', loadEventEvent);

  const loaded = txtBuffer=>{
    try {
      const loadedEvent = emitter.emit('loaded', new emitter.Loaded({
        target,
        otherTarget: loadEventEvent.data.target,
        duration: process.hrtime(time),
        size: txtBuffer.byteLength,
        source,
        sync,
        data: txtBuffer
      }));
      return sync?txtBuffer:loadedEvent.then(()=>txtBuffer,loadError);
    } catch (error) {
      return loadError(error);
    }
  };

  const loadError = error=>{
    const _error = new emitter.Error({target, source, error});
    emitter.emit('error', _error);
    if (!_error.ignore || (_error.ignore && isFunction(_error.ignore) && !_error.ignore())) throw error;
  };

  if (!sync) return loadEvent.then(()=>readFile(loadEventEvent.data.target || target, fileCache).then(loaded, loadError), loadError);
  try {
    return loaded(readFileSync(loadEventEvent.data.target || target, fileCache));
  } catch(error) {
    loadError(error);
  }
}
function _loadModuleText ( target , source , sync = false ) { const time = process . hrtime ( ) ; const loadEventEvent = new emitter . Load ( { target , source , sync } ) ; const loadEvent = emitter . emit ( 'load' , loadEventEvent ) ; const loaded = txtBuffer => { try { const loadedEvent = emitter . emit ( 'loaded' , new emitter . Loaded ( { target , otherTarget : loadEventEvent . data . target , duration : process . hrtime ( time ) , size : txtBuffer . byteLength , source , sync , data : txtBuffer } ) ) ; return sync ? txtBuffer : loadedEvent . then ( ( ) => txtBuffer , loadError ) ; } catch ( error ) { return loadError ( error ) ; } } ; const loadError = error => { const _error = new emitter . Error ( { target , source , error } ) ; emitter . emit ( 'error' , _error ) ; if ( ! _error . ignore || ( _error . ignore && isFunction ( _error . ignore ) && ! _error . ignore ( ) ) ) throw error ; } ; if ( ! sync ) return loadEvent . then ( ( ) => readFile ( loadEventEvent . data . target || target , fileCache ) . then ( loaded , loadError ) , loadError ) ; try { return loaded ( readFileSync ( loadEventEvent . data . target || target , fileCache ) ) ; } catch ( error ) { loadError ( error ) ; } }
Read text from a file and handle any errors.

@private
@param {string} target               The target to load.
@param {string} source               The loading source path.
@param {boolean} [sync=false]        Use sync method?
@returns {Promise.<string>|string}   The results.
Read text from a file and handle any errors .