diff --git a/.changeset/async-public-api.md b/.changeset/async-public-api.md deleted file mode 100644 index a2d8a94..0000000 --- a/.changeset/async-public-api.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -"@eridu-tech/superjson": major ---- - -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` -- `parse(string)` returns `Promise` -- `serialize(object)` returns `Promise` -- `deserialize(payload)` returns `Promise` - -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); -``` diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..3f643e2 --- /dev/null +++ b/CHANGELOG.md @@ -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` + - `parse(string)` returns `Promise` + - `serialize(object)` returns `Promise` + - `deserialize(payload)` returns `Promise` + + 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); + ``` diff --git a/package.json b/package.json index 32817aa..38859c2 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "2.2.5", + "version": "3.0.0", "license": "MIT", "type": "module", "typings": "dist/index.d.ts",