File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ function load(path, option = {}){
3434 const options = {
3535 ignoreLoadingFail : asBoolean ( option . ignoreLoadingFail ) ?? false ,
3636 ignoreMissingSymbol : asBoolean ( option . ignoreMissingSymbol ) ?? false ,
37+ lazy : asBoolean ( option . lazy ) ?? false ,
3738 abi : conventions . includes ( option . abi ) ? option . abi : "default_abi"
3839 } ;
3940
@@ -45,7 +46,7 @@ function load(path, option = {}){
4546 if ( path . indexOf ( ext ) === - 1 ) path += ext ;
4647 const [ dylib , err ] = attempt ( ffi . DynamicLibrary , [
4748 path ,
48- ffi . DynamicLibrary . FLAGS . RTLD_NOW ,
49+ options . lazy ? ffi . DynamicLibrary . FLAGS . RTLD_LAZY : ffi . DynamicLibrary . FLAGS . RTLD_NOW ,
4950 ffi [ "FFI_" + options . abi . toUpperCase ( ) ]
5051 ] ) ;
5152
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ function load(path, option = {}){
3131 const options = {
3232 ignoreLoadingFail : asBoolean ( option . ignoreLoadingFail ) ?? false ,
3333 ignoreMissingSymbol : asBoolean ( option . ignoreMissingSymbol ) ?? false ,
34+ lazy : asBoolean ( option . lazy ) ?? false ,
3435 abi : conventions . includes ( option . abi ) ? option . abi : "func"
3536 } ;
3637
@@ -40,7 +41,7 @@ function load(path, option = {}){
4041 } [ platform ] ?? ".so" ;
4142
4243 if ( path . indexOf ( ext ) === - 1 ) path += ext ;
43- const [ dylib , err ] = attemptify ( koffi . load ) ( path , { lazy : false } ) ;
44+ const [ dylib , err ] = attemptify ( koffi . load ) ( path , { lazy : options . lazy } ) ;
4445
4546 if ( err && ! options . ignoreLoadingFail ) {
4647 throw new Failure ( err . message , {
You can’t perform that action at this time.
0 commit comments