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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Exposing Internal Utils (Javascript)

  • 23-02-2017 2:44pm
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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