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

Non-working example of Typed Arrays #127

Open
oldium opened this issue Jan 21, 2020 · 0 comments
Open

Non-working example of Typed Arrays #127

oldium opened this issue Jan 21, 2020 · 0 comments

Comments

@oldium
Copy link

oldium commented Jan 21, 2020

There is a problem in the following example:

es6-features/features.txt

Lines 1340 to 1362 in 75bf0b4

6| class Example {
6| constructor (buffer = |new ArrayBuffer(24)|) {
6| this.buffer = buffer;
6| }
6| set buffer (buffer) {
6| this._buffer = buffer;
6| this._id = |new Uint32Array (this._buffer, 0, 1)|;
6| this._username = |new Uint8Array (this._buffer, 4, 16)|;
6| this._amountDue = |new Float32Array(this._buffer, 20, 1)|;
6| }
6| get buffer () { return this._buffer; }
6| set id (v) { this._id[0] = v; }
6| get id () { return this._id[0]; }
6| set username (v) { this._username[0] = v; }
6| get username () { return this._username[0]; }
6| set amountDue (v) { this._amountDue[0] = v; }
6| get amountDue () { return this._amountDue[0]; }
6| }
6|
6| let example = new Example()
6| example.|id| = 7
6| example.|username| = "John Doe"
6| example.|amountDue| = 42.0

Manipulating username on line 1361/1353 cannot work. The username is UI8 array and the setter just manipulates the first byte only.

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

1 participant