1

I came across a situation today where I needed a single Javascript file to be accessible through HTTP. The actual program was running with NodeJS and was outside of the /home/ directory.

The reason I was trying to access the javascript file was it has a list of functions that I use often, and wanted to utilize them with PhantomJS (essentially injecting it into a different website).

I was able to get it to work by moving the entire node into an accessible folder and having htaccess deny access to everything except 1 file, but I am curious if anyone would know:

Would it be possible to take an entire object (functions and preset values) and output them as a string (same as if you navigated to a file.js page). This way I could create an HTTP page, send the proper headers and essentially create an accessible JS page.

I looked around but couldn't find any information on actually outputting a object verbatim.

Corey
  • 725
  • 1
  • 10
  • 19

1 Answers1

0

Check this answer from user Houshalter to the question Converting an object to a string.

All answers provide different examples how to convert object without function to string. But he explains how to do that with object which contains also functions.

Community
  • 1
  • 1
Anto Jurković
  • 10,842
  • 2
  • 24
  • 41