Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<script>
  "use strict";
  console.clear();
  let readableController;
  const writable = new WritableStream({
    write(chunk) {
      console.log("Chunk written to writable side of transform", chunk);
      chunk = chunk.map(c => c * 10);
      readableController.enqueue(chunk);
      readableController.close();
    },
    close() {
      console.log("Writable side of transform closing");
    }
  });
  
  const readable = new ReadableStream({
    start(c) {
      readableController = c;
    }
  });
  
  const source = new ReadableStream({
    start(c) {
      c.enqueue([1, 2, 3]);
      c.close();
    }
  });
  
  const output = source.pipeThrough({ writable, readable });
  console.assert(output === readable);
  
  const reader = output.getReader();
  reader.read().then(c => {
    console.log("Reading chunk from output", c);
  });
</script>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers