ServerJS/Binary/C: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 1: Line 1:
:''See also: the [[/Show of hands/]] and [[/Essay/]] portion.''
:''See also: the [[/Show of hands/]] as well as the [[/Unpacking/]] and [[/Essay/]] portions which were removed.''
This proposal was written by Daniel Friesen as an alternative to the [[ServerJS/Binary/B|Binary/B]] proposal.
This proposal was written by Daniel Friesen as an alternative to the [[ServerJS/Binary/B|Binary/B]] proposal.


Line 127: Line 127:
:This method is optional, it should be included if the interpreter being used supports .toSource() on it's various objects and types.
:This method is optional, it should be included if the interpreter being used supports .toSource() on it's various objects and types.
:Returns a representation of the blob in the format "(Blob([]))" or "(new Blob([]))". If the blob has content in it the string should contain integers 0..255 representing the blob such that if evaluated (calling the correct Blob function) would return a blob with the same content.
:Returns a representation of the blob in the format "(Blob([]))" or "(new Blob([]))". If the blob has content in it the string should contain integers 0..255 representing the blob such that if evaluated (calling the correct Blob function) would return a blob with the same content.
=== Unpacking ===
::''These methods are related to unpacking. They will likely be removed from this proposal but are here for reference until we write a proposal for unpacking of binary data.''
;blob.integerAt(offset, size=1, signed=false, networkEndian=false);
:Extracts an integer out of a blob. Arguments may control the byte size extracted whether the number is signed or unsigned, and whether or not the byte is in networkEndian or not. The default is to return a single unsigned byte in the form of an integer in the range 0..255.
;blob.floatAt(offset, size);
:Extracts a float out of a blob. This method requires a size argument of either 4 (floats) or 8 (doubles) to extract a number and should generate a TypeError if passed invalid params.
;blob.stringAt(offset, size, fromCharset=UTF-16);
:Extracts a string out from a blob. This method is similar to if you had done <code>blob.slice(offset, size).toString(fromCharset||"UTF-16");</code>.


=== Buffer ===
=== Buffer ===
40

edits