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

Socket.reduce method | Node.js net module | Bun

Socket.reduce method | Node.js net module | BunBuildDocsReferenceGuidesBlogDiscord/node:net/Socket/reduceMreduce

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/node:net/Socket/reduceMreduce

method

net.Socket.reducereduceT>(fn: (previous: any, data: any, options?: Abortable) => T): PromiseT>;

This method calls fn on each chunk of the stream in order, passing it the result from the calculation on the previous element. It returns a promise for the final value of the reduction.

If no initial value is supplied the first chunk of the stream is used as the initial value. If the stream is empty, the promise is rejected with a TypeError with the ERR_INVALID_ARGS code property.

The reducer function iterates the stream element-by-element which means that there is no concurrency parameter or parallelism. To perform a reduce concurrently, you can extract the async function to readable.map method.

@param fn

a reducer function to call over every chunk in the stream. Async or not.

@returns

a promise for the final value of the reduction.

reduceT>(fn: (previous: T, data: any, options?: Abortable) => T,initial: T,options?: Abortable): PromiseT>;

This method calls fn on each chunk of the stream in order, passing it the result from the calculation on the previous element. It returns a promise for the final value of the reduction.

If no initial value is supplied the first chunk of the stream is used as the initial value. If the stream is empty, the promise is rejected with a TypeError with the ERR_INVALID_ARGS code property.

The reducer function iterates the stream element-by-element which means that there is no concurrency parameter or parallelism. To perform a reduce concurrently, you can extract the async function to readable.map method.

@param fn

a reducer function to call over every chunk in the stream. Async or not.

@param initial

the initial value to use in the reduction.

@returns

a promise for the final value of the reduction.

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 →

Socket.reduce method | Node.js net module | Bun,AI智能索引,全网链接索引,智能导航,网页索引

    API documentation for method node:net.Socket.reduce | Bun