ServerJS/Encodings: Difference between revisions

(→‎Class: Converter: add close() method)
Line 49: Line 49:
; [Constructor] Converter(from, to)
; [Constructor] Converter(from, to)
: Where from and to are the encoding names.
: Where from and to are the encoding names.
; [Method] push(byteStringOrArray)
; [Method] write(byteStringOrArray)
: Convert input from a ByteString or ByteArray. The results are stored in an internal buffer, and also those parts of byteStringOrArray that could not be converted (for multi-byte encodings, in a separate buffer).
: Convert input from a ByteString or ByteArray. The results are stored in an internal buffer, and also those parts of byteStringOrArray that could not be converted (for multi-byte encodings, in a separate buffer).
: Returns nothing.
: Returns nothing.
; [Method] get([byteArray,] [maximumSize])
; [Method] read([byteArray,] [maximumSize])
: Read maximumSize bytes or as many bytes as available out of the internal buffer. If byteArray is specified, the data is written into that ByteArray.
: Read maximumSize bytes or as many bytes as available out of the internal buffer. If byteArray is specified, the data is written into that ByteArray.
: Returns a ByteString if byteArray is not specified, or byteArray itself otherwise.
: Returns a ByteString if byteArray is not specified, or byteArray itself otherwise.
Line 59: Line 59:
: Returns nothing and takes no parameters.
: Returns nothing and takes no parameters.


'''TODO': Which exceptions to throw on error?
'''TODO': Which exception to throw on error?


Example usage:
Example usage:
62

edits