Spaces:
Running
Running
fix: more types
Browse files- packages/web/src/record.ts +11 -4
packages/web/src/record.ts
CHANGED
|
@@ -350,10 +350,17 @@ export class LeRobotDatasetRecorder {
|
|
| 350 |
* to an ArrayBuffer with correct bounds and ArrayBuffer typing.
|
| 351 |
*/
|
| 352 |
private static toArrayBuffer(uint8: Uint8Array): ArrayBuffer {
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 357 |
}
|
| 358 |
|
| 359 |
constructor(
|
|
|
|
| 350 |
* to an ArrayBuffer with correct bounds and ArrayBuffer typing.
|
| 351 |
*/
|
| 352 |
private static toArrayBuffer(uint8: Uint8Array): ArrayBuffer {
|
| 353 |
+
const buffer = uint8.buffer;
|
| 354 |
+
if (buffer instanceof ArrayBuffer) {
|
| 355 |
+
return buffer.slice(
|
| 356 |
+
uint8.byteOffset,
|
| 357 |
+
uint8.byteOffset + uint8.byteLength
|
| 358 |
+
);
|
| 359 |
+
}
|
| 360 |
+
// Handle SharedArrayBuffer case by copying to ArrayBuffer
|
| 361 |
+
const arrayBuffer = new ArrayBuffer(uint8.byteLength);
|
| 362 |
+
new Uint8Array(arrayBuffer).set(uint8);
|
| 363 |
+
return arrayBuffer;
|
| 364 |
}
|
| 365 |
|
| 366 |
constructor(
|