koffi 2.5.21-beta.3 → 2.5.21-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koffi",
3
- "version": "2.5.21-beta.3",
3
+ "version": "2.5.21-beta.4",
4
4
  "stable": "2.5.20",
5
5
  "description": "Fast and simple C FFI (foreign function interface) for Node.js",
6
6
  "keywords": [
package/src/index.js CHANGED
@@ -378,7 +378,7 @@ var require_package = __commonJS({
378
378
  "build/dist/src/koffi/package.json"(exports2, module2) {
379
379
  module2.exports = {
380
380
  name: "koffi",
381
- version: "2.5.21-beta.3",
381
+ version: "2.5.21-beta.4",
382
382
  stable: "2.5.20",
383
383
  description: "Fast and simple C FFI (foreign function interface) for Node.js",
384
384
  keywords: [
@@ -1644,6 +1644,18 @@ static Napi::Value LoadSharedLibrary(const Napi::CallbackInfo &info)
1644
1644
  ThrowError<Napi::TypeError>(env, "Unexpected %1 value for filename, expected string or null", GetValueType(instance, info[0]));
1645
1645
  return env.Null();
1646
1646
  }
1647
+ if (info.Length() >= 2 && !IsObject(info[1])) {
1648
+ ThrowError<Napi::TypeError>(env, "Unexpected %1 value for options, expected object", GetValueType(instance, info[1]));
1649
+ return env.Null();
1650
+ }
1651
+
1652
+ #ifndef _WIN32
1653
+ bool lazy = false;
1654
+ if (info.Length() >= 2) {
1655
+ Napi::Object options = info[1].As<Napi::Object>();
1656
+ lazy = options.Get("lazy").ToBoolean();
1657
+ }
1658
+ #endif
1647
1659
 
1648
1660
  if (!instance->memories.len) {
1649
1661
  AllocateMemory(instance, instance->config.sync_stack_size, instance->config.sync_heap_size);
@@ -1665,8 +1677,10 @@ static Napi::Value LoadSharedLibrary(const Napi::CallbackInfo &info)
1665
1677
  }
1666
1678
  #else
1667
1679
  if (info[0].IsString()) {
1680
+ int flags = lazy ? RTLD_LAZY : RTLD_NOW;
1681
+
1668
1682
  std::string filename = info[0].As<Napi::String>();
1669
- module = dlopen(filename.c_str(), RTLD_NOW);
1683
+ module = dlopen(filename.c_str(), flags);
1670
1684
 
1671
1685
  if (!module) {
1672
1686
  const char *msg = dlerror();