Liking cljdoc? Tell your friends :D

boring.writer

CBOR writer for ClojureScript.

Design follows measurements taken on node before any of this was written:

  • DataView, not hand-rolled shift/mask. Manual byte assembly measured 2.2x SLOWER than DataView for a big-endian i32 (4.34 vs 1.97 ns), which is the opposite of the usual instinct. DataView's default byte order is big-endian, which is also CBOR's.
  • TextEncoder costs ~56 ns per call regardless of string length, so a manual ASCII loop wins below ~55 characters (8.7 ns for 9 chars). Keywords and map keys are almost always shorter than that, so using TextEncoder everywhere would cost ~6x on the hot case.
  • setBigInt64 is 5.7x a normal write, so it is reserved for values outside the safe-integer range.
CBOR writer for ClojureScript.

Design follows measurements taken on node before any of this
was written:

- `DataView`, not hand-rolled shift/mask. Manual byte assembly measured 2.2x
  SLOWER than DataView for a big-endian i32 (4.34 vs 1.97 ns), which is the
  opposite of the usual instinct. DataView's default byte order is
  big-endian, which is also CBOR's.
- `TextEncoder` costs ~56 ns per call regardless of string length, so a manual
  ASCII loop wins below ~55 characters (8.7 ns for 9 chars). Keywords and map
  keys are almost always shorter than that, so using TextEncoder everywhere
  would cost ~6x on the hot case.
- `setBigInt64` is 5.7x a normal write, so it is reserved for values outside
  the safe-integer range.
raw docstring

ARRAYcljs

source

ASCII-LOOP-MAXcljs

source

buffercljs

(buffer w)
source

BYTEScljs

source

head!cljs

(head! w major val)

Header byte for major carrying unsigned val, in the shortest form.

Header byte for `major` carrying unsigned `val`, in the shortest form.
sourceraw docstring

MAPcljs

source

MAX-SAFEcljs

source

NAME-QUEUEcljs

source

NAME-SORTED-MAPcljs

source

NAME-SORTED-SETcljs

source

NAME-WITH-METAcljs

source

NINTcljs

source

positioncljs

(position w)
source

reset!cljs

(reset! w)
source

SIMPLEcljs

source

TAGcljs

source

TAG-DATETIMEcljs

source

TAG-DECIMALcljs

source

TAG-GENERIC-OBJcljs

source

TAG-IDENTIFIERcljs

source

TAG-NEG-BIGNUMcljs

source

TAG-POS-BIGNUMcljs

source

TAG-RATIONALcljs

source

TAG-REGEXcljs

source

TAG-SETcljs

source

TAG-SHAPED-ARRAYcljs

source

TAG-SR-NScljs

source

TAG-STRINGREFcljs

source

TAG-URIcljs

source

TAG-UUIDcljs

source

TEXTcljs

source

text-encodercljs

source

to-bytescljs

(to-bytes w)
source

typed-array-tagscljs

source

UINTcljs

source

write-bool!cljs

(write-bool! w b)
source

write-bytes!cljs

(write-bytes! w bs)
source

write-f16!cljs

(write-f16! w bits)
source

write-f32!cljs

(write-f32! w f)
source

write-f64!cljs

(write-f64! w d)
source

write-int!cljs

(write-int! w n)
source

write-nil!cljs

(write-nil! w)
source

write-shortest-float!cljs

(write-shortest-float! w d)

RFC 8949 §4.2.2 preferred serialisation: narrowest form that round-trips.

RFC 8949 §4.2.2 preferred serialisation: narrowest form that round-trips.
sourceraw docstring

write-string!cljs

(write-string! w s)
source

write-stringref-namespace!cljs

(write-stringref-namespace! w)
source

write-value!cljs

(write-value! w x)
source

writercljs

(writer)
(writer size)
source

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close