diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-11-19 17:42:09 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2020-03-21 12:57:26 +0300 |
commit | 7dead8440c7ee28131cf496daa7c286eecfd90c7 (patch) | |
tree | 758c1cc77e25be86847fc136442c07a3e506e768 /src/node_native_module.cc | |
parent | c44edec4daff9f478eb9b5820d03da6c71253787 (diff) |
src: add LoadEnvironment() variant taking a string
Allow passing a string as the main module rather than using
the callback variant.
PR-URL: https://github.com/nodejs/node/pull/30467
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Diffstat (limited to 'src/node_native_module.cc')
-rw-r--r-- | src/node_native_module.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/node_native_module.cc b/src/node_native_module.cc index 1b916d645d8..c3a77198090 100644 --- a/src/node_native_module.cc +++ b/src/node_native_module.cc @@ -33,6 +33,14 @@ bool NativeModuleLoader::Exists(const char* id) { return source_.find(id) != source_.end(); } +bool NativeModuleLoader::Add(const char* id, const UnionBytes& source) { + if (Exists(id)) { + return false; + } + source_.emplace(id, source); + return true; +} + Local<Object> NativeModuleLoader::GetSourceObject(Local<Context> context) { Isolate* isolate = context->GetIsolate(); Local<Object> out = Object::New(isolate); |