fix: serializable url

This commit is contained in:
orion 2023-12-23 19:30:49 -06:00
parent 939f6d1dcd
commit 1f4995a2d1
Signed by: orion
GPG Key ID: 6D4165AE4C928719
3 changed files with 639 additions and 5775 deletions

6405
spago.lock

File diff suppressed because it is too large Load Diff

View File

@ -17,6 +17,7 @@ package:
- maybe - maybe
- node-event-emitter - node-event-emitter
- node-streams - node-streams
- node-url
- nullable - nullable
- ordered-collections - ordered-collections
- prelude - prelude
@ -27,5 +28,4 @@ package:
workspace: workspace:
extra_packages: {} extra_packages: {}
package_set: package_set:
url: https://raw.githubusercontent.com/purescript/package-sets/psc-0.15.10-20230930/packages.json registry: 47.7.1
hash: sha256-nTsd44o7/hrTdk0c6dh0wyBqhFFDJJIeKdQU6L1zv/A=

View File

@ -15,6 +15,7 @@ import Foreign (Foreign, readArray, readBoolean, readInt, readNullOrUndefined, r
import Foreign.Index (readProp) import Foreign.Index (readProp)
import Foreign.Object (Object) import Foreign.Object (Object)
import JS.BigInt (BigInt) import JS.BigInt (BigInt)
import Node.URL (URL)
import Prim.Row as Row import Prim.Row as Row
import Prim.RowList (class RowToList, Cons, Nil, RowList) import Prim.RowList (class RowToList, Cons, Nil, RowList)
import Record (get) import Record (get)
@ -36,6 +37,10 @@ instance Serializable String where
serialize = unsafeToForeign serialize = unsafeToForeign
deserialize = lmap show <<< runExcept <<< readString deserialize = lmap show <<< runExcept <<< readString
instance Serializable URL where
serialize = unsafeToForeign
deserialize = lmap show <<< runExcept <<< unsafeReadTagged "URL"
instance Serializable Int where instance Serializable Int where
serialize = unsafeToForeign serialize = unsafeToForeign
deserialize = lmap show <<< runExcept <<< readInt deserialize = lmap show <<< runExcept <<< readInt