diff options
author | James M Snell <jasnell@gmail.com> | 2016-05-02 20:27:12 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2016-05-17 21:05:18 +0300 |
commit | dcccbfdc799d174901c29d82874457367231fec5 (patch) | |
tree | bb1a45d053b169af0b1662000d57e034e4422996 /src/node_constants.cc | |
parent | f856234ffaa10441545c3b6ce420b247a17c06cf (diff) |
src: refactor require('constants')
The require('constants') module is currently undocumented and mashes
together unrelated constants. This refactors the require('constants')
in favor of distinct os.constants, fs.constants, and crypto.constants
that are specific to the modules for which they are relevant. The
next step is to document those within the specific modules.
PR-URL: https://github.com/nodejs/node/pull/6534
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Robert Lindstaedt <robert.lindstaedt@gmail.com>
Diffstat (limited to 'src/node_constants.cc')
-rw-r--r-- | src/node_constants.cc | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/node_constants.cc b/src/node_constants.cc index 928502f6aff..2e6be8df37c 100644 --- a/src/node_constants.cc +++ b/src/node_constants.cc @@ -1,4 +1,6 @@ #include "node_constants.h" +#include "env.h" +#include "env-inl.h" #include "uv.h" @@ -1140,14 +1142,26 @@ void DefineCryptoConstants(Local<Object> target) { #endif } -void DefineConstants(Local<Object> target) { - DefineErrnoConstants(target); - DefineWindowsErrorConstants(target); - DefineSignalConstants(target); - DefineOpenSSLConstants(target); - DefineSystemConstants(target); - DefineUVConstants(target); - DefineCryptoConstants(target); +void DefineConstants(v8::Isolate* isolate, Local<Object> target) { + Local<Object> os_constants = Object::New(isolate); + Local<Object> err_constants = Object::New(isolate); + Local<Object> sig_constants = Object::New(isolate); + Local<Object> fs_constants = Object::New(isolate); + Local<Object> crypto_constants = Object::New(isolate); + + DefineErrnoConstants(err_constants); + DefineWindowsErrorConstants(err_constants); + DefineSignalConstants(sig_constants); + DefineUVConstants(os_constants); + DefineSystemConstants(fs_constants); + DefineOpenSSLConstants(crypto_constants); + DefineCryptoConstants(crypto_constants); + + os_constants->Set(OneByteString(isolate, "errno"), err_constants); + os_constants->Set(OneByteString(isolate, "signals"), sig_constants); + target->Set(OneByteString(isolate, "os"), os_constants); + target->Set(OneByteString(isolate, "fs"), fs_constants); + target->Set(OneByteString(isolate, "crypto"), crypto_constants); } } // namespace node |