shareSync(source[, options])


  • source <Iterable> 要共享的同步源。
  • options <Object>
    • budget <number> 必须 >= 16384。 默认值: 65536。
    • backpressure <string> 'strict'、'drop-oldest' 或 'drop-newest'。 默认值: 'strict'。
  • 返回:SyncShare

share() 的同步版本。

🌐 Synchronous version of share().

因为在同步上下文中无法等待,'unbounded' 不被支持,会抛出 ERR_INVALID_ARG_VALUE。使用 'drop-newest' 时,当消费者在预算耗尽时到达缓冲区末尾,会丢弃源中的一条条目,然后返回没有值的 { done: true };消费者不会被分离,因此一旦最慢的消费者前进并释放预算,它可以继续运行。

🌐 Because there is no way to wait in a synchronous context, 'unbounded' is not supported and throws ERR_INVALID_ARG_VALUE. With 'drop-newest', a consumer that reaches the end of the buffer while the budget is exhausted discards a single entry from the source and then returns { done: true } without a value; the consumer is not detached, so it can resume once the slowest consumer advances and releases budget.