Skip to content

Commit 72e35c0

Browse files
committed
serialize can raise
1 parent d5eb1a8 commit 72e35c0

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

jscomp/others/js_json.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ let patch : _ -> _ = [%raw{|function (json) {
174174
|}]
175175

176176

177-
let serialize (type t) (x : t) : string option = [%raw{| function(obj){
177+
let serializeExn (type t) (x : t) : string option = [%raw{| function(obj){
178178
return JSON.stringify(obj,function(_,value){
179179
if(value===undefined){
180180
return {RE_PRIVATE_NONE : true}

jscomp/others/js_json.mli

+3-3
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@ Js.log \@\@ Js.Json.stringifyAny [| "foo"; "bar" |]
236236
*)
237237

238238

239-
239+
(** Best-effort serialization, it tries to seralize as
240+
many objects as possible and deserialize it back*)
240241

241242
val deserializeExn : string -> 'a
242243

243-
(** Best-effort serialization, it tries to seralize as many objects as possible and deserialize it back*)
244-
val serialize : 'a -> string option
244+
val serializeExn : 'a -> string option

jscomp/test/js_json_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ eq("File \"js_json_test.ml\", line 388, characters 5-12", Js_json.decodeNull({})
737737
eq("File \"js_json_test.ml\", line 390, characters 5-12", Js_json.decodeNull(1.23), undefined);
738738

739739
function id(obj) {
740-
var x = Js_json.serialize(obj);
740+
var x = Js_json.serializeExn(obj);
741741
if (x !== undefined) {
742742
return Js_json.deserializeExn(x);
743743
}

jscomp/test/js_json_test.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ let () =
392392

393393

394394
let id (type t ) (obj : t) : t =
395-
match J.serialize obj with
395+
match J.serializeExn obj with
396396
| None -> assert false
397397
| Some x -> J.deserializeExn x
398398

lib/es6/js_json.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ var patch = (function (json) {
136136
return x[0];
137137
});
138138

139-
function serialize(x) {
139+
function serializeExn(x) {
140140
return (function(obj){
141141
return JSON.stringify(obj,function(_,value){
142142
if(value===undefined){
@@ -161,7 +161,7 @@ export {
161161
decodeBoolean ,
162162
decodeNull ,
163163
deserializeExn ,
164-
serialize ,
164+
serializeExn ,
165165

166166
}
167167
/* No side effect */

lib/js/js_json.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ var patch = (function (json) {
136136
return x[0];
137137
});
138138

139-
function serialize(x) {
139+
function serializeExn(x) {
140140
return (function(obj){
141141
return JSON.stringify(obj,function(_,value){
142142
if(value===undefined){
@@ -160,5 +160,5 @@ exports.decodeArray = decodeArray;
160160
exports.decodeBoolean = decodeBoolean;
161161
exports.decodeNull = decodeNull;
162162
exports.deserializeExn = deserializeExn;
163-
exports.serialize = serialize;
163+
exports.serializeExn = serializeExn;
164164
/* No side effect */

0 commit comments

Comments
 (0)