[{"data":1,"prerenderedAt":1152},["ShallowReactive",2],{"navigation_docs":3,"-guide-binary-serialization":149,"-guide-binary-serialization-surround":1147},[4,27,81,103,144],{"title":5,"icon":6,"redirect":7,"path":8,"stem":9,"children":10,"page":26},"Introduction","i-lucide-rocket","\u002Fintroduction\u002Fabout-ts-runtypes","\u002Fintroduction","01.introduction",[11,14,18,22],{"title":12,"path":7,"stem":13},"About RunTypes","01.introduction\u002F01.about-ts-runtypes",{"title":15,"path":16,"stem":17},"Built on typescript-go","\u002Fintroduction\u002Fbuilt-on-typescript-go","01.introduction\u002F02.built-on-typescript-go",{"title":19,"path":20,"stem":21},"Quick Start","\u002Fintroduction\u002Fquick-start","01.introduction\u002F03.quick-start",{"title":23,"path":24,"stem":25},"Configuration","\u002Fintroduction\u002Fconfiguration","01.introduction\u002F04.configuration",false,{"title":28,"icon":29,"redirect":30,"path":31,"stem":32,"children":33,"page":26},"Guide","i-lucide-book-open","\u002Fguide\u002Ftype-builders","\u002Fguide","02.guide",[34,37,41,45,49,53,57,61,65,69,73,77],{"title":35,"path":30,"stem":36},"Types vs Type Builders","02.guide\u002F01.type-builders",{"title":38,"path":39,"stem":40},"Type Formats","\u002Fguide\u002Ftype-formats","02.guide\u002F02.type-formats",{"title":42,"path":43,"stem":44},"Validation","\u002Fguide\u002Fvalidation","02.guide\u002F03.validation",{"title":46,"path":47,"stem":48},"Reflection","\u002Fguide\u002Freflection","02.guide\u002F04.reflection",{"title":50,"path":51,"stem":52},"JSON Serialization","\u002Fguide\u002Fjson-serialization","02.guide\u002F05.json-serialization",{"title":54,"path":55,"stem":56},"Binary Serialization","\u002Fguide\u002Fbinary-serialization","02.guide\u002F06.binary-serialization",{"title":58,"path":59,"stem":60},"Data Mocking","\u002Fguide\u002Fmocking","02.guide\u002F07.mocking",{"title":62,"path":63,"stem":64},"Compiler Markers","\u002Fguide\u002Fcompiler-markers","02.guide\u002F08.compiler-markers",{"title":66,"path":67,"stem":68},"Pure Functions","\u002Fguide\u002Fpure-functions","02.guide\u002F09.pure-functions",{"title":70,"path":71,"stem":72},"Linting","\u002Fguide\u002Flinting","02.guide\u002F10.linting",{"title":74,"path":75,"stem":76},"Source Conversion","\u002Fguide\u002Fsource-conversion","02.guide\u002F13.source-conversion",{"title":78,"path":79,"stem":80},"Generating JSON Schema","\u002Fguide\u002Fjson-schema-generation","02.guide\u002F14.json-schema-generation",{"title":82,"icon":83,"redirect":84,"path":85,"stem":86,"children":87,"page":26},"AI Integration","i-lucide-sparkles","\u002Fai-integration\u002Fworkflow-and-commands","\u002Fai-integration","03.ai-integration",[88,91,95,99],{"title":89,"path":84,"stem":90},"AI Workflow","03.ai-integration\u002F01.workflow-and-commands",{"title":92,"path":93,"stem":94},"FriendlyText","\u002Fai-integration\u002Ffriendly-type","03.ai-integration\u002F02.friendly-type",{"title":96,"path":97,"stem":98},"MockData","\u002Fai-integration\u002Fmock-data","03.ai-integration\u002F03.mock-data",{"title":100,"path":101,"stem":102},"Translations (i18n)","\u002Fai-integration\u002Fi18n","03.ai-integration\u002F04.i18n",{"title":104,"icon":105,"redirect":106,"path":107,"stem":108,"children":109,"page":26},"Benchmarks","i-lucide-gauge","\u002Fbenchmarks\u002Fvalidation","\u002Fbenchmarks","07.benchmarks",[110,112,116,120,124,128,132,136,140],{"title":42,"path":106,"stem":111},"07.benchmarks\u002F01.validation",{"title":113,"path":114,"stem":115},"Validation Formats","\u002Fbenchmarks\u002Fvalidation-formats","07.benchmarks\u002F02.validation-formats",{"title":117,"path":118,"stem":119},"Validation Errors","\u002Fbenchmarks\u002Fgetvalidationerrors","07.benchmarks\u002F03.getvalidationerrors",{"title":121,"path":122,"stem":123},"Validation Error Formats","\u002Fbenchmarks\u002Fgetvalidationerrors-formats","07.benchmarks\u002F04.getvalidationerrors-formats",{"title":125,"path":126,"stem":127},"Serialization","\u002Fbenchmarks\u002Fserialization","07.benchmarks\u002F05.serialization",{"title":129,"path":130,"stem":131},"Serialization Formats","\u002Fbenchmarks\u002Fserialization-formats","07.benchmarks\u002F06.serialization-formats",{"title":133,"path":134,"stem":135},"Compile Time","\u002Fbenchmarks\u002Fcompiletime","07.benchmarks\u002F07.compiletime",{"title":137,"path":138,"stem":139},"Correctness","\u002Fbenchmarks\u002Fcorrectness","07.benchmarks\u002F08.correctness",{"title":141,"path":142,"stem":143},"Strict validation","\u002Fbenchmarks\u002Fstrict","07.benchmarks\u002F09.strict",{"title":145,"path":146,"stem":147,"icon":148},"Diagnostics","\u002Fdiagnostics","08.diagnostics","i-lucide-triangle-alert",{"id":150,"title":54,"body":151,"description":1141,"extension":1142,"links":1143,"meta":1144,"navigation":279,"path":55,"seo":1145,"stem":56,"__hash__":1146},"docs\u002F02.guide\u002F06.binary-serialization.md",{"type":152,"value":153},"minimark",[154,159,190,205,352,359,363,370,418,522,535,581,585,592,910,923,927,962,966,978,1096,1100,1107,1137],[155,156,158],"h2",{"id":157},"the-round-trip","The round trip",[160,161,162,166,167,170,171,175,176,179,180,182,183,186,187,189],"p",{},[163,164,165],"code",{},"createBinaryEncoderFn"," and ",[163,168,169],{},"createBinaryDecoderFn"," are the ",[172,173,174],"a",{"href":51},"JSON pair"," with a different output: compact bytes instead of text. Everything else is the same. The codec is generated from your type, so a ",[163,177,178],{},"Date"," comes back as a ",[163,181,178],{},", and a ",[163,184,185],{},"Map"," as a ",[163,188,185],{},".",[160,191,192,193,196,197,200,201,204],{},"The encoder returns the encoded bytes as a zero-copy ",[163,194,195],{},"Uint8Array"," (its ",[163,198,199],{},"byteLength"," is the exact size on the wire; call ",[163,202,203],{},"slice()"," if you want an owned copy). The decoder takes those bytes, or any buffer or view, straight back.",[206,207,212],"pre",{"className":208,"code":209,"language":210,"meta":211,"style":211},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","const encode = createBinaryEncoderFn\u003CTelemetry>();\nconst decode = createBinaryDecoderFn\u003CTelemetry>();\n\nconst bytes = encode(sample); \u002F\u002F a Uint8Array view of the encoded bytes: compact, no field names on the wire\nconst back = decode(bytes); \u002F\u002F decode reads the bytes directly; typed as DataOnly\u003CTelemetry>\n\nback.recordedAt instanceof Date; \u002F\u002F true: Date round-trips, like JSON\n","ts","",[163,213,214,251,274,281,304,325,330],{"__ignoreMap":211},[215,216,219,223,227,231,235,238,242,245,248],"span",{"class":217,"line":218},"line",1,[215,220,222],{"class":221},"spNyl","const",[215,224,226],{"class":225},"sTEyZ"," encode ",[215,228,230],{"class":229},"sMK4o","=",[215,232,234],{"class":233},"s2Zo4"," createBinaryEncoderFn",[215,236,237],{"class":229},"\u003C",[215,239,241],{"class":240},"sBMFI","Telemetry",[215,243,244],{"class":229},">",[215,246,247],{"class":225},"()",[215,249,250],{"class":229},";\n",[215,252,254,256,259,261,264,266,268,270,272],{"class":217,"line":253},2,[215,255,222],{"class":221},[215,257,258],{"class":225}," decode ",[215,260,230],{"class":229},[215,262,263],{"class":233}," createBinaryDecoderFn",[215,265,237],{"class":229},[215,267,241],{"class":240},[215,269,244],{"class":229},[215,271,247],{"class":225},[215,273,250],{"class":229},[215,275,277],{"class":217,"line":276},3,[215,278,280],{"emptyLinePlaceholder":279},true,"\n",[215,282,284,286,289,291,294,297,300],{"class":217,"line":283},4,[215,285,222],{"class":221},[215,287,288],{"class":225}," bytes ",[215,290,230],{"class":229},[215,292,293],{"class":233}," encode",[215,295,296],{"class":225},"(sample)",[215,298,299],{"class":229},";",[215,301,303],{"class":302},"sHwdD"," \u002F\u002F a Uint8Array view of the encoded bytes: compact, no field names on the wire\n",[215,305,307,309,312,314,317,320,322],{"class":217,"line":306},5,[215,308,222],{"class":221},[215,310,311],{"class":225}," back ",[215,313,230],{"class":229},[215,315,316],{"class":233}," decode",[215,318,319],{"class":225},"(bytes)",[215,321,299],{"class":229},[215,323,324],{"class":302}," \u002F\u002F decode reads the bytes directly; typed as DataOnly\u003CTelemetry>\n",[215,326,328],{"class":217,"line":327},6,[215,329,280],{"emptyLinePlaceholder":279},[215,331,333,336,338,341,344,347,349],{"class":217,"line":332},7,[215,334,335],{"class":225},"back",[215,337,189],{"class":229},[215,339,340],{"class":225},"recordedAt ",[215,342,343],{"class":229},"instanceof",[215,345,346],{"class":240}," Date",[215,348,299],{"class":229},[215,350,351],{"class":302}," \u002F\u002F true: Date round-trips, like JSON\n",[160,353,354,355,358],{},"Reach for binary when you're moving lots of records and both ends are yours (WebSockets, game state, IoT). Stick with JSON when a human or a third party reads the payload, or you need it ",[163,356,357],{},"curl","-able.",[155,360,362],{"id":361},"choose-how-the-buffer-is-sized","Choose how the buffer is sized",[160,364,365,366,369],{},"The ",[163,367,368],{},"sizeStrategy"," option picks how the encoder sizes its buffer, and with it the shape of the function you get back:",[371,372,373,384,393,405],"ul",{},[374,375,376,379,380,383],"li",{},[163,377,378],{},"dynamic"," (the default), ",[163,381,382],{},"(val) => Uint8Array",", sizes its first buffer from a compile-time estimate of your type, then refines from earlier encodes and grows the buffer in place when a value runs larger. You configure nothing, and it suits almost everyone.",[374,385,386,389,390,392],{},[163,387,388],{},"precalculate",", ",[163,391,382],{},", measures the value once to find its exact size, then allocates exactly that. The extra pass makes encoding roughly a quarter slower; in return the buffer is never too large and never has to grow.",[374,394,395,389,398,401,402,189],{},[163,396,397],{},"initialSize",[163,399,400],{},"(val, size) => Uint8Array",", lets you pass the buffer size each call. It never grows, so a value that does not fit throws a ",[163,403,404],{},"RangeError",[374,406,407,389,410,413,414,417],{},[163,408,409],{},"intoBuffer",[163,411,412],{},"(val, into) => Uint8Array",", lets you pass the ",[163,415,416],{},"ArrayBuffer"," to write into each call. It writes a zero-copy view into your buffer and throws if the value does not fit.",[206,419,421],{"className":208,"code":420,"language":210,"meta":211,"style":211},"const encode = createBinaryEncoderFn\u003CUser>(undefined, {sizeStrategy: 'intoBuffer'});\nconst buffer = new ArrayBuffer(4096);\nconst view = encode(user, buffer); \u002F\u002F a Uint8Array view into `buffer`, zero-copy\n",[163,422,423,472,497],{"__ignoreMap":211},[215,424,425,427,429,431,433,435,438,440,443,446,449,452,455,458,461,464,467,470],{"class":217,"line":218},[215,426,222],{"class":221},[215,428,226],{"class":225},[215,430,230],{"class":229},[215,432,234],{"class":233},[215,434,237],{"class":229},[215,436,437],{"class":240},"User",[215,439,244],{"class":229},[215,441,442],{"class":225},"(",[215,444,445],{"class":229},"undefined,",[215,447,448],{"class":229}," {",[215,450,368],{"class":451},"swJcz",[215,453,454],{"class":229},":",[215,456,457],{"class":229}," '",[215,459,409],{"class":460},"sfazB",[215,462,463],{"class":229},"'",[215,465,466],{"class":229},"}",[215,468,469],{"class":225},")",[215,471,250],{"class":229},[215,473,474,476,479,481,484,487,489,493,495],{"class":217,"line":253},[215,475,222],{"class":221},[215,477,478],{"class":225}," buffer ",[215,480,230],{"class":229},[215,482,483],{"class":229}," new",[215,485,486],{"class":233}," ArrayBuffer",[215,488,442],{"class":225},[215,490,492],{"class":491},"sbssI","4096",[215,494,469],{"class":225},[215,496,250],{"class":229},[215,498,499,501,504,506,508,511,514,517,519],{"class":217,"line":276},[215,500,222],{"class":221},[215,502,503],{"class":225}," view ",[215,505,230],{"class":229},[215,507,293],{"class":233},[215,509,510],{"class":225},"(user",[215,512,513],{"class":229},",",[215,515,516],{"class":225}," buffer)",[215,518,299],{"class":229},[215,520,521],{"class":302}," \u002F\u002F a Uint8Array view into `buffer`, zero-copy\n",[160,523,524,525,527,528,530,531,534],{},"To pick a safe size for ",[163,526,397],{}," or ",[163,529,409],{},", ask ",[163,532,533],{},"createBinarySizerFn"," for the exact byte count. It runs the same encoding as the encoder but writes nothing, so it allocates no buffer:",[206,536,538],{"className":208,"code":537,"language":210,"meta":211,"style":211},"const sizeOf = createBinarySizerFn\u003CUser>();\nconst bytes = sizeOf(user); \u002F\u002F exact on-wire size, no buffer allocated\n",[163,539,540,562],{"__ignoreMap":211},[215,541,542,544,547,549,552,554,556,558,560],{"class":217,"line":218},[215,543,222],{"class":221},[215,545,546],{"class":225}," sizeOf ",[215,548,230],{"class":229},[215,550,551],{"class":233}," createBinarySizerFn",[215,553,237],{"class":229},[215,555,437],{"class":240},[215,557,244],{"class":229},[215,559,247],{"class":225},[215,561,250],{"class":229},[215,563,564,566,568,570,573,576,578],{"class":217,"line":253},[215,565,222],{"class":221},[215,567,288],{"class":225},[215,569,230],{"class":229},[215,571,572],{"class":233}," sizeOf",[215,574,575],{"class":225},"(user)",[215,577,299],{"class":229},[215,579,580],{"class":302}," \u002F\u002F exact on-wire size, no buffer allocated\n",[155,582,584],{"id":583},"reuse-the-buffer-in-hot-loops","Reuse the buffer in hot loops",[160,586,587,588,591],{},"In a tight loop the per-encode allocation adds up. With ",[163,589,590],{},"sizeStrategy: 'intoBuffer'"," you allocate one buffer and reuse it: the encoder writes into it and hands back a zero-copy view, so there is no fresh allocation per call. Consume each view before the next encode overwrites the buffer.",[206,593,595],{"className":208,"code":594,"language":210,"meta":211,"style":211},"\u002F\u002F In a hot loop, allocate one buffer and reuse it. With sizeStrategy 'intoBuffer' the\n\u002F\u002F encoder writes into YOUR buffer and returns a zero-copy view, so there is no\n\u002F\u002F fresh allocation per call. createBinarySizerFn gives a safe size to allocate.\nconst encode = createBinaryEncoderFn\u003CTick>(undefined, {sizeStrategy: 'intoBuffer'});\nconst decode = createBinaryDecoderFn\u003CTick>();\nconst sizeOf = createBinarySizerFn\u003CTick>();\n\nconst ticks: Tick[] = [\n  {symbol: 'TS', price: 7},\n  {symbol: 'GO', price: 9},\n];\n\nconst buffer = new ArrayBuffer(Math.max(...ticks.map(sizeOf)));\n\nfor (const tick of ticks) {\n  const view = encode(tick, buffer); \u002F\u002F a Uint8Array view into `buffer`\n  decode(view); \u002F\u002F consume the view before the next encode reuses the buffer\n}\n",[163,596,597,602,607,612,651,671,691,695,716,747,774,782,787,826,831,855,886,904],{"__ignoreMap":211},[215,598,599],{"class":217,"line":218},[215,600,601],{"class":302},"\u002F\u002F In a hot loop, allocate one buffer and reuse it. With sizeStrategy 'intoBuffer' the\n",[215,603,604],{"class":217,"line":253},[215,605,606],{"class":302},"\u002F\u002F encoder writes into YOUR buffer and returns a zero-copy view, so there is no\n",[215,608,609],{"class":217,"line":276},[215,610,611],{"class":302},"\u002F\u002F fresh allocation per call. createBinarySizerFn gives a safe size to allocate.\n",[215,613,614,616,618,620,622,624,627,629,631,633,635,637,639,641,643,645,647,649],{"class":217,"line":283},[215,615,222],{"class":221},[215,617,226],{"class":225},[215,619,230],{"class":229},[215,621,234],{"class":233},[215,623,237],{"class":229},[215,625,626],{"class":240},"Tick",[215,628,244],{"class":229},[215,630,442],{"class":225},[215,632,445],{"class":229},[215,634,448],{"class":229},[215,636,368],{"class":451},[215,638,454],{"class":229},[215,640,457],{"class":229},[215,642,409],{"class":460},[215,644,463],{"class":229},[215,646,466],{"class":229},[215,648,469],{"class":225},[215,650,250],{"class":229},[215,652,653,655,657,659,661,663,665,667,669],{"class":217,"line":306},[215,654,222],{"class":221},[215,656,258],{"class":225},[215,658,230],{"class":229},[215,660,263],{"class":233},[215,662,237],{"class":229},[215,664,626],{"class":240},[215,666,244],{"class":229},[215,668,247],{"class":225},[215,670,250],{"class":229},[215,672,673,675,677,679,681,683,685,687,689],{"class":217,"line":327},[215,674,222],{"class":221},[215,676,546],{"class":225},[215,678,230],{"class":229},[215,680,551],{"class":233},[215,682,237],{"class":229},[215,684,626],{"class":240},[215,686,244],{"class":229},[215,688,247],{"class":225},[215,690,250],{"class":229},[215,692,693],{"class":217,"line":332},[215,694,280],{"emptyLinePlaceholder":279},[215,696,698,700,703,705,708,711,713],{"class":217,"line":697},8,[215,699,222],{"class":221},[215,701,702],{"class":225}," ticks",[215,704,454],{"class":229},[215,706,707],{"class":240}," Tick",[215,709,710],{"class":225},"[] ",[215,712,230],{"class":229},[215,714,715],{"class":225}," [\n",[215,717,719,722,725,727,729,732,734,736,739,741,744],{"class":217,"line":718},9,[215,720,721],{"class":229},"  {",[215,723,724],{"class":451},"symbol",[215,726,454],{"class":229},[215,728,457],{"class":229},[215,730,731],{"class":460},"TS",[215,733,463],{"class":229},[215,735,513],{"class":229},[215,737,738],{"class":451}," price",[215,740,454],{"class":229},[215,742,743],{"class":491}," 7",[215,745,746],{"class":229},"},\n",[215,748,750,752,754,756,758,761,763,765,767,769,772],{"class":217,"line":749},10,[215,751,721],{"class":229},[215,753,724],{"class":451},[215,755,454],{"class":229},[215,757,457],{"class":229},[215,759,760],{"class":460},"GO",[215,762,463],{"class":229},[215,764,513],{"class":229},[215,766,738],{"class":451},[215,768,454],{"class":229},[215,770,771],{"class":491}," 9",[215,773,746],{"class":229},[215,775,777,780],{"class":217,"line":776},11,[215,778,779],{"class":225},"]",[215,781,250],{"class":229},[215,783,785],{"class":217,"line":784},12,[215,786,280],{"emptyLinePlaceholder":279},[215,788,790,792,794,796,798,800,803,805,808,810,813,816,818,821,824],{"class":217,"line":789},13,[215,791,222],{"class":221},[215,793,478],{"class":225},[215,795,230],{"class":229},[215,797,483],{"class":229},[215,799,486],{"class":233},[215,801,802],{"class":225},"(Math",[215,804,189],{"class":229},[215,806,807],{"class":233},"max",[215,809,442],{"class":225},[215,811,812],{"class":229},"...",[215,814,815],{"class":225},"ticks",[215,817,189],{"class":229},[215,819,820],{"class":233},"map",[215,822,823],{"class":225},"(sizeOf)))",[215,825,250],{"class":229},[215,827,829],{"class":217,"line":828},14,[215,830,280],{"emptyLinePlaceholder":279},[215,832,834,838,841,843,846,849,852],{"class":217,"line":833},15,[215,835,837],{"class":836},"s7zQu","for",[215,839,840],{"class":225}," (",[215,842,222],{"class":221},[215,844,845],{"class":225}," tick ",[215,847,848],{"class":229},"of",[215,850,851],{"class":225}," ticks) ",[215,853,854],{"class":229},"{\n",[215,856,858,861,864,867,869,871,874,876,879,881,883],{"class":217,"line":857},16,[215,859,860],{"class":221},"  const",[215,862,863],{"class":225}," view",[215,865,866],{"class":229}," =",[215,868,293],{"class":233},[215,870,442],{"class":451},[215,872,873],{"class":225},"tick",[215,875,513],{"class":229},[215,877,878],{"class":225}," buffer",[215,880,469],{"class":451},[215,882,299],{"class":229},[215,884,885],{"class":302}," \u002F\u002F a Uint8Array view into `buffer`\n",[215,887,889,892,894,897,899,901],{"class":217,"line":888},17,[215,890,891],{"class":233},"  decode",[215,893,442],{"class":451},[215,895,896],{"class":225},"view",[215,898,469],{"class":451},[215,900,299],{"class":229},[215,902,903],{"class":302}," \u002F\u002F consume the view before the next encode reuses the buffer\n",[215,905,907],{"class":217,"line":906},18,[215,908,909],{"class":229},"}\n",[911,912,913,914,916,917,919,920,922],"note",{},"You only reach for ",[163,915,409],{}," when you want to own the buffer in performance-sensitive code. For everyday encode\u002Fdecode, the default ",[163,918,165],{}," \u002F ",[163,921,169],{}," calls handle their own buffers.",[155,924,926],{"id":925},"payload-size","Payload size",[160,928,929,930,527,933,936,937,527,940,943,944,166,947,949,950,953,954,957,958,961],{},"Binary is the strategy that wins big when your types carry format constraints. The codec reserves a worst case width whenever it cannot tell a value's range, so an unconstrained ",[163,931,932],{},"number",[163,934,935],{},"bigint"," rides the wire as a fixed 8 bytes. Once the type pins the value into a known range (a fixed width like ",[163,938,939],{},"int8",[163,941,942],{},"uint16",", or a ",[163,945,946],{},"min",[163,948,807],{}," bound), the encoder packs it into far fewer bytes (a ",[163,951,952],{},"uint8"," into 1 byte, a ",[163,955,956],{},"{min: 0, max: 1000}"," number into 2). The ",[172,959,960],{"href":130},"serialization formats benchmark"," pairs each unconstrained value against its constrained twin, so you can read the saving off directly.",[155,963,965],{"id":964},"circular-references","Circular references",[160,967,968,969,972,973,977],{},"A value that points back at itself makes the encoder recurse until the stack overflows, so the binary encoder arms the same per-call ",[163,970,971],{},"rejectCircularRefs"," guard as the ",[172,974,976],{"href":975},"\u002Fguide\u002Fjson-serialization#circular-references","JSON one",", with the same pay-for-use rule.",[206,979,981],{"className":208,"code":980,"language":210,"meta":211,"style":211},"\u002F\u002F The binary encoder arms the same way. `rejectCircularRefs` is a compile-time\n\u002F\u002F option, so the armed encoder is a separate compiled function that bakes the\n\u002F\u002F cycle check into its body (you only pay for it where you ask for it).\nconst encodeBin = createBinaryEncoderFn\u003CNode>(undefined, {rejectCircularRefs: true});\ntry {\n  encodeBin(cyclic as Node);\n} catch (err) {\n  err instanceof CircularReferenceError; \u002F\u002F true\n}\n",[163,982,983,988,993,998,1036,1044,1064,1076,1092],{"__ignoreMap":211},[215,984,985],{"class":217,"line":218},[215,986,987],{"class":302},"\u002F\u002F The binary encoder arms the same way. `rejectCircularRefs` is a compile-time\n",[215,989,990],{"class":217,"line":253},[215,991,992],{"class":302},"\u002F\u002F option, so the armed encoder is a separate compiled function that bakes the\n",[215,994,995],{"class":217,"line":276},[215,996,997],{"class":302},"\u002F\u002F cycle check into its body (you only pay for it where you ask for it).\n",[215,999,1000,1002,1005,1007,1009,1011,1014,1016,1018,1020,1022,1024,1026,1030,1032,1034],{"class":217,"line":283},[215,1001,222],{"class":221},[215,1003,1004],{"class":225}," encodeBin ",[215,1006,230],{"class":229},[215,1008,234],{"class":233},[215,1010,237],{"class":229},[215,1012,1013],{"class":240},"Node",[215,1015,244],{"class":229},[215,1017,442],{"class":225},[215,1019,445],{"class":229},[215,1021,448],{"class":229},[215,1023,971],{"class":451},[215,1025,454],{"class":229},[215,1027,1029],{"class":1028},"sfNiH"," true",[215,1031,466],{"class":229},[215,1033,469],{"class":225},[215,1035,250],{"class":229},[215,1037,1038,1041],{"class":217,"line":306},[215,1039,1040],{"class":836},"try",[215,1042,1043],{"class":229}," {\n",[215,1045,1046,1049,1051,1054,1057,1060,1062],{"class":217,"line":327},[215,1047,1048],{"class":233},"  encodeBin",[215,1050,442],{"class":451},[215,1052,1053],{"class":225},"cyclic",[215,1055,1056],{"class":836}," as",[215,1058,1059],{"class":240}," Node",[215,1061,469],{"class":451},[215,1063,250],{"class":229},[215,1065,1066,1068,1071,1074],{"class":217,"line":332},[215,1067,466],{"class":229},[215,1069,1070],{"class":836}," catch",[215,1072,1073],{"class":225}," (err) ",[215,1075,854],{"class":229},[215,1077,1078,1081,1084,1087,1089],{"class":217,"line":697},[215,1079,1080],{"class":225},"  err",[215,1082,1083],{"class":229}," instanceof",[215,1085,1086],{"class":240}," CircularReferenceError",[215,1088,299],{"class":229},[215,1090,1091],{"class":302}," \u002F\u002F true\n",[215,1093,1094],{"class":217,"line":718},[215,1095,909],{"class":229},[155,1097,1099],{"id":1098},"what-it-shares-with-json","What it shares with JSON",[160,1101,1102,1103,1106],{},"Everything below the wire format itself is the same, and lives on the ",[172,1104,1105],{"href":51},"JSON serialization"," page:",[371,1108,1109,1120,1130],{},[374,1110,1111,1115,1116,1119],{},[172,1112,1114],{"href":1113},"\u002Fguide\u002Fjson-serialization#custom-class-serializers","Custom class serializers",": one ",[163,1117,1118],{},"registerClassSerializer"," call covers both codecs.",[374,1121,1122,1129],{},[172,1123,1125,1126],{"href":1124},"\u002Fguide\u002Fjson-serialization#decoders-return-dataonlyt","Decoders return ",[163,1127,1128],{},"DataOnly\u003CT>",": bytes can only carry data, so methods are left out of the type that comes back.",[374,1131,1132,1136],{},[172,1133,1135],{"href":1134},"\u002Fguide\u002Fjson-serialization#one-contract-serializable-data-only","One contract: serializable data only",": functions, methods and symbol keys are dropped, with a build-time Warning.",[1138,1139,1140],"style",{},"html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sfNiH, html code.shiki .sfNiH{--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC}","The same round trip as JSON, written as compact bytes instead of text.","md",null,{"toc":26},{"title":54,"description":1141},"q0gcMqyIiihOthzNBzTMPJ0WoWM4IYc_BXB4RTWdBEo",[1148,1150],{"title":50,"path":51,"stem":52,"description":1149,"children":-1},"Turn a value into JSON and get the same types back, generated from your type.",{"title":58,"path":59,"stem":60,"description":1151,"children":-1},"Generate valid or invalid type-shaped fake data for tests and fixtures.",1787523489065]