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

fix: js.Wrapper was removed in go1.19 #20

Merged
merged 2 commits into from
Nov 14, 2022
Merged
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
10 changes: 8 additions & 2 deletions indexeddb/idbblob/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,15 @@ func newBlob(buf js.Value) *Blob {
return b
}

// jsWrapper is implemented by types that are backed by a JavaScript value.
type jsWrapper interface {
// JSValue returns a JavaScript value associated with an object.
JSValue() js.Value
}

// FromBlob creates a Blob from the given blob.Blob, either wrapping the JS value or copying the bytes if incompatible.
func FromBlob(b blob.Blob) *Blob {
if b, ok := b.(js.Wrapper); ok {
if b, ok := b.(jsWrapper); ok {
return newBlob(b.JSValue())
}
buf := b.Bytes()
Expand Down Expand Up @@ -90,7 +96,7 @@ func (b *Blob) Bytes() []byte {
return buf
}

// JSValue implements js.Wrapper
// JSValue implements JSWrapper
func (b *Blob) JSValue() js.Value {
return b.jsValue.Load().(js.Value)
}
Expand Down