Skip to content

feat: make Array.buffer public #1815

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

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion std/assembly/array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class Array<T> {
// `dataStart` (equals `buffer`) and `byteLength` (equals computed `buffer.byteLength`), but the
// block is 16 bytes anyway so it's fine to have a couple extra fields in there.

private buffer: ArrayBuffer;
readonly buffer: ArrayBuffer;
private dataStart: usize;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MaxGraey Isn't it private now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, good point. In ArrayBufferView it's currently public. So I guess better make this public as well and add @unsafe decorator. @dcodeIO wdyt?

private byteLength: i32;

Expand Down
3 changes: 2 additions & 1 deletion std/assembly/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1575,11 +1575,12 @@ declare class Array<T> {
static isArray<U>(value: any): value is Array<any>;

[key: number]: T;
/** The {@link ArrayBuffer} referenced by this view. */
readonly buffer: ArrayBuffer;
/** Current length of the array. */
length: i32;
/** Constructs a new array. */
constructor(capacity?: i32);

at(index: i32): T;
fill(value: T, start?: i32, end?: i32): this;
every(callbackfn: (element: T, index: i32, array?: Array<T>) => bool): bool;
Expand Down