invertase / dart_edge

Run Dart on the Edge - supporting Vercel & Cloudflare Workers (more coming soon).
https://docs.dartedge.dev
Apache License 2.0
324 stars 23 forks source link

feat: Refactor Response class and add new initialization methods #28

Open gaetschwartz opened 1 year ago

gaetschwartz commented 1 year ago

Changes

Motivation

jsify is subject to minification and has somewhat bad performance. When using dart compile with minification enabled, the response json gets minified (after a certain depth AFAIK). It should not be the case. The new Response.json behaves simlarly from the previous implementation except that it doesn't minify as it uses json.encode. Renamed the previous implementation to Response.jsify as it could still be useful for some cases.

Ehesp commented 1 year ago

@gaetschwartz thanks for this - what's the use case for the jsify method?

gaetschwartz commented 1 year ago

Well, as jsify can translate Dart objects to Js objects directly, people could still have some use. As it was the old behavior I figured I would leave it.

rrousselGit commented 1 year ago

I'm not really familiar with the project, but it looks alright at a quick glance.

I'd still consider this a breaking change (since the "json" constructor changes). And it'd be great to have some tests. But the project doesn't seem to have some atm, so that's alright I guess