Global Objects#
These objects are available in all modules. Some of these objects aren't
actually in the global scope but in the module scope - this will be noted.
이 객체들은 모든 모듈에서 이용할 수 있다. 이 객체들 중 일부는 실제로 전역 범위를 가지지
않고 모듈 범위를 가진다. - 이는 따로 표시할 것이다.
global#
{Object} The global namespace object.
In browsers, the top-level scope is the global scope. That means that in
browsers if you're in the global scope var something
will define a global
variable. In Node this is different. The top-level scope is not the global
scope; var something
inside a Node module will be local to that module.
브라우저에서 최상위 범위는 전역 범위이다. 이는 브라우저의 전역 범위에서 var something
가
전역 변수를 정의한다는 것을 의미한다. Node에서는 다르다. 최상위 범위는 전역 범위가 아니다.
Node 모듈에서 var something
는 해당 모듈의 지역 범위가 된다.
process#
process 객체. process object 부분을 봐라.
console#
stdout와 stderr에 출력하는 데 사용한다. console 부분을 봐라.
Class: Buffer#
바이너리 데이터를 다루는데 사용한다. buffer section 을 봐라.
require()#
To require modules. See the Modules section. require
isn't actually a
global but rather local to each module.
모듈을 require한다. Modules 부분을 봐라.
require
는 실제로 전역이 아니라 각 모듈의 지역범위다.
require.resolve()#
Use the internal require()
machinery to look up the location of a module,
but rather than loading the module, just return the resolved filename.
모듈의 위치를 검색하는데 내부 require()
장치(machinery)를 사용한다. 모듈을 로딩하는
것이 아니라 처리된 파일명을 리턴할 뿐이다.
require.cache#
Modules are cached in this object when they are required. By deleting a key
value from this object, the next require
will reload the module.
모듈을 require했을 때 모듈은 이 객체에 캐시된다. 이 객체에서 키 값을 삭제하면 다음 번
require
에서 해당 모듈을 다시 로드할 것이다.
require.extensions#
Stability: 0 - Deprecated
Instruct require
on how to handle certain file extensions.
Process files with the extension .sjs
as .js
:
require.extensions['.sjs'] = require.extensions['.js'];
Deprecated In the past, this list has been used to load
non-JavaScript modules into Node by compiling them on-demand.
However, in practice, there are much better ways to do this, such as
loading modules via some other Node program, or compiling them to
JavaScript ahead of time.
Since the Module system is locked, this feature will probably never go
away. However, it may have subtle bugs and complexities that are best
left untouched.
Stability: 0 - Deprecated
특정 파일 확장자를 어떻게 다룰지를 require
에 지시한다.
.sjs
확장자의 파일을 .js
처럼 처리한다.
require.extensions['.sjs'] = require.extensions['.js'];
Deprecated 과거에 이 항목은 요청에 따라 컴파일해서 Node에 자바스크립트가 아닌 모듈을
로드하는데 사용했다. 하지만 실제로 다른 몇몇 Node 프로그램을 통해서 모듈을 로딩하거나
ahead of time으로 자바스크립트로 컴파일하는 등의 이를 위한 훨씬 더 좋은 방법이 존재한다.
Module 시스템이 locked 상태이므로 이 기능은 없어지지 않을 것이다. 하지만 미묘한 버그나
건드릴 수 없는 복잡성을 가질 수 있다.
__filename#
The filename of the code being executed. This is the resolved absolute path
of this code file. For a main program this is not necessarily the same
filename used in the command line. The value inside a module is the path
to that module file.
Example: running node example.js
from /Users/mjr
console.log(__filename);
// /Users/mjr/example.js
__filename
isn't actually a global but rather local to each module.
실행되는 코드의 파일명이다. 이 코드 파일을 처리한 절대경로이다. 메인 프로그램에서 이는
커맨드라인에서 사용한 것과 반드시 같은 파일명은 아니다. 모듈내부에서 이 값은 해당 모듈 파일에
대한 경로이다.
예제: /Users/mjr
에서 node example.js
를 실행한다.
console.log(__filename);
// /Users/mjr/example.js
__filename
은 실제로 전역이 아니라 각 모듈의 지역범위이다.
__dirname#
The name of the directory that the currently executing script resides in.
Example: running node example.js
from /Users/mjr
console.log(__dirname);
// /Users/mjr
__dirname
isn't actually a global but rather local to each module.
현재 실행되는 스크립트가 존재하는 디렉토리 이름이다.
예제: /Users/mjr
에서 node example.js
를 실행한다.
console.log(__dirname);
// /Users/mjr
__dirname
는 실제로 전역이 아니라 각 모듈의 지역범위이다.
module#
A reference to the current module. In particular
module.exports
is the same as the exports
object.
module
isn't actually a global but rather local to each module.
See the module system documentation for more information.
현재 모듈에 대한 참조이다. 특히 module.exports
는 exports
객체와 같다.
module
는 실제로 전역이 아니라 각 모듈의 지역범위이다.
더 자세한 내용은 module system documentation 를 봐라.
exports#
A reference to the module.exports
object which is shared between all
instances of the current module and made accessible through require()
.
See module system documentation for details on when to use exports
and
when to use module.exports
.
exports
isn't actually a global but rather local to each module.
See the module system documentation for more information.
See the module section for more information.
현재 모듈과 require()
로 접근가능하게 된 모듈의 모든 인스턴스 사이에서 공유되는
module.exports
객체에 대한 참조. 언제 exports
를 사용하고 언제 module.exports
를
사용하는 지에 대한 자세한 내용은 module system documentation 를 참고해라.
exports
는 실제로 전역이 아니라 각 모듈의 지역범위이다.
더 자세한 내용은 module system documentation 를 봐라.
더 자세한 내용은 module section 를 봐라.
setTimeout(cb, ms)#
Run callback cb
after at least ms
milliseconds. The actual delay depends
on external factors like OS timer granularity and system load.
The timeout must be in the range of 1-2,147,483,647 inclusive. If the value is
outside that range, it's changed to 1 millisecond. Broadly speaking, a timer
cannot span more than 24.8 days.
Returns an opaque value that represents the timer.
최소 ms
밀리초 후에 콜백 cb
를 실행한다. 실제 지연시간은 OS 타이머의 크기와 시스템
부하같은 외부 요소에 달려있다.
타임아웃은 1-2,147,483,647의 범위여야 한다. 값이 이 범위 밖이면 타임아웃은 1 밀리초로
바뀐다. 대략적으로 말해서 타이머는 24.8일이상이 될 수 없다.
타이머를 나타내는 불투명한 값을 반환한다.
clearTimeout(t)#
이전에 setTimeout()
로 생성된 타이머를 멈춘다. 콜백은 실행하지 않을 것이다.
setInterval(cb, ms)#
Run callback cb
repeatedly every ms
milliseconds. Note that the actual
interval may vary, depending on external factors like OS timer granularity and
system load. It's never less than ms
but it may be longer.
The interval must be in the range of 1-2,147,483,647 inclusive. If the value is
outside that range, it's changed to 1 millisecond. Broadly speaking, a timer
cannot span more than 24.8 days.
Returns an opaque value that represents the timer.
ms
밀리초마다 반복적으로 콜백 cb
를 실행한다. 실제 간격은 OS 타이머의 크기나 시스템
부하같은 외부 요소에 따라 다양하다. 시간간격은 ms
보다 작을 수 없다.
간격은 1-2,147,483,647의 범위여야 한다. 값이 이 범위 밖이면 1밀리초로 바뀐다. 대력적으로
말해서 타이머는 24.8일 이상이 될 수 없다.
타이머를 나타내는 불투명한 값을 반환한다.
clearInterval(t)#
Stop a timer that was previously created with setInterval()
. The callback
will not execute.
The timer functions are global variables. See the timers section.
이전에 setInterval()
로 생성된 타이머를 멈춘다. 콜백은 실행하지 않을 것이다.
timer 함수는 전역 변수이다. timers 부분을 봐라.