Last active
April 5, 2018 19:06
-
-
Save cmstead/4db01275adfefa8ee082d5305c10c972 to your computer and use it in GitHub Desktop.
Updated Factory Function Setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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