ServerJS/Binary/B: Difference between revisions

→‎Specification: add some results from the discussion
(→‎Relevant Discussions: add new discussion)
(→‎Specification: add some results from the discussion)
Line 36: Line 36:
=== Constructor methods ===
=== Constructor methods ===


; <u>join(array, delimiter)</u>
; join(array, delimiter)
: Like Array.prototype.join, but for Binarys. Returns a ByteString.
: Like Array.prototype.join, but for Binarys. Returns a ByteString.


Line 71: Line 71:
: Returns the index of the last occurance of byte (a Number or a single element ByteString or ByteArray) or -1 if none was found. If start and/or stop are specified, only elements between the the indexes start and stop are searched.
: Returns the index of the last occurance of byte (a Number or a single element ByteString or ByteArray) or -1 if none was found. If start and/or stop are specified, only elements between the the indexes start and stop are searched.
; charCodeAt(offset)
; charCodeAt(offset)
; <u>get(offset)</u>
: Return the byte at offset as a Number.
: Return the byte at offset as a Number.
; byteAt(offset) ByteString
; byteAt(offset) ByteString
Line 76: Line 77:
: Return the byte at offset as a ByteString.
: Return the byte at offset as a ByteString.
; split(delimiter, [options])
; split(delimiter, [options])
: Split at delimiter, which can by a Number, a ByteString, a ByteArray or an Array of the prior (containing multiple delimiters).
: Split at delimiter, which can by a Number, a ByteString, a ByteArray or an Array of the prior (containing multiple delimiters, i.e., "split at any of these delimiters"). Delimiters can have arbitrary size.
: Options is an optional object parameter with the following optional properties:
: Options is an optional object parameter with the following optional properties:
* ''count'' - Maximum number of elements to return. The last returned element may contain delimiters.
* ''count'' - Maximum number of elements (ignoring delimiters) to return. The last returned element may contain delimiters.
* ''includeDelimiter'' - Whether the delimiter should be included in the result.
* ''includeDelimiter'' - Whether the delimiter should be included in the result.
: Returns an array of ByteStrings.
: Returns an array of ByteStrings.
Line 151: Line 152:
: transcoded
: transcoded
; <u>byteAt(offset) ByteString</u>
; <u>byteAt(offset) ByteString</u>
; <u>charAt(offset) ByteString</u>
: Return the byte at offset as a ByteString.
:
; <u>get(offset) Number</u>
: Return the byte at offset as a Number.
; concat(other:ByteArray|ByteString|Array)
; concat(other:ByteArray|ByteString|Array)
; pop() byte:Number
; pop() byte:Number
:
:
; push(...variadic Numbers...) count:Number
; push(...variadic Numbers...) -> count(Number)
:
:
; <u>extendRight(...variadic Numbers / Arrays / ByteArrays / ByteStrings ...)</u>
:
; shift() byte:Number
; shift() byte:Number
:
:
; unshift(...variadic Numbers...) count:Number
; unshift(...variadic Numbers...) count:Number
:
:
; <u>extendLeft(...variadic Numbers / Arrays / ByteArrays / ByteStrings ...)</u>
:
; reverse() in place reversal
; reverse() in place reversal
:
:
Line 170: Line 176:
; splice()
; splice()
:
:
; <u>indexOf()</u>
:
; <u>lastIndexOf()</u>
:
; <u>split()</u>
: Returns an array of ByteArrays instead of ByteStrings.
; <u>filter()/u>
:
; <u>forEach()/u>
:
; <u>every()/u>
:
; <u>some()/u>
:
; <u>map()/u>
:
; <u>reduce()/u>
:
; <u>reduceRight()/u>
:
; <u>displace(begin, end, values/ByteStrings/ByteArrays/Arrays...) -> length</u>
: begin/end are specified like for slice. Can be used like splice but does not return the removed elements.
; toSource()
; toSource()
: returns a string like "ByteArray([])" for a null byte-array.
: Returns a string like "ByteArray([])" for a null byte-array.
; [] Number
; [] Number
: The mutable [] operator for numbers
: The mutable [] operator for numbers
62

edits