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

Node fs.write function | API Reference | Bun

Node fs.write function | API Reference | BunBuildDocsReferenceGuidesBlogDiscord/node:fs/writeNwrite

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/node:fs/writeNwrite

namespace

fs.writefunction writeTBuffer extends ArrayBufferViewArrayBufferLike>>(fd: number,buffer: TBuffer,offset?: null | number,length?: null | number,position?: null | number,callback: (err: null | ErrnoException, written: number, buffer: TBuffer) => void): void;

Write buffer to the file specified by fd.

offset determines the part of the buffer to be written, and length is an integer specifying the number of bytes to write.

position refers to the offset from the beginning of the file where this data should be written. If typeof position !== 'number', the data will be written at the current position. See pwrite(2).

The callback will be given three arguments (err, bytesWritten, buffer) where bytesWritten specifies how many bytes were written from buffer.

If this method is invoked as its util.promisify() ed version, it returns a promise for an Object with bytesWritten and buffer properties.

It is unsafe to use fs.write() multiple times on the same file without waiting for the callback. For this scenario, createWriteStream is recommended.

On Linux, positional writes don't work when the file is opened in append mode. The kernel ignores the position argument and always appends the data to the end of the file.

function writeTBuffer extends ArrayBufferViewArrayBufferLike>>(fd: number,buffer: TBuffer,offset: undefined | null | number,length: undefined | null | number,callback: (err: null | ErrnoException, written: number, buffer: TBuffer) => void): void;

Asynchronously writes buffer to the file referenced by the supplied file descriptor.

@param fd

A file descriptor.

@param offset

The part of the buffer to be written. If not supplied, defaults to 0.

@param length

The number of bytes to write. If not supplied, defaults to buffer.length - offset.

function writeTBuffer extends ArrayBufferViewArrayBufferLike>>(fd: number,buffer: TBuffer,offset: undefined | null | number,callback: (err: null | ErrnoException, written: number, buffer: TBuffer) => void): void;

Asynchronously writes buffer to the file referenced by the supplied file descriptor.

@param fd

A file descriptor.

@param offset

The part of the buffer to be written. If not supplied, defaults to 0.

function writeTBuffer extends ArrayBufferViewArrayBufferLike>>(fd: number,buffer: TBuffer,callback: (err: null | ErrnoException, written: number, buffer: TBuffer) => void): void;

Asynchronously writes buffer to the file referenced by the supplied file descriptor.

@param fd

A file descriptor.

function writeTBuffer extends ArrayBufferViewArrayBufferLike>>(fd: number,buffer: TBuffer,options: WriteOptions,callback: (err: null | ErrnoException, written: number, buffer: TBuffer) => void): void;

Asynchronously writes buffer to the file referenced by the supplied file descriptor.

@param fd

A file descriptor.

@param options

An object with the following properties:

offset The part of the buffer to be written. If not supplied, defaults to 0.length The number of bytes to write. If not supplied, defaults to buffer.length - offset.position The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.
function write(fd: number,string: string,position: undefined | null | number,encoding: undefined | null | BufferEncoding,callback: (err: null | ErrnoException, written: number, str: string) => void): void;

Asynchronously writes string to the file referenced by the supplied file descriptor.

@param fd

A file descriptor.

@param string

A string to write.

@param position

The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.

@param encoding

The expected string encoding.

function write(fd: number,string: string,position: undefined | null | number,callback: (err: null | ErrnoException, written: number, str: string) => void): void;

Asynchronously writes string to the file referenced by the supplied file descriptor.

@param fd

A file descriptor.

@param string

A string to write.

@param position

The offset from the beginning of the file where this data should be written. If not supplied, defaults to the current position.

function write(fd: number,string: string,callback: (err: null | ErrnoException, written: number, str: string) => void): void;

Asynchronously writes string to the file referenced by the supplied file descriptor.

@param fd

A file descriptor.

@param string

A string to write.

namespace write

Resources

ReferenceDocsGuidesDiscordMerch StoreGitHubBlog 

Toolkit

RuntimePackage managerTest runnerBundlerPackage runner

Project

Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicense

Baked with ❤️ in San Francisco

We're hiring →

Node fs.write function | API Reference | Bun,AI智能索引,全网链接索引,智能导航,网页索引

    API documentation for namespace node:fs.write | Bun