Conversation
| if (libfile && libfile.indexOf(EXT) === -1) { | ||
| debug('appending library extension to library name', EXT) | ||
| libfile += EXT | ||
| if (!(dl instanceof DynamicLibrary)) { |
There was a problem hiding this comment.
Let's do if ('string' === typeof dl || null === dl) instead. I'm paranoid about instanceof and try to avoid it when possible.
There was a problem hiding this comment.
any particular reason? instanceof is logically correct, no?
There was a problem hiding this comment.
IMO instanceof is an anti-pattern in dynamically typed languages like JavaScript. Consider a DynamicLibrary instance from another "env" (i.e. another copy of node-ffi in the node_modules structure), or another module that implements the DynamicLibrary interface but using a different backend (perhaps libuv's dl functions). Basically the "if it looks like a duck, and quacks like a duck" benefits of dynamic langs are lost with instanceof.
|
I'm 👍 for this, but needs a test case or two before merging. |
|
I have another use case for this. That is closing the This is a significant issue for me right now because I'm dropping DLLs into temporary directories but I can never clean up "the mess" because Windows won't let me remove DLLs if they are in use by any process. Any news on merging this? |
Extend Library API to support DynamicLibrary as first parameter. This might be useful for manual
dlopenflags setting and nonstandard lib names.Address #137