Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Exposing Internal Utils (Javascript)

Options
  • 23-02-2017 3:44pm
    #1
    Registered Users Posts: 1,298 ✭✭✭


    What do people think is a good way to do this, say i'm writing a project and want a single utils file that can contain some auth methods, helper methods etc etc, do you think using a node set up it would be better to do require('../../../../utils'); or perhaps expose it on the window object?


Comments

  • Registered Users Posts: 403 ✭✭counterpointaud


    Any reason not to make it a module and declare it as a dependency?

    EDIT: BTW there is no window object in node, or is this supposed to run in the browser?


  • Registered Users Posts: 1,298 ✭✭✭off.the.walls


    Any reason not to make it a module and declare it as a dependency?

    EDIT: BTW there is no window object in node, or is this supposed to run in the browser?

    Apologies, this is where my confusion lay, I know in terms of libraries such as jQuery they expose their functionality on the window. This is where I was hitting a wall with this!


  • Registered Users Posts: 403 ✭✭counterpointaud


    Try and avoid putting things in global scope if you can help it. We have evolved a lot since the JQuery days, there are many options for modularization in Javascript.


Advertisement