\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Ran Qing (Ran Qing)} \pdfinfo{ /Title (node-js-apis.pdf) /Creator (Cheatography) /Author (Ran Qing (Ran Qing)) /Subject (Node.JS APIs Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{71C427} \definecolor{LightBackground}{HTML}{F6FBF1} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Node.JS APIs Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Ran Qing (Ran Qing)} via \textcolor{DarkBackground}{\uline{cheatography.com/197298/cs/41567/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Ran Qing (Ran Qing) \\ \uline{cheatography.com/ran-qing} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 6th December, 2023.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{p{0.8 cm} p{0.8 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Assertion testing}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.04 cm} x{4.96 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{断言模式}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{严格断言模式} & \seqsplit{require('node:assert/strict')} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{传统断言模式} & require('node:assert') \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.28 cm} x{4.72 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{断言错误}} \tn % Row 0 \SetRowColor{LightBackground} 类 & new \seqsplit{assert.AssertionError(options)} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} 错误类型 & name \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} 错误信息 & message \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} 真实值 & actual \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} 期望值 & expect \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} ERR\_ASSERTION & code \tn % Row Count 7 (+ 1) % Row 6 \SetRowColor{LightBackground} 断言操作 & operator \tn % Row Count 8 (+ 1) % Row 7 \SetRowColor{white} \seqsplit{是否自动生成信息} & generatedMessage \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.8 cm} x{5.2 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{断言操作}} \tn % Row 0 \SetRowColor{LightBackground} 真值 & {[}ok{]}(value{[}, message{]}) \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} 相等 & equal(actual, expected{[}, message{]}) \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} 严格相等 & strictEqual(actual, expected{[}, message{]}) \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} 深层相等 & deepEqual(actual, expected{[}, message{]}) \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} \seqsplit{深层严格相等} & deepStrictEqual(actual, expected{[}, message{]}) \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} 不相等 & notEqual(actual, expected{[}, message{]}) \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} \seqsplit{不严格相等} & notStrictEqual(actual, expected{[}, message{]}) \tn % Row Count 13 (+ 2) % Row 7 \SetRowColor{white} \seqsplit{不深层相等} & notDeepEqual(actual, expected{[}, message{]}) \tn % Row Count 15 (+ 2) % Row 8 \SetRowColor{LightBackground} \seqsplit{不深层严格相等} & \seqsplit{notDeepStrictEqual(actual}, expected{[}, message{]}) \tn % Row Count 17 (+ 2) % Row 9 \SetRowColor{white} 正则匹配 & match(string, regexp{[}, message{]}) \tn % Row Count 19 (+ 2) % Row 10 \SetRowColor{LightBackground} \seqsplit{正则不匹配} & doesNotMatch(string, regexp{[}, message{]}) \tn % Row Count 21 (+ 2) % Row 11 \SetRowColor{white} \seqsplit{异步函数拒绝} & rejects(asyncFn{[}, error{]}{[}, message{]}) \tn % Row Count 23 (+ 2) % Row 12 \SetRowColor{LightBackground} \seqsplit{异步函数非拒绝} & doesNotReject(asyncFn{[}, error{]}{[}, message{]}) \tn % Row Count 25 (+ 2) % Row 13 \SetRowColor{white} \seqsplit{函数抛出错误} & throws(fn{[}, error{]}{[}, message{]}) \tn % Row Count 27 (+ 2) % Row 14 \SetRowColor{LightBackground} \seqsplit{函数不抛出错误} & doesNotThrow(fn{[}, error{]}{[}, message{]}) \tn % Row Count 29 (+ 2) % Row 15 \SetRowColor{white} \seqsplit{期望undefined和null} & ifError(value) \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{2.8 cm} x{5.2 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{断言操作 (cont)}} \tn % Row 16 \SetRowColor{LightBackground} 抛出错误 & fail({[}message{]}) \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{0.8 cm} p{0.8 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Buffer}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{5.12 cm} x{2.88 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{编码格式}} \tn % Row 0 \SetRowColor{LightBackground} character & utf-8 \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} & utf16le \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} & latin1 \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} binary-to-text & base64 \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} & base64url \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} & hex \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} legacy character & ascii \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} & binary \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} & ucs2 \tn % Row Count 9 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4.16 cm} x{3.84 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Blob}} \tn % Row 0 \SetRowColor{LightBackground} 类 & new buffer.Blob({[}sources{[}, options{]}{]}) \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} 返回 Promise 包含数据的 ArrayBuffer & blob.arrayBuffer() \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} 数据字节大小 & blob.size \tn % Row Count 6 (+ 1) % Row 3 \SetRowColor{white} 截取 & blob.slice({[}start{[}, end{[}, type{]}{]}{]}) \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} 返回 ReadableStream & blob.stream() \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} 解码成字符串 utf-8格式 & blob.text() \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} 数据类型 & blob.type \tn % Row Count 13 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Buffer}} \tn % Row 0 \SetRowColor{LightBackground} 类 & Buffer \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{8.4cm}}{{\bf{静态方法}}} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} 创建对象 & Buffer.alloc(size{[}, fill{[}, encoding{]}{]}) \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{创建对象-不初始化} & \seqsplit{Buffer.allocUnsafe(size)} \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} \seqsplit{创建对象-不初始化-慢速路径} & \seqsplit{Buffer.allocUnsafeSlow(size)} \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} \seqsplit{返回字符串的字节长度} & Buffer.byteLength(string{[}, encoding{]}) \tn % Row Count 10 (+ 2) % Row 6 \SetRowColor{LightBackground} 比较字节长度 & Buffer.compare(buf1, buf2) \tn % Row Count 12 (+ 2) % Row 7 \SetRowColor{white} 连接字节数组 & Buffer.concat(list{[}, totalLength{]}) \tn % Row Count 14 (+ 2) % Row 8 \SetRowColor{LightBackground} 复制字节数组 & Buffer.copyBytesFrom(view{[}, offset{[}, length{]}{]}) \tn % Row Count 17 (+ 3) % Row 9 \SetRowColor{white} \seqsplit{创建对象-纯数值数组} & Buffer.from(array) \tn % Row Count 19 (+ 2) % Row 10 \SetRowColor{LightBackground} 创建对象-共享 arrayBuffer 内存 & Buffer.from(arrayBuffer{[}, byteOffset{[}, length{]}{]}) \tn % Row Count 22 (+ 3) % Row 11 \SetRowColor{white} 创建对象-复制 buffer & Buffer.from(buffer) \tn % Row Count 24 (+ 2) % Row 12 \SetRowColor{LightBackground} \seqsplit{创建对象-某些特定对象如} Array & Buffer.from(object{[}, offsetOrEncoding{[}, length{]}{]}) \tn % Row Count 27 (+ 3) % Row 13 \SetRowColor{white} \seqsplit{创建对象-字符串} & Buffer.from(string{[}, encoding{]}) \tn % Row Count 29 (+ 2) % Row 14 \SetRowColor{LightBackground} 判断是否为 Buffer 对象 & \seqsplit{Buffer.isBuffer(obj)} \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Buffer (cont)}} \tn % Row 15 \SetRowColor{LightBackground} 判断 Buffer \seqsplit{是否支持该编码} & \seqsplit{Buffer.isEncoding(encoding)} \tn % Row Count 2 (+ 2) % Row 16 \SetRowColor{white} Node.js 内部 Buffer 对象池的大小 & Buffer.poolSize \tn % Row Count 4 (+ 2) % Row 17 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{{\bf{实例对象}}} \tn % Row Count 5 (+ 1) % Row 18 \SetRowColor{white} \seqsplit{指定索引处的字节值} & buf.buf{[}index{]} \tn % Row Count 7 (+ 2) % Row 19 \SetRowColor{LightBackground} 与 Buffer 共享的 ArrayBuffer 对象 & buf.buffer \tn % Row Count 9 (+ 2) % Row 20 \SetRowColor{white} Buffer \seqsplit{对象的字节长度} & buf.length \tn % Row Count 11 (+ 2) % Row 21 \SetRowColor{LightBackground} Buffer 在 ArrayBuffer 中的偏移量 & buf.byteOffset \tn % Row Count 13 (+ 2) % Row 22 \SetRowColor{white} 与目标 Buffer 或 ArrayBuffer比较 & buf.compare(target{[}, targetStart{[}, targetEnd{[}, sourceStart{[}, sourceEnd{]}{]}{]}{]}) \tn % Row Count 17 (+ 4) % Row 23 \SetRowColor{LightBackground} 复制到目标 Buffer & buf.copy(target{[}, targetStart{[}, sourceStart{[}, sourceEnd{]}{]}{]}) \tn % Row Count 20 (+ 3) % Row 24 \SetRowColor{white} 填充 & buf.fill(value{[}, offset{[}, end{]}{]}{[}, encoding{]}) \tn % Row Count 23 (+ 3) % Row 25 \SetRowColor{LightBackground} \seqsplit{是否包含指定的值} & buf.includes(value{[}, byteOffset{]}{[}, encoding{]}) \tn % Row Count 26 (+ 3) % Row 26 \SetRowColor{white} 指定值在 Buffer \seqsplit{中第一次出现的索引} & buf.indexOf(value{[}, byteOffset{]}{[}, encoding{]}) \tn % Row Count 29 (+ 3) % Row 27 \SetRowColor{LightBackground} 截取数组 & buf.subarray({[}start{[}, end{]}{]}) \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Buffer (cont)}} \tn % Row 28 \SetRowColor{LightBackground} 每16字节 字节翻转顺序 & buf.swap16() \tn % Row Count 2 (+ 2) % Row 29 \SetRowColor{white} 每32字节 字节翻转顺序 & buf.swap32() \tn % Row Count 4 (+ 2) % Row 30 \SetRowColor{LightBackground} 每64字节 字节翻转顺序 & buf.swap64() \tn % Row Count 6 (+ 2) % Row 31 \SetRowColor{white} \mymulticolumn{2}{x{8.4cm}}{读取数据(BE大端 LE小端)} \tn % Row Count 7 (+ 1) % Row 32 \SetRowColor{LightBackground} 对象变 JSON 字符串 & buf.toJSON() \tn % Row Count 9 (+ 2) % Row 33 \SetRowColor{white} 解码成字符串 & buf.toString({[}encoding{[}, start{[}, end{]}{]}{]}) \tn % Row Count 11 (+ 2) % Row 34 \SetRowColor{LightBackground} 8 位有符号整数 & buf.readInt8({[}offset{]}) \tn % Row Count 13 (+ 2) % Row 35 \SetRowColor{white} 16 位有符号整数 & buf.readInt16BE({[}offset{]}) \tn % Row Count 15 (+ 2) % Row 36 \SetRowColor{LightBackground} 16 位有符号整数 & buf.readInt16LE({[}offset{]}) \tn % Row Count 17 (+ 2) % Row 37 \SetRowColor{white} 32 位有符号整数 & buf.readInt32BE({[}offset{]}) \tn % Row Count 19 (+ 2) % Row 38 \SetRowColor{LightBackground} 32 位有符号整数 & buf.readInt32LE({[}offset{]}) \tn % Row Count 21 (+ 2) % Row 39 \SetRowColor{white} 64 位有符号整数 & buf.readBigInt64BE({[}offset{]}) \tn % Row Count 23 (+ 2) % Row 40 \SetRowColor{LightBackground} 64 位有符号整数 & buf.readBigInt64LE({[}offset{]}) \tn % Row Count 25 (+ 2) % Row 41 \SetRowColor{white} xx \seqsplit{位的有符号整数} & \seqsplit{buf.readIntBE(offset}, byteLength) \tn % Row Count 27 (+ 2) % Row 42 \SetRowColor{LightBackground} xx \seqsplit{位的有符号整数} & \seqsplit{buf.readIntLE(offset}, byteLength) \tn % Row Count 29 (+ 2) % Row 43 \SetRowColor{white} 64 \seqsplit{位的无符号整数} & buf.readBigUInt64BE({[}offset{]}) \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Buffer (cont)}} \tn % Row 44 \SetRowColor{LightBackground} 64 \seqsplit{位的无符号整数} & buf.readBigUInt64LE({[}offset{]}) \tn % Row Count 2 (+ 2) % Row 45 \SetRowColor{white} 8 位无符号整数 & buf.readUInt8({[}offset{]}) \tn % Row Count 4 (+ 2) % Row 46 \SetRowColor{LightBackground} 16 位无符号整数 & buf.readUInt16BE({[}offset{]}) \tn % Row Count 6 (+ 2) % Row 47 \SetRowColor{white} 16 位无符号整数 & buf.readUInt16LE({[}offset{]}) \tn % Row Count 8 (+ 2) % Row 48 \SetRowColor{LightBackground} 32 位无符号整数 & buf.readUInt32BE({[}offset{]}) \tn % Row Count 10 (+ 2) % Row 49 \SetRowColor{white} 32 位无符号整数 & buf.readUInt32LE({[}offset{]}) \tn % Row Count 12 (+ 2) % Row 50 \SetRowColor{LightBackground} xx 位无符号整数 & \seqsplit{buf.readUIntBE(offset}, byteLength) \tn % Row Count 14 (+ 2) % Row 51 \SetRowColor{white} xx 位无符号整数 & \seqsplit{buf.readUIntLE(offset}, byteLength) \tn % Row Count 16 (+ 2) % Row 52 \SetRowColor{LightBackground} 32 \seqsplit{位的单精度浮点数} & buf.readFloatBE({[}offset{]}) \tn % Row Count 18 (+ 2) % Row 53 \SetRowColor{white} 32 \seqsplit{位的单精度浮点数} & buf.readFloatLE({[}offset{]}) \tn % Row Count 20 (+ 2) % Row 54 \SetRowColor{LightBackground} 64 \seqsplit{位的双精度浮点数} & buf.readDoubleBE({[}offset{]}) \tn % Row Count 22 (+ 2) % Row 55 \SetRowColor{white} 64 \seqsplit{位的双精度浮点数} & buf.readDoubleLE({[}offset{]}) \tn % Row Count 24 (+ 2) % Row 56 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{写入数据(BE大端 LE小端)} \tn % Row Count 25 (+ 1) % Row 57 \SetRowColor{white} 字符串 & buf.write(string{[}, offset{[}, length{]}{]}{[}, encoding{]}) \tn % Row Count 28 (+ 3) % Row 58 \SetRowColor{LightBackground} 8 位有符号整数 & buf.writeInt8(value{[}, offset{]}) \tn % Row Count 30 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Buffer (cont)}} \tn % Row 59 \SetRowColor{LightBackground} 16 位有符号整数 & buf.writeInt16BE(value{[}, offset{]}) \tn % Row Count 2 (+ 2) % Row 60 \SetRowColor{white} 16 位有符号整数 & buf.writeInt16LE(value{[}, offset{]}) \tn % Row Count 4 (+ 2) % Row 61 \SetRowColor{LightBackground} 32 位有符号整数 & buf.writeInt32BE(value{[}, offset{]}) \tn % Row Count 6 (+ 2) % Row 62 \SetRowColor{white} 32 位有符号整数 & buf.writeInt32LE(value{[}, offset{]}) \tn % Row Count 8 (+ 2) % Row 63 \SetRowColor{LightBackground} 64 位有符号整数 & buf.writeBigInt64BE(value{[}, offset{]}) \tn % Row Count 10 (+ 2) % Row 64 \SetRowColor{white} 64 位有符号整数 & buf.writeBigInt64LE(value{[}, offset{]}) \tn % Row Count 12 (+ 2) % Row 65 \SetRowColor{LightBackground} xx 位有符号整数 & \seqsplit{buf.writeIntBE(value}, offset, byteLength) \tn % Row Count 15 (+ 3) % Row 66 \SetRowColor{white} xx 位有符号整数 & \seqsplit{buf.writeIntLE(value}, offset, byteLength) \tn % Row Count 18 (+ 3) % Row 67 \SetRowColor{LightBackground} 8 位无符号整数 & buf.writeUInt8(value{[}, offset{]}) \tn % Row Count 20 (+ 2) % Row 68 \SetRowColor{white} 16 位无符号整数 & buf.writeUInt16BE(value{[}, offset{]}) \tn % Row Count 22 (+ 2) % Row 69 \SetRowColor{LightBackground} 16 位无符号整数 & buf.writeUInt16LE(value{[}, offset{]}) \tn % Row Count 24 (+ 2) % Row 70 \SetRowColor{white} 32 位无符号整数 & buf.writeUInt32BE(value{[}, offset{]}) \tn % Row Count 26 (+ 2) % Row 71 \SetRowColor{LightBackground} 32 位无符号整数 & buf.writeUInt32LE(value{[}, offset{]}) \tn % Row Count 28 (+ 2) % Row 72 \SetRowColor{white} 64 位无符号整数 & buf.writeBigUInt64BE(value{[}, offset{]}) \tn % Row Count 30 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Buffer (cont)}} \tn % Row 73 \SetRowColor{LightBackground} 64 位无符号整数 & buf.writeBigUInt64LE(value{[}, offset{]}) \tn % Row Count 2 (+ 2) % Row 74 \SetRowColor{white} xx 位无符号整数 & \seqsplit{buf.writeUIntBE(value}, offset, byteLength) \tn % Row Count 5 (+ 3) % Row 75 \SetRowColor{LightBackground} xx 位无符号整数 & \seqsplit{buf.writeUIntLE(value}, offset, byteLength) \tn % Row Count 8 (+ 3) % Row 76 \SetRowColor{white} 32 \seqsplit{位的单精度浮点数} & buf.writeFloatBE(value{[}, offset{]}) \tn % Row Count 10 (+ 2) % Row 77 \SetRowColor{LightBackground} 32 \seqsplit{位的单精度浮点数} & buf.writeFloatLE(value{[}, offset{]}) \tn % Row Count 12 (+ 2) % Row 78 \SetRowColor{white} 64 \seqsplit{位的双精度浮点数} & buf.writeDoubleBE(value{[}, offset{]}) \tn % Row Count 14 (+ 2) % Row 79 \SetRowColor{LightBackground} 64 \seqsplit{位的双精度浮点数} & buf.writeDoubleLE(value{[}, offset{]}) \tn % Row Count 16 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Buffer 迭代}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{for..of} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{buf.values()} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{buf.keys()} \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{buf.entries()} \tn % Row Count 4 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.04 cm} x{4.96 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{File}} \tn % Row 0 \SetRowColor{LightBackground} 类 & new buffer.File(sources, fileName{[}, options{]}) \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} 文件名 & file.name \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} \seqsplit{文件上次修改时间} & file.lastModified \tn % Row Count 5 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{buffer 模块 API}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{判断输入的数据是否为} ASCII 编码 & \seqsplit{buffer.isAscii(input)} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \seqsplit{判断输入的数据是否为} UTF-8 编码 & \seqsplit{buffer.isUtf8(input)} \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} 限制 Buffer 对象在 调试输出等 \seqsplit{时显示的最大字节数} & \seqsplit{buffer.INSPECT\_MAX\_BYTES} \tn % Row Count 10 (+ 4) % Row 3 \SetRowColor{white} Buffer \seqsplit{对象的最大长度} & buffer.kMaxLength \tn % Row Count 12 (+ 2) % Row 4 \SetRowColor{LightBackground} Buffer \seqsplit{对象的最大长度} & \seqsplit{buffer.constants.MAX\_LENGTH} \tn % Row Count 14 (+ 2) % Row 5 \SetRowColor{white} \seqsplit{字符串的最大长度} & \seqsplit{buffer.kStringMaxLength} \tn % Row Count 16 (+ 2) % Row 6 \SetRowColor{LightBackground} \seqsplit{字符串的最大长度} & \seqsplit{buffer.constants.MAX\_STRING\_LENGTH} \tn % Row Count 18 (+ 2) % Row 7 \SetRowColor{white} \seqsplit{将二进制数据从一个字符编码转换为另一个字符编码} & \seqsplit{buffer.transcode(source}, fromEnc, toEnc) \tn % Row Count 22 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}