Thursday 21 April 2016

Trouble with bson-ext's native function calling

Hey guys,So basically, I didn't want to install the entire VS Package from Microsoft (I did try the Microsoft Dev Tools, but they didn't work with node-gyp).So I purchased a basic 2.99 vps (which might be relevant, but I doubt it). [I'm pretty sure my code is at fault]I am using http://ift.tt/1WJ8HfY as a native binding.Everything has worked well so far, I installed GCC, make and ran node-gyp configure and node-gyp build. I am now including the file in my node app like so:var bson = require('./bson/build/Release/bson.node'); var object = bson.BSON.prototype; console.log(object.serialize('hey')) The problem is, I am getting this error: console.log(object.serialize({test: "turkey"})) ^ TypeError: Illegal invocation Which is weird because when I do console.log(object)I get:BSON { calculateObjectSize: [Function: calculateObjectSize], serialize: [Function: serialize], serializeWithBufferAndIndex: [Function: serializeWithBufferAndIndex], deserialize: [Function: deserialize], deserializeStream: [Function: deserializeStream] } Which these are the native functions from C++ that were built to bson.node. So it does look like the bindings were compiled correctly, I am just not sure how to call them now. I posted on bson-ext's issue tracker but it seems like there are no examples or documentation on how to use this binding. And my lack of knowledge with the prototype chain, I'm obviously missing something here :(. I've been stuck on this for the past several hours or so and was just going to say fuck it. But, I really want to see where I am going wrong here so I don't mess up in the future.Edit: When I do:var bson = require('./bson/build/Release/bson'); console.log(bson) -- I receive:{ BSON: [Function: BSON] }If that helps.. If you need me to run anything on the console, let me know!

Submitted April 22, 2016 at 03:51AM by BillOReillyYUPokeMe

No comments:

Post a Comment