Node modules

module.exports.foo = function () {
    // export a function `foo`
}

// Check if it's called as a script or imported as a module
if (require.main === module) {
    console.log("It's called as a script")
}