-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
15 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (C) 2024 Toitware ApS. All rights reserved. | ||
// Use of this source code is governed by an MIT-style license that can be | ||
// found in the LICENSE file. | ||
import io | ||
|
||
io-data-to-byte-array_ data/io.Data from/int=0 to/int=data.byte-size -> ByteArray: | ||
if data is ByteArray: | ||
byte-array := data as ByteArray | ||
if from == 0 and to == byte-array.size: return byte-array | ||
return byte-array[from..to] | ||
|
||
byte-array := ByteArray (to - from) | ||
data.write-to-byte-array byte-array --at=0 from to | ||
return byte-array |