tags:

views:

336

answers:

4

I was looking through Mozilla's JS in JS code and came across the snarf function. It's not defined in the javascript, it seems, just in the C version here. It isn't very well-commented, though. I Google searched this to no avail.

Is this a standard part of JavaScript? (My guess is no.) Is it some kind of extension? What is it supposed to do?

+1  A: 

It loads a file and returns the contents of the file in a string.

Rob Kennedy
+3  A: 

No, it is not standard. It is the part of Mozilla's Narcissus (JS in JS interpreter implemented on top of SpiderMonkey). snarf(filename) grabs the content of the file and returns it as a string for further processing (e.g., evaluation).

Eugene Lazutkin
A: 

i was just reading the code for narcissus and saw snarf, and googled it, and came here! weird!

gene tsai
This is probably more a comment than an answer...
harto
+1  A: 

Snarf is defined here:

http://mxr.mozilla.org/mozilla/source/js/src/js.c#3712

Andrew Moore