npm.io
1.0.6 • Published 7 years ago

@inithink/node-pointer

Licence
ISC
Version
1.0.6
Deps
0
Size
93 kB
Vulns
0
Weekly
0
Install scriptsThis package runs scripts during installation (preinstall/install/postinstall)

node-pointer

Access C++ pointer from node.js code

##Example

readAddress

const assert = require('assert');
const {readAddress} = require('@inithink/node-pointer');
// By using ref-napi, we can get memory address of a Buffer instance
require('ref-napi');

const buf = Buffer.alloc(4);
buf.writeUInt64LE(0x11223344, 0);

let buffer = readAddress(buf.address(), 4);
assert.strictEqual(0x11223344, buffer.readUInt32LE(0));