Skip to content

Commit

Permalink
Add typescript code sample to buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
bhelx committed Sep 13, 2024
1 parent abda87c commit 3a1bfcf
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,18 @@ exports:
contentType: application/json
$ref: "#/components/schemas/KitchenSinkObject"
codeSamples:
- lang: typescript
source: |-
const encoder = new TextEncoder()
const oldBytes = encoder.encode("Hello")
const newBytes = encoder.encode("Goodbye")
const bufferView = new Uint8Array(input.aBuffer)
const newBuffer = new ArrayBuffer(newBytes.length + bufferView.length - oldBytes.length)
const newBufferView = new Uint8Array(newBuffer)
newBufferView.set(newBytes, 0)
newBufferView.set(bufferView.subarray(oldBytes.length), newBytes.length)
input.aBuffer = newBuffer
return input
- lang: go
source: |-
old := []byte("Hello")
Expand Down

0 comments on commit 3a1bfcf

Please sign in to comment.