ServerJS/Binary/B: Difference between revisions

Jump to navigation Jump to search
move join the ByteString constructor, remove toString(charset)
(export Binary too!)
(move join the ByteString constructor, remove toString(charset))
Line 33: Line 33:
; ByteString(string, charset)
; ByteString(string, charset)
: Convert a string. The ByteString will contain string encoded with charset.
: Convert a string. The ByteString will contain string encoded with charset.
=== Constructor methods ===
; <u>join(array, delimiter)</u>
: Like Array.prototype.join, but for Binarys. Returns a ByteString.


=== Instance properties ===
=== Instance properties ===
Line 54: Line 59:
: Returns an array containing the decoded Unicode code points.
: Returns an array containing the decoded Unicode code points.
; toString()
; toString()
: Returns a debug representation like "[ByteString 10]", where 10 is the length of the Array.
: Returns a debug representation like "[ByteString 10]", where 10 is the length of the Array. Alternative debug representations are valid too, as long as (1) this method will never fail, (2) the length is included.
; decodeToString(charset)
; decodeToString(charset)
: Returns the decoded ByteArray as a string.
: Returns the decoded ByteArray as a string.
Line 129: Line 134:
: an array of the code points, decoded
: an array of the code points, decoded
; toString()
; toString()
: a string representation like "[ByteArray 10]"
: A string debug representation like "[ByteArray 10]". Alternative debug representations are valid too, as long as (1) this method will never fail, (2) the length is included.
; <u>toString(charset)</u>
: <u>an alias for decodeToString(charset)</u>
; decodeToString()
; decodeToString()
; decodeToString(charset)
; decodeToString(charset)
Line 145: Line 148:
; <u>byteAt(offset)</u>
; <u>byteAt(offset)</u>
; concat(other:ByteArray|ByteString|Array)
; concat(other:ByteArray|ByteString|Array)
; <strike>join(delimiter:ByteArray|ByteString|Array)</strike>
: <u>deemed unnecessary and semantically unclear</u>
; pop() -> byte:Number
; pop() -> byte:Number
; push(...variadic Numbers...)-> count:Number
; push(...variadic Numbers...)-> count:Number
Line 179: Line 180:
; toByteString(charset)
; toByteString(charset)
: Converts an array of Unicode code points to a ByteString encoded in charset.
: Converts an array of Unicode code points to a ByteString encoded in charset.
; <u>join(delimiter)</u>
: <u>Overridden to distinguish its behavior on whether the delimiter is a ByteString, ByteArray, or String.  Defaults to usual behavior for Strings.  Coerces items to ByteString or ByteArray and joins them on the delimiter for delimiters with their respective types.</u>


== General Requirements ==
== General Requirements ==
62

edits

Navigation menu