node-ctypes - v2.10.0
    Preparing search index...

    Type Alias CallbackRestype

    CallbackRestype:
        | SimpleCDataConstructor
        | PointerTypeDef
        | FuncPtrFactory
        | number
        | null

    Create a callback that can be passed to native functions.

    The callback runs on the main thread. For thread-safe callbacks, use threadSafeCallback.

    Important: Call .release() when the callback is no longer needed.

    Python equivalent: ctypes.CFUNCTYPE(...)(func)

    JavaScript function to wrap

    Return type of the callback

    Argument types

    A wrapper with a .pointer property and .release() method

    import { callback, c_int32, c_void_p, readValue } from 'node-ctypes';

    const compare = callback(
    (a, b) => readValue(a, c_int32) - readValue(b, c_int32),
    c_int32, [c_void_p, c_void_p]
    );
    // Pass compare.pointer to qsort, etc.
    compare.release();