Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
require
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Angelo Chen  
View profile  
 More options Nov 15 2012, 7:17 am
From: Angelo Chen <angelochen...@gmail.com>
Date: Thu, 15 Nov 2012 04:17:32 -0800 (PST)
Local: Thurs, Nov 15 2012 7:17 am
Subject: require

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Вадим Барышев  
View profile   Translate to Translated (View Original)
 More options Nov 15 2012, 7:21 am
From: Вадим Барышев <vadimbarys...@gmail.com>
Date: Thu, 15 Nov 2012 04:21:05 -0800 (PST)
Local: Thurs, Nov 15 2012 7:21 am
Subject: Re: require

This is node.js function. You can start
here https://github.com/joyent/node/blob/master/lib/module.js#L361

четверг, 15 ноября 2012 г., 16:17:32 UTC+4 пользователь Angelo Chen написал:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Angelo Chen  
View profile  
 More options Nov 15 2012, 9:21 am
From: Angelo Chen <angelochen...@gmail.com>
Date: Thu, 15 Nov 2012 06:20:45 -0800 (PST)
Local: Thurs, Nov 15 2012 9:20 am
Subject: Re: require
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);

};

?

On Nov 15, 8:21 pm, Вадим Барышев <vadimbarys...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Вадим Барышев  
View profile  
 More options Nov 15 2012, 9:39 am
From: Вадим Барышев <vadimbarys...@gmail.com>
Date: Thu, 15 Nov 2012 06:39:33 -0800 (PST)
Local: Thurs, Nov 15 2012 9:39 am
Subject: Re: require

NativeModule defined
here https://github.com/joyent/node/blob/master/src/node.js#L676

It just returns itself if module id is
'native_module' https://github.com/joyent/node/blob/master/src/node.js#L687

Module._load defined
here https://github.com/joyent/node/blob/master/lib/module.js#L275

четверг, 15 ноября 2012 г., 18:21:09 UTC+4 пользователь Angelo Chen написал:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Cooper  
View profile  
 More options Nov 15 2012, 11:28 am
From: Martin Cooper <mfncoo...@gmail.com>
Date: Thu, 15 Nov 2012 08:28:37 -0800
Local: Thurs, Nov 15 2012 11:28 am
Subject: Re: [nodejs] Re: require

On Thu, Nov 15, 2012 at 6:20 AM, Angelo Chen <angelochen...@gmail.com>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, Вадим Барышев <vadimbarys...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »