readFile fs promise wrapped
@param {string} path
@param {string} fileName
110
function readFile(path, fileName) {
  return new Promise((resolve, reject) => {
    fs.readFile(`${path}/${fileName}`, 'utf8', (err, content) => {
      if (err) {
        return reject(err)
      }

      return resolve(content)
    })
  })
}
546807
function writeFile(filename, data) {
    return new Promise(function (fulfill, reject) {
        fs.writeFile(filename, data, function (err, res) {
            return err ? reject(err) : fulfill(res);
        });
    });
}
169044
function readSync( path, options ) {
	var file,
		opts;

	if (
		arguments.length > 1 &&
		!isString( options )
	) {
		opts = options;
	} else {
		opts = {};
	}
	opts.encoding = 'utf8';
	file = readFile.sync( path, opts );
	if ( file instanceof Error ) {
		return file;
	}
	return parse( file, opts );
}
920358
async function readFile(path, encoding) {
	const url = browser.extension.getURL(realpath(path));

	return new Promise((resolve, reject) => {
		const xhr = new global.XMLHttpRequest;
		xhr.responseType = encoding == null ? 'arraybuffer' : 'text';
		xhr.addEventListener('load', () => resolve(xhr.response));
		xhr.addEventListener('error', reject);
		xhr.open('GET', url);
		xhr.send();
	});
}
354097
async function read(path) {
  const rs = createReadStream(path)
  /** @type {string} */
  const res = await collect(rs)
  return res
}
561724
function(path) {
      var code = require('fs').readFileSync(path);
      var context = vm.createContext(initContext);
      context.flow = _conn.flow;
      vm.runInContext(code, context);
      for (var key in context) {
        if (!initContext[key]) {
          global[key] = context[key];
        }
      }
    }
229701
function readFileStats(filePath) {
  return new Promise((resolve, reject) => {
    fs.stat(filePath, (err, fstat) => {
      if (err) {
        reject(err);
        return;
      }
      resolve(fstat);
    });
  });
}
751854
async function readJSON(path) {
    const file = await read(path)
    const parsed = JSON.parse(file)
    return parsed
}
1254020
function readDirectoryFiles(directory) {
  return new Promise((resolve, reject) => {
    fs.readdir(directory, (err, files) => {
      if (err) {
        reject(err);
        return;
      }

      const isFile = fileName => readFileStats(path.join(directory, fileName))
        .then((fstat) => {
          if (fstat.isFile()) {
            return fileName;
          }
          return null;
        });

      Promise.all(files.map(isFile))
        .then(fileList => resolve(fileList.filter(f => f !== null)))
        .catch(reject);
    });
  });
}
40288
function(file, type) {
    var promise = new Parse.Promise();

    if (typeof(FileReader) === "undefined") {
      return Parse.Promise.error(new Parse.Error(
          Parse.Error.FILE_READ_ERROR,
          "Attempted to use a FileReader on an unsupported browser."));
    }

    var reader = new FileReader();
    reader.onloadend = function() {
      if (reader.readyState !== 2) {
        promise.reject(new Parse.Error(
            Parse.Error.FILE_READ_ERROR,
            "Error reading file."));
        return;
      }

      var dataURL = reader.result;
      var matches = /^data:([^;]*);base64,(.*)$/.exec(dataURL);
      if (!matches) {
        promise.reject(new Parse.Error(
            Parse.ERROR.FILE_READ_ERROR,
            "Unable to interpret data URL: " + dataURL));
        return;
      }

      promise.resolve(matches[2], type || matches[1]);
    };
    reader.readAsDataURL(file);
    return promise;
  }
585023
function open (path, delimiter = '\r\n') {

  const self = this;
  const flags = 'r+';

  return new Promise((resolve, reject) => {
    // Open file for reading and writing. An exception occurs if the file does not exist.
    fs.open(path, flags, (error, fd) => {
      if (error) {
        reject(error);
        return;
      }

      try {
        let promise = self.term(path, delimiter, fd);
        resolve(promise);
      } catch (termError) {
        reject(termError);
      }
    });
  });
}
787151
function promiseWriteFile(targetPath, content, tabs = 2) {
  const fileName = targetPath.split('/').pop();
  let contentHolder = content;

  if (targetPath.endsWith('.json')) {
    contentHolder = JSON.stringify(contentHolder, null, tabs);
  }

  return new Promise((resolve, reject) => {
    fs.writeFile(targetPath, contentHolder, err => {
      if (err) reject(err);

      resolve({
        path: targetPath,
        fileName,
        content: contentHolder
      });
    });
  });
}
630138
function openFile(filename) {
  return new Promise((resolve, reject) => {
    opener(filename, null, err => err === null ? resolve(filename) : reject(err));
  });
}
1060858
async function createDirectory(sftp, path) {
  return new Promise((resolve, reject) => {
    sftp.mkdir(path, error => (error ? reject(error) : resolve()));
  });
}
712085
function readFile(filename, enc) {
    return new Promise(function (fulfill, reject) {
        fs.readFile(filename, enc || 'utf8', function (err, res) {
            return err ? reject(err) : fulfill(res);
        });
    });
}
1076968
function(file) {
        var self = this;

        return new Promise(function(resolve) {
            fs.readFileAsync(file, 'utf-8')
                .then(function(content) {
                    return self._parseFile(file, content);
                })
                .then(function(ast) {
                    return self._getConfig(file, ast);
                })
                .then(function(config) {
                    self._modules = self._modules.concat(config);

                    resolve(config);
                });
        });
    }
1267266
function processItem(path) {
            var deferred = new $.Deferred(),
                fileEntry = FileSystem.getDirectoryForPath(path);

            fileEntry.exists(function (err, exists) {
                if (!err && exists) {
                    deferred.resolve();
                } else {
                    deferred.reject();
                }
            });

            return deferred.promise();
        }