Skip to content

Commit

Permalink
Add resizable ArrayBuffer examples (#2434)
Browse files Browse the repository at this point in the history
* Add resizable ArrayBuffer examples

* remove explanatory comments
  • Loading branch information
chrisdavidmills authored Mar 1, 2023
1 parent 7f7dc1d commit 56ec841
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const buffer = new ArrayBuffer(8, { maxByteLength: 16 } );

console.log(buffer.byteLength);
// Expected output: 8

console.log(buffer.maxByteLength);
// Expected output: 16
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const buffer1 = new ArrayBuffer(8, { maxByteLength: 16 } );
const buffer2 = new ArrayBuffer(8);

console.log(buffer1.resizable);
// Expected output: true

console.log(buffer2.resizable);
// Expected output: false
9 changes: 9 additions & 0 deletions live-examples/js-examples/arraybuffer/arraybuffer-resize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const buffer = new ArrayBuffer(8, { maxByteLength: 16 } );

console.log(buffer.byteLength);
// Expected output: 8

buffer.resize(12);

console.log(buffer.byteLength);
// Expected output: 12
18 changes: 18 additions & 0 deletions live-examples/js-examples/arraybuffer/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,24 @@
"title": "JavaScript Demo: ArrayBuffer.isView()",
"type": "js"
},
"arraybufferMaxByteLength": {
"exampleCode": "./live-examples/js-examples/arraybuffer/arraybuffer-maxbytelength.js",
"fileName": "arraybuffer-maxbytelength.html",
"title": "JavaScript Demo: ArrayBuffer.maxByteLength",
"type": "js"
},
"arraybufferResizable": {
"exampleCode": "./live-examples/js-examples/arraybuffer/arraybuffer-resizable.js",
"fileName": "arraybuffer-resizable.html",
"title": "JavaScript Demo: ArrayBuffer.resizable",
"type": "js"
},
"arraybufferResize": {
"exampleCode": "./live-examples/js-examples/arraybuffer/arraybuffer-resize.js",
"fileName": "arraybuffer-resize.html",
"title": "JavaScript Demo: ArrayBuffer.resize()",
"type": "js"
},
"arraybufferSlice": {
"exampleCode": "./live-examples/js-examples/arraybuffer/arraybuffer-slice.js",
"fileName": "arraybuffer-slice.html",
Expand Down

0 comments on commit 56ec841

Please sign in to comment.