GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — stream: create the stream/iter share() read reaction once per consumer · nodejs/node@97b7504

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/streams/iter
    • share.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/streams/iter/share.js‎

Copy file name to clipboardExpand all lines: lib/internal/streams/iter/share.js
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,15 @@ class ShareImpl {
408408
// longer pending: clear it from pendingNext, unless a next() has been
409409
// queued behind it, without a reaction of its own.
410410
#readAfterPull(state) {
411-
state.afterPull ??= () => {
411+
// afterPull() is created by a method of its own: if it were created
412+
// here, V8 would allocate the context it captures on every call, even
413+
// when it already exists.
414+
state.afterPull ??= this.#createAfterPull(state);
415+
return PromisePrototypeThen(this.#pullFromSource(false), state.afterPull);
416+
}
417+
418+
#createAfterPull(state) {
419+
return () => {
412420
let result;
413421
try {
414422
result = this.#tryRead(state);
@@ -426,7 +434,6 @@ class ShareImpl {
426434
this.#clearWaitingRead(state);
427435
return result;
428436
};
429-
return PromisePrototypeThen(this.#pullFromSource(false), state.afterPull);
430437
}
431438

432439
#clearWaitingRead(state) {

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.