@@ -202,20 +202,20 @@ so it can be used with the [`using`][] declaration. Disposing the returned
202202object closes the library handle.
203203
204204``` mjs
205- import { dlopen } from ' node:ffi' ;
205+ import { dlopen , suffix } from ' node:ffi' ;
206206
207207{
208- using handle = dlopen (' ./mylib.so ' , {
208+ using handle = dlopen (` ./mylib.${ suffix } ` , {
209209 add_i32: { arguments: [' i32' , ' i32' ], return: ' i32' },
210210 });
211211 console .log (handle .functions .add_i32 (20 , 22 ));
212212} // handle.lib.close() is invoked automatically here.
213213```
214214
215215``` mjs
216- import { dlopen } from ' node:ffi' ;
216+ import { dlopen , suffix } from ' node:ffi' ;
217217
218- const { lib , functions } = dlopen (' ./mylib.so ' , {
218+ const { lib , functions } = dlopen (` ./mylib.${ suffix } ` , {
219219 add_i32: { arguments: [' i32' , ' i32' ], return: ' i32' },
220220 string_length: { arguments: [' pointer' ], return: ' u64' },
221221});
@@ -224,9 +224,9 @@ console.log(functions.add_i32(20, 22));
224224```
225225
226226``` cjs
227- const { dlopen } = require (' node:ffi' );
227+ const { dlopen , suffix } = require (' node:ffi' );
228228
229- const { lib , functions } = dlopen (' ./mylib.so ' , {
229+ const { lib , functions } = dlopen (` ./mylib.${ suffix } ` , {
230230 add_i32: { arguments: [' i32' , ' i32' ], return: ' i32' },
231231 string_length: { arguments: [' pointer' ], return: ' u64' },
232232});
@@ -278,9 +278,9 @@ Loads the dynamic library without resolving any functions eagerly.
278278On Windows passing ` null ` is not supported.
279279
280280``` cjs
281- const { DynamicLibrary } = require (' node:ffi' );
281+ const { DynamicLibrary , suffix } = require (' node:ffi' );
282282
283- const lib = new DynamicLibrary (' ./mylib.so ' );
283+ const lib = new DynamicLibrary (` ./mylib.${ suffix } ` );
284284```
285285
286286### ` library.path `
@@ -310,10 +310,10 @@ library instance can be managed with the [`using`][] declaration. Leaving the
310310enclosing scope invokes ` library.close() ` automatically.
311311
312312``` mjs
313- import { DynamicLibrary } from ' node:ffi' ;
313+ import { DynamicLibrary , suffix } from ' node:ffi' ;
314314
315315{
316- using lib = new DynamicLibrary (' ./mylib.so ' );
316+ using lib = new DynamicLibrary (` ./mylib.${ suffix } ` );
317317 // Use `lib` here; `lib.close()` is called when the block exits.
318318}
319319```
@@ -365,9 +365,9 @@ If the same symbol has already been resolved, requesting it again with a
365365different signature throws.
366366
367367``` cjs
368- const { DynamicLibrary } = require (' node:ffi' );
368+ const { DynamicLibrary , suffix } = require (' node:ffi' );
369369
370- const lib = new DynamicLibrary (' ./mylib.so ' );
370+ const lib = new DynamicLibrary (` ./mylib.${ suffix } ` );
371371const add = lib .getFunction (' add_i32' , {
372372 arguments: [' i32' , ' i32' ],
373373 return: ' i32' ,
@@ -415,9 +415,9 @@ The return value is the callback pointer address as a `bigint`. It can be
415415passed to native functions expecting a callback pointer.
416416
417417``` cjs
418- const { DynamicLibrary } = require (' node:ffi' );
418+ const { DynamicLibrary , suffix } = require (' node:ffi' );
419419
420- const lib = new DynamicLibrary (' ./mylib.so ' );
420+ const lib = new DynamicLibrary (` ./mylib.${ suffix } ` );
421421
422422const callback = lib .registerCallback (
423423 { arguments: [' i32' ], return: ' i32' },
0 commit comments