Open jimmywarting opened 2 years ago
before you jump onto the conclusion of why -0
should be supported:
Code can do different things depending on if it's signed or not.
Math.atan2(0, 0); //returns 0
Math.atan2(0, -0); //returns Pi
the reason why we have +0
and -0
is mostly due to being able to represent positive and negative ∞ in a mathematically way
1/-0 === -Infinity
1/0 === Infinity
This is really cool, nice work! Yes, I will take a look to see if there are some improvements that can be made, when I get a chance, although no guarantees, since there may be some limitations from data formats. Again, this is a great analysis and set of tests!
I added the mapsAsObjects: true
and then it passed more tests...
I update my post to include a list of what i think should be supported. That way you can create sub issues and use this a meta ticket if you like.
I think Object literals could just be as simple as just prefixing the next following value... You don't need a seperate Tags for each String/Boolean/Number/BigInt etc?
var isObjectLiteral = buffer[x]
if (isObjectLiteral) {
return Object( read_next_value_as_normal() )
}
I just publish this test page today to test out different binary package
Maybe this is something you wish to improve on? (you can also click on each ❌ to see more details - and see the result in the console for more detail)
A summary of what i think should be supported
-0
structuredClone(BigInt('0x' + 'FF'.repeat(1024)))
Object(2n)
ArrayBuffer
and return it as anArrayBuffer
(not as an Uint8Array with an offset)var input = {}; input.input = input
,var input = [0]; input[0] = input
I don't know about Blob/Files. I think it would be better to just encode a references point to some blob index rather than trying encode a hole file into memory. So first you would encode the structure, emit all the data and then transfer/pipe the blobs over the wire later in your own way. kind of how the web has a transferable list when using postMessage