Skip to content

Instantly share code, notes, and snippets.

@ahgood
Created April 20, 2016 02:29
Show Gist options
  • Save ahgood/1d112596255fad71409e85bc21acdcdf to your computer and use it in GitHub Desktop.
Save ahgood/1d112596255fad71409e85bc21acdcdf to your computer and use it in GitHub Desktop.
//m.js
var fs = require('fs');
module.exports = function(filename, callback) {
fs.readFile(filename, 'utf8', function(err, data){
if (err) throw err;
callback(data);
});
}
//u.js
var getContent = require('./m');
getContent('h.txt', function(data) {
console.log(data);
});
//h.txt
Hello Nodejs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment