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

arrayBuffer is not an instance of ArrayBuffer #26

Open
TMTHY opened this issue May 29, 2019 · 2 comments
Open

arrayBuffer is not an instance of ArrayBuffer #26

TMTHY opened this issue May 29, 2019 · 2 comments

Comments

@TMTHY
Copy link

TMTHY commented May 29, 2019

Sometimes, in some browsers (usually old ones), calling untar from GWT client, produces exception "arrayBuffer is not an instance of ArrayBuffer."

In that part of code:

function function untar(arrayBuffer) {
	if (!(arrayBuffer instanceof ArrayBuffer)) {
		throw new TypeError("arrayBuffer is not an instance of ArrayBuffer.");
        }
...
}

Object passed to untar is actually ArrayBuffer, Chrome debugger shows that is ArrayBuffer, but "instanceof ArrayBuffer" returns false. When you remove lines with the type check, everything is working fine.

May be another version on the function can be introduced (untarUnchecked), without type checking?

@Qvazar
Copy link
Member

Qvazar commented May 29, 2019

A better fix would be to remove the instanceof check and use 🦆 typing instead.
If it has the required methods of an ArrayBuffer, it probably is an ArrayBuffer.

@TMTHY
Copy link
Author

TMTHY commented May 29, 2019

Yes, duck typing would be a good solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants