温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.bun.com/reference/node/buffer/Buffer/write
点击访问原文链接

Buffer.write method | Node.js buffer module | Bun

Buffer.write method | Node.js buffer module | BunBuildDocsReferenceGuidesBlogDiscord/node:buffer/Buffer/writeMwrite

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/node:buffer/Buffer/writeMwrite

method

buffer.Buffer.writewrite(string: string,encoding?: BufferEncoding): number;Writes string to buf at offset according to the character encoding inencoding. The length parameter is the number of bytes to write. If buf did not contain enough space to fit the entire string, only part of string will be written. However, partially encoded characters will not be written.

import { Buffer } from 'node:buffer'; const buf = Buffer.alloc(256); const len = buf.write('\u00bd + \u00bc = \u00be', 0); console.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`); // Prints: 12 bytes: ½ + ¼ = ¾ const buffer = Buffer.alloc(10); const length = buffer.write('abcd', 8); console.log(`${length} bytes: ${buffer.toString('utf8', 8, 10)}`); // Prints: 2 bytes : ab @param stringString to write to buf.

@param encodingThe character encoding of string.

@returnsNumber of bytes written.

write(string: string,offset: number,encoding?: BufferEncoding): number;write(string: string,offset: number,length: number,encoding?: BufferEncoding): number;

Resources

ReferenceDocsGuidesDiscordMerch StoreGitHubBlog 

Toolkit

RuntimePackage managerTest runnerBundlerPackage runner

Project

Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco

We're hiring →

智能索引记录