Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions .changeset/async-public-api.md

This file was deleted.

34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# @eridu-tech/superjson

## 3.0.0

### Major Changes

- 4d497bd: The public API is now asynchronous: `stringify`, `parse`, `serialize` and `deserialize` return Promises, and custom transformers may perform async work.

### Breaking changes

`SuperJSON.stringify`, `SuperJSON.parse`, `SuperJSON.serialize` and `SuperJSON.deserialize` — together with the named exports `stringify`, `parse`, `serialize`, `deserialize` — are now `async`:

- `stringify(object)` returns `Promise<string>`
- `parse<T>(string)` returns `Promise<T>`
- `serialize(object)` returns `Promise<SuperJSONResult>`
- `deserialize<T>(payload)` returns `Promise<T>`

Callers must now `await` these methods. The registration methods (`registerClass`, `registerSymbol`, `registerCustom`, `allowErrorProps`) remain synchronous.

### Custom transformers

The `CustomTransfomer` hooks (`isApplicable`, `serialize`, `deserialize`) may now return either a value or a `Promise`, so custom transformers can perform asynchronous work (for example, lazily loading a class before serializing it).

### Migration

```ts
// before
const json = superjson.stringify(object);
const parsed = superjson.parse(json);

// after
const json = await superjson.stringify(object);
const parsed = await superjson.parse(json);
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "2.2.5",
"version": "3.0.0",
"license": "MIT",
"type": "module",
"typings": "dist/index.d.ts",
Expand Down