-
Notifications
You must be signed in to change notification settings - Fork 165
Check whether or not Buffer and Int32Array are present and support buf[index] #23
Conversation
So, it still looks to me that this is an issue with zombie, did you post an issue on zombie? |
I didn't because I'm able to reproduce it with the JSONStream tests just by using buffer-browserify and, although I don't fully understand why I also tested with an |
And yeah it's a weird one to find the right place for a fix because so many things are involved... Ideally @creationix (and everyone else) would be able to avoid using things in I put it here because this is where the thing is created, and you were already checking to see if |
it's just that the way I see it, the browsers are already right, because they are just browsers. Maybe you can make a tiny test case (just pulling enough out of buffer-browserify to reproduce your test assert.strictEqual(new Buffer('X'), 88) And whatever is the minimum from buffer-browserify to get this test failing in zombie, but passing in a browser. |
I'm working on that now, while trying not to pull in the whole universe with the tiny test case. 😉 Do you see what I mean about it not working in browsers if anyone is using browserify and does a Unfortunately when you have things that can only partially emulate other things it all gets a bit messy where those things are used, if you want them to work. 😕 |
just ran into this same problem. this pull req should use int8 arrays and should be on this repo https://github.com/toots/buffer-browserify/ |
actually haha i already fixed this 7 months ago #9 but for some reason it isnt working anymore.... i'm looking into it |
ok the reason it doesnt work is the pull req i made predates buffer-browserify and now doesnt work because the |
Ah cool, thanks @maxogden. I'll admit I was getting a bit out of my depth 😟 Would a fix in buffer-browserify work? The JSONStream code would still be using the [] operator which (as I understand it) can't be implemented on anything that isn't really an array or |
fixing buffer-browserify to use typed arrays seems like the best way forward. |
is this still a problem? |
This is still a problem, yes. It was made worse in browserify 2.6.0, which detects for global Buffer references and includes a Buffer definition as necessary so detecting for the presence of |
That would be great! If buffer-browserify can be made to support |
Hi guys! I'd be very happy to fix this in buffer-browserify and would welcome any patch for that. However, typed array don't seem to be supported in enough browser to be a suitable solution.. |
You can close this issue since Buffer in browserify supports indexing correctly. |
As I mentioned in creationix/jsonparse#10 I've run into a problem with a combination of browserify/zombie where browserify's implementation of
Buffer
can't implement the[]
operator which jsonparse makes use of. I guess the same will happen for other polyfills too.This pull request intends to check that whatever is given to jsonparse supports
[]
, falling back toInt32Array
and thenArray
ifBuffer
is either not available or won't work with jsonparse. The tests now pass using buffer-browserify'sBuffer
where they previously failed.As you can probably tell I'm no JS expert - particularly when it comes to client-side stuff - so am prepared for ridicule/schooling as appropriate 😁