Thursday 2 February 2017

Requiring only specific method from a module have some benefits?

I have seen some people requiring only specific method in a module instead of the full module. EG:const {readFile} = require('fs') const {equal} = require('assert') readFile('./myFile', (err, data) => { if (err) throw err; equal(10,data) }); Does this have any benefit or it's only personal preference?

Submitted February 02, 2017 at 10:46AM by muccapazza

No comments:

Post a Comment