Skip to content

Instantly share code, notes, and snippets.

@cmstead
Last active April 5, 2018 19:06
Show Gist options
  • Save cmstead/4db01275adfefa8ee082d5305c10c972 to your computer and use it in GitHub Desktop.
Save cmstead/4db01275adfefa8ee082d5305c10c972 to your computer and use it in GitHub Desktop.
Updated Factory Function Setup
function fileReader(fs, logger) {
function readAFile(filepath) {
try {
return fs.readFileSync(filePath, { encoding: 'utf8' });
} catch (e) {
logger.log(e.message);
return null;
}
}
return {
readAFile: readAFile
};
}
module.exports = fileReader;
'use strict';
let singletonLogger = null;
function logger(loggerFactory) {
return singletonLogger === null ? loggerFactory.create() : singletonLogger;
}
module.exports = logger;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment