On Thu, Nov 15, 2012 at 6:20 AM, Angelo Chen <[email protected]>wrote:
> Hi,
>
> Thanks for the direction, but I found it at beg of module.js, it has a
> line:
> var NativeModule = require('native_module');
> is the require here refers to:
>
> Module.prototype.require = function(path) {
> return Module._load(path, this);
> };
> ?
>
I'm afraid you're going to have to keep reading. :-) You'll discover that
ultimately 'require' is a function that is unique for each module, and is
passed in to the wrapper that executes the module. See:
https://github.com/joyent/node/blob/master/lib/module.js#L377
https://github.com/joyent/node/blob/master/src/node.js#L726
https://github.com/joyent/node/blob/master/lib/module.js#L453
NativeModule.require() is used to get at those modules that are baked into
Node itself; a regular 'require' is used for everything else.
--
Martin Cooper
On Nov 15, 8:21 pm, Вадим Барышев <[email protected]> wrote:
> > This is node.js function. You can start
> > herehttps://github.com/joyent/node/blob/master/lib/module.js#L361
> >
> > четверг, 15 ноября 2012 г., 16:17:32 UTC+4 пользователь Angelo Chen
> написал:
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > > Hi,
> >
> > > var fs = require('fs');
> > > I'd like to understand this a little more, require is part of v8 JS? or
> > > nodejs function? if yes, where can I find it in Nodejs's source code?
> > > thanks,
> >
> > > Angelo
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en