You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
typesetting/pitfall/restructure/encodestream.rkt

19 lines
551 B
Racket

#lang restructure/racket
(provide (all-defined-out))
#| approximates
https://github.com/mbutterick/restructure/blob/master/src/EncodeStream.coffee
|#
;; basically just a wrapper for a Racket outputport
(define-subclass object% (REncodeStream [bufferSize 65536])
(field [_port (open-output-bytes)])
(getter-field [pos (port-position _port)])
(define/public (dump)
(get-output-bytes _port))
(define/public (write val)
(cond
[(bytes? val) (write-bytes val _port) (void)]
[else (error 'REncodeStream:write:unknown-type)])))