File tree Expand file tree Collapse file tree 4 files changed +41
-0
lines changed Expand file tree Collapse file tree 4 files changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ # dev
2+
3+ ## Features/Changes
4+
5+ * Library: new Typed_array.Bytes module.
6+
17# 5.8.0 (2024-04-20) - Lille
28
39## Features/Changes
Original file line number Diff line number Diff line change 11#include <caml/misc.h>
22
3+ void caml_bytes_of_array () {
4+ caml_fatal_error ("Unimplemented Javascript primitive caml_bytes_of_array!" );
5+ }
6+
37void caml_js_error_of_exception () {
48 caml_fatal_error ("Unimplemented Javascript primitive caml_js_error_of_exception!" );
59}
@@ -20,6 +24,10 @@ void caml_js_on_ie () {
2024 caml_fatal_error ("Unimplemented Javascript primitive caml_js_on_ie!" );
2125}
2226
27+ void caml_uint8_array_of_bytes () {
28+ caml_fatal_error ("Unimplemented Javascript primitive caml_uint8_array_of_bytes!" );
29+ }
30+
2331void caml_xmlhttprequest_create () {
2432 caml_fatal_error ("Unimplemented Javascript primitive caml_xmlhttprequest_create!" );
2533}
Original file line number Diff line number Diff line change @@ -261,3 +261,13 @@ module String = struct
261261 let uint8 = new % js uint8Array_fromBuffer ab in
262262 of_uint8Array uint8
263263end
264+
265+ module Bytes = struct
266+ external of_uint8Array : uint8Array Js .t -> bytes = " caml_bytes_of_array"
267+
268+ external to_uint8Array : bytes -> uint8Array Js .t = " caml_uint8_array_of_bytes"
269+
270+ let of_arrayBuffer ab =
271+ let uint8 = new % js uint8Array_fromBuffer ab in
272+ of_uint8Array uint8
273+ end
Original file line number Diff line number Diff line change @@ -254,3 +254,20 @@ module String : sig
254254
255255 val of_uint8Array : uint8Array Js .t -> string
256256end
257+
258+ module Bytes : sig
259+ val of_uint8Array : uint8Array Js .t -> bytes
260+ (* * This efficiently converts a typed array to [bytes] because it will usually
261+ not copy its input.
262+
263+ Modifying its input may also modify its output, and vice versa when
264+ modifying its output. This is not a guarantee, however, since certain
265+ [bytes] operations may require the runtime to make a copy. One should not
266+ use this on input that is sensitive to modification. *)
267+
268+ val to_uint8Array : bytes -> uint8Array Js .t
269+ (* * See the words of caution for {!of_uint8Array}. *)
270+
271+ val of_arrayBuffer : arrayBuffer Js .t -> bytes
272+ (* * See the words of caution for {!of_uint8Array}. *)
273+ end
You can’t perform that action at this time.
0 commit comments