Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BROWSER vs NODE differences #63

Open
oskrs111 opened this issue Jul 13, 2017 · 3 comments
Open

BROWSER vs NODE differences #63

oskrs111 opened this issue Jul 13, 2017 · 3 comments

Comments

@oskrs111
Copy link

oskrs111 commented Jul 13, 2017

Hi,
I'm trying to port a working app from electron (node based) to cordova. This app makes intesive usage of jBinary and works really fine on electron.

What i found is that BROWSER version does not generate the same jBinary::view type as when using NODE version. For the the same code;

var writeBuffer = new Buffer(2048);
var writeFrame = new jBinary(writeBuffer, bdFrameStruct);

NODE version ->
var jBinary = require('jbinary'); is generating view as 'jDataView'

writeFrame
jBinary {view: jDataView, contexts: Array[0], typeSet: Object, cacheKey: "jBinary.Cache.1"}

BROWSER version ->
<script type="text/javascript" src="js/jdataview.js"></script>
<script type="text/javascript" src="js/jbinary.js"></script> is generating view as 'e'

writeFrame
h {view: e, contexts: Array[0], typeSet: Object, cacheKey: "jBinary.Cache.1"}

How do can I get the same result as in NODE using BROWSER?
Or maybe there is a better way to use it on cordova?

Thanks.

@RReverser
Copy link
Member

It should be still jDataView, just the name is minified. Do you have any difference in actual behaviour?

@oskrs111
Copy link
Author

oskrs111 commented Jul 13, 2017

Yes, that's the problem. NODE version works perfectly but when switching to BROWSER does not. Note that when I say BROWSER I am still using electron only switching to js file version instead node module, It is supposed to work the same Isn't it?

Here is what i have found going deeper into JBinary Object. Same piece of code, expanding 'view'

var writeBuffer = new Buffer(2048);
var writeFrame = new jBinary(writeBuffer, bdFrameStruct);

NODE VERSION -->

writeFrame.view
jDataView {buffer: Buffer[2048], _isArrayBuffer: false, _isPixelData: false, _isDataView: false, _isNodeBuffer: true…}

Note-> buffer: Buffer[2048]
Note-> _isNodeBuffer:true

BROWSER VERSION ->

writeFrame.view
e {buffer: ArrayBuffer,_isArrayBuffer: true, _isPixelData: false, _isDataView: true, _isNodeBuffer: false…}

Note-> buffer: ArrayBuffer
Note-> _isArrayBuffer: true
Note-> _isDataView: true

Any idea? Why does 'buffer' type is also different?

@RReverser
Copy link
Member

Well buffer being different is expected, it's an internal platform-specific representation which you shouldn't use anyway in most cases. That's because jDataView chooses the best buffer type depending on what's supported in the current engine.

But, as you can see, it's still jDataView in both cases, so all the public APIs should still work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants