Nodejs Module Export

Machine generated alternative text:
DATA 
Name 
package.json 
temp 
onenote-to-html 
work 
scripts 
modules 
getContentOfFile 
Size 
213

Text in image:Machine generated alternative text: DATA Name package.json temp onenote-to-html work scripts modules getContentOfFile Size 213

 

Package.json:

{

  "name""getContentOfFile",

  "version""1.0.0",

  "description""",

  "main""index.js",

  "scripts": {

    "test""echo \"Error: no test specified\" && exit 1"

  },

  "author""",

  "license""ISC"

}

 

Index.js:

const fs = require('file-system');

 

const getContentOfFile = pathToFile => {

  return fs.readFileSync(pathToFile'utf-8', (errdata=> {

    if (errthrow err;

    return data;

  })

};

module.exports = getContentOfFile;

 

Module-exports-object_

 

And that is how we use our module:

D: temp > onenote-to-html > work > scripts JS file_splitterjs > 
5 
10 
const, require( 'file- system' • 
const- cheerio- require( 'cheerio' ); 
const getContentOfFile = require( ./modu1es/getContentOfFi1e 
const- masterFi1eC(N1tent = ./ . ./Notes/Zette1Kasten l.htm 
const, S — cheerio. 
$( el) — 
- cc_hlsole. log(el); 
D;

Text in image:D: temp > onenote-to-html > work > scripts JS file_splitterjs > 5 10 const, require( 'file- system' • const- cheerio- require( 'cheerio' ); const getContentOfFile = require( ./modu1es/getContentOfFi1e const- masterFi1eC(N1tent = ./ . ./Notes/Zette1Kasten l.htm const, S — cheerio. $( el) — - cc_hlsole. log(el); D;

 


All Articles