Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@phryneas/turbo-stream

jacob-ebey202ISC2.4.1-pr.51.1.d24f66eTypeScript support: included

A streaming data transport format that aims to support built-in features such as Promises, Dates, RegExps, Maps, Sets and more.

devalue, turbo, stream, enhanced, json

readme

Turbo Stream
turbo-stream's badge

A streaming data transport format that aims to support built-in features such as Promises, Dates, RegExps, Maps, Sets and more.

Decode runtime size: turbo-stream's badge

Shout Out!

Shout out to Rich Harris and his https://github.com/rich-harris/devalue project. Devalue has heavily influenced this project and portions of the code have been directly lifted from it. I highly recommend checking it out if you need something more cusomizable or without streaming support.

Installation

npm install turbo-stream

Usage

import { decode, encode } from "turbo-stream";

const encodedStream = encode(Promise.resolve(42));
const decoded = await decode(encodedStream);
console.log(decoded.value); // a Promise
console.log(await decoded.value); // 42
await decoded.done; // wait for the stream to finish

Stackblitz: https://stackblitz.com/edit/stackblitz-starters-2wm7dh?file=index.js React SSR Example: https://github.com/jacob-ebey/turbo-stream-react-example

changelog

Changelog

3.1.0 (2025-02-07)

Features

  • allow for custom error redaction (#68) (e128d83)

3.0.1 (2025-02-05)

Bug Fixes

3.0.0 (2025-02-04)

⚠ BREAKING CHANGES

  • new encoding format (#59)

Features

2.4.1 (2024-09-11)

Bug Fixes

  • address memory leak caused by too many event listeners on AbortSignal (#49) (628504e)

2.4.0 (2024-08-17)

Features

  • add postPlugins for encode to handle any values that can not be handled natively or by other plugins (#47) (5fc83c8)

2.3.0 (2024-08-12)

Features

2.2.3 (2024-08-11)

Bug Fixes

  • push one value at a time to avoid stack overflows (#43) (88c51a7)

2.2.2 (2024-08-10)

Bug Fixes

  • support "infinitely" large payloads (#41) (8b602a3)

2.2.1 (2024-08-09)

Bug Fixes

  • encoding of previously-used values (#38) (84520be)

2.2.0 (2024-06-04)

Features

  • allow plugins to custom encode functions (#34) (6bd197a)

2.1.0 (2024-05-30)

Features

  • support pre resolved / rejected promises (#32) (3f15f99)

Bug Fixes

2.0.1 (2024-04-29)

Bug Fixes

  • subsequent null and undefined encoding failure (#24) (47adfe1)

2.0.0 (2024-03-06)

⚠ BREAKING CHANGES

  • add abort signal (#21)

Features

1.2.1 (2024-02-15)

Bug Fixes

1.2.0 (2023-11-01)

Features

1.1.1 (2023-11-01)

Bug Fixes

1.1.0 (2023-10-27)

Features

1.0.4 (2023-10-27)

Bug Fixes

  • add support for URL encoding and decoding (#10) (acf9ae1)

1.0.3 (2023-10-26)

Bug Fixes

1.0.2 (2023-10-26)

Bug Fixes

  • add sideEffects: false to pkg json (#6) (ad7b842)

1.0.1 (2023-10-26)

Features

  • add release pipeline to the repository (db40f74)
  • encode errors and promise rejections (fa120e9)
  • minify things (1db51bf)
  • support null prototype objects (27b3ece)

Bug Fixes

  • add repository to package.json (#4) (9ae3518)

Miscellaneous Chores

1.0.0 (2023-10-26)

Welcome to turbo-stream, a streaming data transport format that aims to support built-in features such as Promises, Dates, RegExps, Maps, Sets and more.

Shout out to Rich Harris and his https://github.com/rich-harris/devalue project. Devalue has heavily influenced this project and portions of the code have been directly lifted from it. I highly recommend checking it out if you need something more cusomizable or without streaming support.

Features

  • initial release