I found this in the index.js
of a module I used recently:
(function() {
module.exports = require('./lib/somelib');
}).call(this);
These were the entire contents of the file. somelib
had the definitions that were actually being exported. What would be the purpose of this and how is this different from simply having:
module.exports = require('./lib/somelib');
I understand what an IIFE is for (typically for creating a closure with a reference to a "hidden" scoped variable. I'm having trouble seeing any benefit to this above pattern however.
Can anyone enlighten me?