File tree Expand file tree Collapse file tree 1 file changed +3
-0
lines changed Expand file tree Collapse file tree 1 file changed +3
-0
lines changed Original file line number Diff line number Diff line change @@ -62,15 +62,18 @@ const data = Uint8Array.fromBase64(inputBase64);
62
62
const dataLen = data .length ;
63
63
const dataLenStr = String (dataLen);
64
64
const digitCount = dataLenStr .length ;
65
+
65
66
// Transfer to a new ArrayBuffer with room for the netstring framing.
66
67
const tmpBuf = data .buffer .transfer (digitCount + 1 + dataLen + 1 );
67
68
const tmpArr = new Uint8Array (tmpBuf);
68
69
assert (tmpArr .buffer === tmpBuf);
70
+
69
71
// Frame the data.
70
72
tmpArr .copyWithin (digitCount + 1 , 0 );
71
73
for (let i = 0 ; i < digitCount; i++ ) tmpArr[i] = dataLenStr .charCodeAt (i);
72
74
tmpArr[digitCount] = 0x3A ;
73
75
tmpArr[tmpArr .length - 1 ] = 0x2C ;
76
+
74
77
// Transfer to an immutable ArrayBuffer backing a frozen Uint8Array.
75
78
const netstringArr = Object .freeze (new Uint8Array (tmpBuf .transferToImmutable ()));
76
79
assert (tmpBuf .detached );
You can’t perform that action at this time.
0 commit comments