readable.take(limit[, options])


新增于: v17.5.0, v16.15.0
稳定性: 1 - 实验性的

\Stability: 1 - Experimental

  • limit <number> 从可读块中获取的块数。

    \limit <number> the number of chunks to take from the readable.

  • options <Object>

    • signal <AbortSignal> 如果信号中止,允许销毁流。

      \signal <AbortSignal> allows destroying the stream if the signal is aborted.

  • 返回:<Readable> 是一个带有 limit 块的流。

    \Returns: <Readable> a stream with limit chunks taken.

此方法返回一个包含前 limit 个块的新流。

\This method returns a new stream with the first limit chunks.

import { Readable } from 'node:stream';
await Readable.from([1, 2, 3, 4]).take(2).toArray(); // [1, 2] 

AltStyle によって変換されたページ (->オリジナル) /