Skip to content

Commit 2b557c4

Browse files
committed
Namespace trimming: remove node.constants
1 parent 89d891f commit 2b557c4

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

src/file.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ node.fs.cat = function (path, encoding, callback) {
1212
callback(-1);
1313
};
1414

15-
var content = (encoding == node.constants.UTF8 ? "" : []);
15+
var content = (encoding == node.UTF8 ? "" : []);
1616
var pos = 0;
1717
var chunkSize = 16*1024;
1818

@@ -41,9 +41,9 @@ node.fs.File = function (options) {
4141
options = options || {};
4242

4343
if (options.encoding === "utf8") {
44-
self.encoding = node.constants.UTF8;
44+
self.encoding = node.UTF8;
4545
} else {
46-
self.encoding = node.constants.RAW;
46+
self.encoding = node.RAW;
4747
}
4848

4949
//node.debug("encoding: opts=" + options.encoding + " self=" + self.encoding);
@@ -104,22 +104,22 @@ node.fs.File = function (options) {
104104
var flags;
105105
switch (mode) {
106106
case "r":
107-
flags = node.constants.O_RDONLY;
107+
flags = node.O_RDONLY;
108108
break;
109109
case "r+":
110-
flags = node.constants.O_RDWR;
110+
flags = node.O_RDWR;
111111
break;
112112
case "w":
113-
flags = node.constants.O_CREAT | node.constants.O_TRUNC | node.constants.O_WRONLY;
113+
flags = node.O_CREAT | node.O_TRUNC | node.O_WRONLY;
114114
break;
115115
case "w+":
116-
flags = node.constants.O_CREAT | node.constants.O_TRUNC | node.constants.O_RDWR;
116+
flags = node.O_CREAT | node.O_TRUNC | node.O_RDWR;
117117
break;
118118
case "a":
119-
flags = node.constants.O_APPEND | node.constants.O_CREAT | node.constants.O_WRONLY;
119+
flags = node.O_APPEND | node.O_CREAT | node.O_WRONLY;
120120
break;
121121
case "a+":
122-
flags = node.constants.O_APPEND | node.constants.O_CREAT | node.constants.O_RDWR;
122+
flags = node.O_APPEND | node.O_CREAT | node.O_RDWR;
123123
break;
124124
default:
125125
throw "Unknown mode";
@@ -173,9 +173,9 @@ node.fs.File = function (options) {
173173
};
174174
};
175175

176-
stdout = new node.fs.File({ fd: node.constants.STDOUT_FILENO });
177-
stderr = new node.fs.File({ fd: node.constants.STDERR_FILENO });
178-
stdin = new node.fs.File({ fd: node.constants.STDIN_FILENO });
176+
stdout = new node.fs.File({ fd: node.STDOUT_FILENO });
177+
stderr = new node.fs.File({ fd: node.STDERR_FILENO });
178+
stdin = new node.fs.File({ fd: node.STDIN_FILENO });
179179

180180
puts = stdout.puts;
181181
print = stdout.print;

src/node.cc

+1-3
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,7 @@ Load (int argc, char *argv[])
303303

304304
Timer::Initialize(node_obj);
305305

306-
Local<Object> constants = Object::New();
307-
node_obj->Set(String::NewSymbol("constants"), constants);
308-
DefineConstants(constants);
306+
DefineConstants(node_obj);
309307

310308
Local<Object> fs = Object::New();
311309
node_obj->Set(String::NewSymbol("fs"), fs);

website/api.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ <h3 id="file_wrappers">POSIX Wrappers</h3>
206206
<a href="http://opengroup.org/onlinepubs/007908799/xsh/open.html">open(2)</a>
207207
<p>
208208
The constants like <code>O_CREAT</code> are defined at
209-
<code>node.constants.O_CREAT</code>.
209+
<code>node.O_CREAT</code>.
210210
</p>
211211
</dd>
212212

@@ -243,8 +243,8 @@ <h3 id="file_wrappers">POSIX Wrappers</h3>
243243
</p>
244244

245245
<p>
246-
<code>encoding</code> is either <code>node.constants.UTF8</code>
247-
or <code>node.constants.RAW</code>.
246+
<code>encoding</code> is either <code>node.UTF8</code>
247+
or <code>node.RAW</code>.
248248
</p>
249249
</dd>
250250
</dl>

0 commit comments

Comments
 (0)