kill isBuffer

main
Matthew Butterick 5 years ago
parent 2c9ac3b6dc
commit 17ef98718a

@ -122,8 +122,8 @@
(define/contract (write this x)
((or/c string? isBuffer?) . ->m . any/c)
(define bstr (if (not (isBuffer? x))
((or/c string? bytes?) . ->m . any/c)
(define bstr (if (not (bytes? x))
(newBuffer (string-append x "\n"))
x))
(push-field! doc-byte-strings this bstr)

@ -2,7 +2,6 @@
(require (for-syntax racket/base racket/syntax br/syntax) br/define racket/class sugar/list racket/list (only-in br/list push! pop!) racket/string racket/format racket/contract)
(provide (all-defined-out) push! pop!)
(define isBuffer? bytes?)
(define (newBuffer x) (string->bytes/latin-1 (format "~a" x)))
(define buffer-length bytes-length)

@ -17,7 +17,7 @@
(define/contract (PDFImage-open src label)
(any/c any/c . -> . (or/c (is-a?/c PNG) (is-a?/c JPEG)))
(define data (cond
[(isBuffer? src) src]
[(bytes? src) src]
;;else if src instanceof ArrayBuffer
;;data = new Buffer(new Uint8Array(src))
[(regexp-match #rx"^data:.+;base64,(.*)$" src)

@ -24,18 +24,18 @@
(define/contract (write this x)
((or/c string? isBuffer? input-port?) . ->m . void?)
((or/c string? bytes? input-port?) . ->m . void?)
(push-field! ref-byte-strings this
(let loop ([x x])
(cond
[(isBuffer? x) x]
[(bytes? x) x]
[(input-port? x) (loop (port->bytes x))]
[else (bytes-append (newBuffer x) #"\n")]))))
(define got-ref-byte-strings? pair?)
(define/contract (end this [chunk #f])
(() ((or/c string? isBuffer? input-port?)) . ->*m . void?)
(() ((or/c string? bytes? input-port?)) . ->*m . void?)
(when chunk (send this write chunk))
#;(report* 'end! (· this id))

Loading…
Cancel
Save