Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Topic: js codecs #1120

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
9 changes: 9 additions & 0 deletions modules/core/js/src/main/scala/codec/AllCodecs.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) 2018-2024 by Rob Norris and Contributors
// This software is licensed under the MIT License (MIT).
// For more information see LICENSE or https://opensource.org/licenses/MIT

package skunk.scalajs.codec

trait AllCodecs extends BinaryCodecs

object all extends AllCodecs
23 changes: 23 additions & 0 deletions modules/core/js/src/main/scala/codec/BinaryCodecs.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2018-2024 by Rob Norris and Contributors
// This software is licensed under the MIT License (MIT).
// For more information see LICENSE or https://opensource.org/licenses/MIT

package skunk
package scalajs.codec

import scodec.bits.ByteVector
import skunk.data.Type
import scala.scalajs.js.typedarray.Uint8Array

trait BinaryCodecs {

val uint8array = Codec.simple[Uint8Array](
"\\x" + ByteVector.view(_).toHex,
hex => ByteVector.fromHex(hex.substring(2)).map(_.toUint8Array).toRight("Cannot decode bytes from HEX String"),
Type.bytea
)


}

object binary extends BinaryCodecs
Loading