Sha256: 5b0e4856c529610bb37dd59242f4a84ad941c6ad54fc3bf460d61bd1714f46f8
Contents?: true
Size: 916 Bytes
Versions: 28
Compression:
Stored size: 916 Bytes
Contents
// 'use strict'; const fs = require('fs'); function readFile(filepath , options ) { options = options || {}; const throwNotFound = options.throwNotFound || false; return new Promise((resolve, reject) => { fs.readFile(filepath, 'utf8', (err, content) => { if (err && err.code === 'ENOENT' && !throwNotFound) { return resolve(null); } if (err) return reject(err); resolve(content); }); }); } readFile.sync = function readFileSync( filepath , options ) { options = options || {}; const throwNotFound = options.throwNotFound || false; try { return fs.readFileSync(filepath, 'utf8'); } catch (err) { if (err.code === 'ENOENT' && !throwNotFound) { return null; } throw err; } }; module.exports = readFile;
Version data entries
28 entries across 27 versions & 9 rubygems