Skip to content

Commit

Permalink
Provide a helper method to wrap an ArrayBufferView (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
niloc132 authored May 15, 2024
1 parent 10ed5ac commit 589a889
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/java/nio/ByteBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ public static ByteBuffer allocateDirect (int capacity) {
public static ByteBuffer wrapArrayBuffer(ArrayBuffer arrayBuffer) {
return new ByteBuffer(arrayBuffer);
}
public static ByteBuffer wrapArrayBuffer(ArrayBuffer arrayBuffer, int capacity, int offset) {
return new ByteBuffer(arrayBuffer, capacity, offset);
}
public ByteBuffer wrap(ArrayBuffer arrayBuffer) {
return new ByteBuffer(arrayBuffer);
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/gwtproject/nio/TypedArrayHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class TypedArrayHelper {
public static ByteBuffer wrap(ArrayBuffer ab) {
return ByteBuffer.wrapArrayBuffer(ab);
}
public static ByteBuffer wrap(ArrayBufferView ab) {
return ByteBuffer.wrapArrayBuffer(ab.buffer, ab.byteLength, ab.byteOffset);
}
public static ArrayBufferView unwrap(ByteBuffer bb) {
return bb.getTypedArray();
}
Expand Down

0 comments on commit 589a889

Please sign in to comment.