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

Node fs.readFileSync function | API Reference | Bun

Node fs.readFileSync function | API Reference | BunBuildDocsReferenceGuidesBlogDiscord/node:fs/readFileSyncFreadFileSync

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/node:fs/readFileSyncFreadFileSync

function

fs.readFileSync'); // => [Error: EISDIR: illegal operation on a directory, read ] // FreeBSD readFileSync(''); // => ```" data-algolia-static="false" data-algolia-merged="false" data-type="Function">function readFileSync(path: PathOrFileDescriptor,options?: null | { encoding: null; flag: string }): NonSharedBuffer;

Returns the contents of the path.

For detailed information, see the documentation of the asynchronous version of this API: readFile.

If the encoding option is specified then this function returns a string. Otherwise it returns a buffer.

Similar to readFile, when the path is a directory, the behavior of fs.readFileSync() is platform-specific.

import { readFileSync } from 'node:fs';

// macOS, Linux, and Windows
readFileSync('');
// => [Error: EISDIR: illegal operation on a directory, read ]

// FreeBSD
readFileSync(''); // =>
@param path

filename or file descriptor

function readFileSync(path: PathOrFileDescriptor,options: BufferEncoding | { encoding: BufferEncoding; flag: string }): string;

Synchronously reads the entire contents of a file.

@param path

A path to a file. If a URL is provided, it must use the file: protocol. If a file descriptor is provided, the underlying file will not be closed automatically.

@param options

Either the encoding for the result, or an object that contains the encoding and an optional flag. If a flag is not provided, it defaults to 'r'.

function readFileSync(path: PathOrFileDescriptor,options?: null | BufferEncoding | ObjectEncodingOptions & { flag: string }): string | NonSharedBuffer;

Synchronously reads the entire contents of a file.

@param path

A path to a file. If a URL is provided, it must use the file: protocol. If a file descriptor is provided, the underlying file will not be closed automatically.

@param options

Either the encoding for the result, or an object that contains the encoding and an optional flag. If a flag is not provided, it defaults to 'r'.

Referenced typestype PathOrFileDescriptor = PathLike | numberinterface ObjectEncodingOptionsencoding?: null | BufferEncoding

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.readFileSync function | API Reference | Bun,AI智能索引,全网链接索引,智能导航,网页索引

    API documentation for function node:fs.readFileSync | Bun