diff --git a/CHANGELOG.md b/CHANGELOG.md index 74e9abbbe6c..215202b085f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ #### :boom: Breaking Change +- Remove the deprecated `Js` namespace and its runtime modules. https://github.com/rescript-lang/rescript/pull/8531 + #### :eyeglasses: Spec Compliance #### :rocket: New Feature diff --git a/analysis/reanalyze/src/exn_lib.ml b/analysis/reanalyze/src/exn_lib.ml index f6ce02723f4..ce39c97dc97 100644 --- a/analysis/reanalyze/src/exn_lib.ml +++ b/analysis/reanalyze/src/exn_lib.ml @@ -195,7 +195,6 @@ let raises_lib_table : (Name.t, Exceptions.t) Hashtbl.t = ("Error", stdlib_error); ("Exn", stdlib_exn); ("JsError", stdlib_js_error); - ("Js.Json", [("parseExn", [js_exn])]); ("JSON", stdlib_json); ("Json_decode", bs_json); ("Json.Decode", bs_json); diff --git a/analysis/src/completion_front_end.ml b/analysis/src/completion_front_end.ml index 31f6dc52076..b1562a608cc 100644 --- a/analysis/src/completion_front_end.ml +++ b/analysis/src/completion_front_end.ml @@ -328,13 +328,13 @@ let complete_pipe_chain ~(in_jsx_context : bool) (exp : Parsetree.expression) = (* Complete the end of pipe chains by reconstructing the pipe chain as a single pipe, so it can be completed. Example: - someArray->Js.Array2.filter(v => v > 10)->Js.Array2.map(v => v + 2)-> + someArray->Array.filter(v => v > 10)->Array.map(v => v + 2)-> will complete as: - Js.Array2.map(someArray->Js.Array2.filter(v => v > 10), v => v + 2)-> + Array.map(someArray->Array.filter(v => v > 10), v => v + 2)-> *) match exp.pexp_desc with (* When the left side of the pipe we're completing is a function application. - Example: someArray->Js.Array2.map(v => v + 2)-> *) + Example: someArray->Array.map(v => v + 2)-> *) | Pexp_apply { funct = {pexp_desc = Pexp_ident {txt = Lident "->"}}; diff --git a/compiler/core/design.md b/compiler/core/design.md index 567a8dce77c..a0c0b46d051 100644 --- a/compiler/core/design.md +++ b/compiler/core/design.md @@ -5,7 +5,7 @@ - printing ```ocaml -Js.log true +Console.log true ``` - pattern match diff --git a/compiler/core/destruct_exn.md b/compiler/core/destruct_exn.md index 81e6667d8d4..bf6c05aba27 100644 --- a/compiler/core/destruct_exn.md +++ b/compiler/core/destruct_exn.md @@ -11,7 +11,7 @@ However it does not prevent things like ```ocaml destruct v begin fun exn -> - Js.log exn ; + Console.log exn ; match exn with | .. | .. @@ -44,7 +44,7 @@ Another proposal is match%exn computation with | A .. | B .. -| Js.NonCamlOpenVariant .. +| JsExn .. | v -> .. ``` @@ -53,7 +53,7 @@ Here we pack the data `v` ==> ``` -match (Js_enx.internalTOOCamlException compuation) with +match (Primitive_exceptions.internalToException computation) with | A .. | B | exception .. ) @@ -62,7 +62,7 @@ match (Js_enx.internalTOOCamlException compuation) with The same problem is ``` -match (Js_enx.internalTOOCamlException compuation) with +match (Primitive_exceptions.internalToException computation) with | _ -> .. ``` @@ -76,6 +76,6 @@ Another very similar proposal would be ```ocaml fun[@bs:exn] e -> match e with - | Js.Exn.Error .. + | JsExn .. | .. -``` \ No newline at end of file +``` diff --git a/compiler/core/lam_convert.ml b/compiler/core/lam_convert.ml index fa963206e96..13193e36869 100644 --- a/compiler/core/lam_convert.ml +++ b/compiler/core/lam_convert.ml @@ -37,13 +37,13 @@ let lam_extension_id loc (head : Lam.t) = ]} we approximate that if [id] is destructed or not. If it is destructed, we need pack it in case it is JS exception. - The packing is called Js.Exn.internalTOOCamlException, which is a nop for OCaml exception, + The packing is called Primitive_exceptions.internalToException, which is a nop for OCaml exception, but will wrap as (Error e) when it is an JS exception. {[ try .. with | A (x,y) -> - | Js.Error .. + | Exn.Error .. ]} Without such wrapping, the code above would raise diff --git a/compiler/core/outcome_printer_ns.ml b/compiler/core/outcome_printer_ns.ml index 9ded0bf3b71..6163bf3433e 100644 --- a/compiler/core/outcome_printer_ns.ml +++ b/compiler/core/outcome_printer_ns.ml @@ -27,26 +27,6 @@ let ps = Format.pp_print_string let out_ident ppf s = ps ppf (match s with - | "Js_null" -> "Js.Null" - | "Js_undefined" -> "Js.Undefined" - | "Js_null_undefined" -> "Js.Nullable" - | "Js_exn" -> "Js.Exn" - | "Js_array" -> "Js.Array" - | "Js_string" -> "Js.String" - | "Js_re" -> "Js.Re" - | "Js_promise" -> "Js.Promise" - | "Js_date" -> "Js.Date" - | "Js_dict" -> "Js.Dict" - | "Js_global" -> "Js.Global" - | "Js_json" -> "Js.Json" - | "Js_math" -> "Js.Math" - | "Js_obj" -> "Js.Obj" - | "Js_typed_array" -> "Js.Typed_array" - | "Js_types" -> "Js.Types" - | "Js_float" -> "Js.Float" - | "Js_int" -> "Js.Int" - | "Js_option" -> "Js.Option" - | "Js_result" -> "Js.Result" (* Belt_libs *) | "Belt_Id" -> "Belt.Id" | "Belt_Array" -> "Belt.Array" diff --git a/compiler/ext/primitive_modules.ml b/compiler/ext/primitive_modules.ml index b11bc8766af..bff1d8b58a4 100644 --- a/compiler/ext/primitive_modules.ml +++ b/compiler/ext/primitive_modules.ml @@ -52,4 +52,6 @@ let curry = "Primitive_curry" let util = "Primitive_util" +let js_extern = "Primitive_js_extern" + let pervasives = "Pervasives" diff --git a/compiler/frontend/ast_core_type.mli b/compiler/frontend/ast_core_type.mli index dfa1f017526..82f04e828b6 100644 --- a/compiler/frontend/ast_core_type.mli +++ b/compiler/frontend/ast_core_type.mli @@ -34,7 +34,7 @@ val from_labels : loc:Location.t -> int -> string Asttypes.loc list -> t (** return a function type [from_labels ~loc tyvars labels] example output: - {[x:'a0 -> y:'a1 -> < x :'a0 ;y :'a1 > Js.t]} + {[x:'a0 -> y:'a1 -> < x :'a0 ;y :'a1 >]} *) val make_obj : loc:Location.t -> Parsetree.object_field list -> t diff --git a/compiler/frontend/ast_exp_handle_external.ml b/compiler/frontend/ast_exp_handle_external.ml index 73818242f31..375d5e98bc0 100644 --- a/compiler/frontend/ast_exp_handle_external.ml +++ b/compiler/frontend/ast_exp_handle_external.ml @@ -22,50 +22,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -(** - {[ - Js.undefinedToOption - (if Js.typeof x = "undefined" then undefined - else x ) - - ]} - - @deprecated -*) -let handle_external loc (x : string) : Parsetree.expression = - let raw_exp : Ast_exp.t = - let str_exp = - Ast_compatible.const_exp_string ~loc x ~delimiter:Ext_string.empty - in - { - str_exp with - pexp_desc = - Ast_external_mk.local_external_apply loc ~pval_prim:["#raw_expr"] - ~pval_type: - (Ast_helper.Typ.arrows - [{attrs = []; lbl = Nolabel; typ = Ast_helper.Typ.any ()}] - (Ast_helper.Typ.any ())) - [str_exp]; - } - in - let empty = - (* FIXME: the empty delimiter does not make sense*) - Ast_helper.Exp.ident ~loc - {txt = Ldot (Ldot (Lident "Js", "Undefined"), "empty"); loc} - in - let undefined_typeof = - Ast_helper.Exp.ident {loc; txt = Ldot (Lident "Js", "undefinedToOption")} - in - let typeof = Ast_helper.Exp.ident {loc; txt = Ldot (Lident "Js", "typeof")} in - - Ast_compatible.app1 ~loc undefined_typeof - (Ast_helper.Exp.ifthenelse ~loc - (Ast_compatible.app2 ~loc - (Ast_helper.Exp.ident ~loc {loc; txt = Lident "=="}) - (Ast_compatible.app1 ~loc typeof raw_exp) - (Ast_compatible.const_exp_string ~loc "undefined")) - empty (Some raw_exp)) - let handle_debugger loc (payload : Ast_payload.t) = match payload with | PStr [] -> diff --git a/compiler/frontend/ast_exp_handle_external.mli b/compiler/frontend/ast_exp_handle_external.mli index c3ff047268c..74829c3547c 100644 --- a/compiler/frontend/ast_exp_handle_external.mli +++ b/compiler/frontend/ast_exp_handle_external.mli @@ -22,8 +22,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -val handle_external : Location.t -> string -> Parsetree.expression - val handle_debugger : Location.t -> Ast_payload.t -> Parsetree.expression_desc val handle_ffi : loc:Location.t -> payload:Ast_payload.t -> Parsetree.expression diff --git a/compiler/frontend/ast_literal.ml b/compiler/frontend/ast_literal.ml index 50ea292d53d..9115caba978 100644 --- a/compiler/frontend/ast_literal.ml +++ b/compiler/frontend/ast_literal.ml @@ -51,24 +51,19 @@ module Lid = struct let pervasives : t = Lident Primitive_modules.pervasives - (* FIXME: Use primitive module *) - let js_oo : t = Lident "Js_OO" + let js_extern : t = Lident Primitive_modules.js_extern - (* FIXME: Use primitive module *) - let js_meth_callback : t = Ldot (js_oo, "Callback") + let method_callback : t = Ldot (js_extern, "Callback") let ignore_id : t = Ldot (pervasives, "ignore") let hidden_field n : t = Lident ("I" ^ n) - (* FIXME: Use primitive module *) - let js_null : t = Ldot (Lident "Js", "null") + let js_null : t = Ldot (Ldot (Lident "Stdlib", "Null"), "t") - (* FIXME: Use primitive module *) - let js_undefined : t = Ldot (Lident "Js", "undefined") + let js_undefined : t = Lident "undefined" - (* FIXME: Use primitive module *) - let js_null_undefined : t = Ldot (Lident "Js", "null_undefined") + let js_null_undefined : t = Ldot (Ldot (Lident "Stdlib", "Nullable"), "t") let regexp_id : t = Ldot (Lident "Stdlib_RegExp", "t") end diff --git a/compiler/frontend/ast_literal.mli b/compiler/frontend/ast_literal.mli index 82d57261715..32d3e9ca3df 100644 --- a/compiler/frontend/ast_literal.mli +++ b/compiler/frontend/ast_literal.mli @@ -43,9 +43,9 @@ module Lid : sig val pervasives : t - val js_oo : t + val js_extern : t - val js_meth_callback : t + val method_callback : t val hidden_field : string -> t diff --git a/compiler/frontend/ast_typ_uncurry.ml b/compiler/frontend/ast_typ_uncurry.ml index a57c491b76d..275b5eff49f 100644 --- a/compiler/frontend/ast_typ_uncurry.ml +++ b/compiler/frontend/ast_typ_uncurry.ml @@ -31,7 +31,7 @@ let to_method_callback_type loc (mapper : Bs_ast_mapper.mapper) ~arity | Some n -> Ast_helper.Typ.constr { - txt = Ldot (Ast_literal.Lid.js_meth_callback, "arity" ^ string_of_int n); + txt = Ldot (Ast_literal.Lid.method_callback, "arity" ^ string_of_int n); loc; } [meth_type] diff --git a/compiler/frontend/ast_typ_uncurry.mli b/compiler/frontend/ast_typ_uncurry.mli index c373caa42a9..63bb4cf7881 100644 --- a/compiler/frontend/ast_typ_uncurry.mli +++ b/compiler/frontend/ast_typ_uncurry.mli @@ -22,18 +22,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -(* Note that currently there is no way to consume [Js.meth_callback] - so it is fine to encode it with a freedom, - but we need make it better for error message. - - all are encoded as - {[ - type fn = (`Args_n of _ , 'result ) Js.fn - type method = (`Args_n of _, 'result) Js.method - type method_callback = (`Args_n of _, 'result) Js.method_callback - ]} - For [method_callback], the arity is never zero, so both [method] - and [fn] requires (unit -> 'a) to encode arity zero -*) +(* Method callbacks encode their arity with + [Primitive_js_extern.Callback.arityN]. The arity is never zero. *) type typ = Parsetree.core_type diff --git a/compiler/frontend/ast_uncurry_gen.ml b/compiler/frontend/ast_uncurry_gen.ml index 7e12f3a43a2..5d80377668c 100644 --- a/compiler/frontend/ast_uncurry_gen.ml +++ b/compiler/frontend/ast_uncurry_gen.ml @@ -61,7 +61,7 @@ let to_method_callback ~async loc (self : Bs_ast_mapper.mapper) label { funct = Exp.ident ~loc - {loc; txt = Ldot (Ast_literal.Lid.js_oo, "unsafe_to_method")}; + {loc; txt = Ldot (Ast_literal.Lid.js_extern, "unsafe_to_method")}; args = [ ( Nolabel, @@ -79,7 +79,7 @@ let to_method_callback ~async loc (self : Bs_ast_mapper.mapper) label { loc; txt = - Ldot (Ast_literal.Lid.js_meth_callback, "arity" ^ arity_s); + Ldot (Ast_literal.Lid.method_callback, "arity" ^ arity_s); } [Typ.any ~loc ()]) ); ]; diff --git a/compiler/gentype/gentype_common.ml b/compiler/gentype/gentype_common.ml index d550a4cc23d..eabddae4325 100644 --- a/compiler/gentype/gentype_common.ml +++ b/compiler/gentype/gentype_common.ml @@ -185,7 +185,7 @@ let sanitize_type_name name = | '\'' -> '_' | c -> c) let unknown = ident "unknown" -let bigint_t = ident "BigInt" +let bigint_t = ident "bigint" let boolean_t = ident "boolean" let date_t = ident "Date" let map_t (x, y) = ident ~type_args:[x; y] "Map" diff --git a/compiler/gentype/translate_structure.ml b/compiler/gentype/translate_structure.ml index bd3ffa23e6a..b55ba8b4469 100644 --- a/compiler/gentype/translate_structure.ml +++ b/compiler/gentype/translate_structure.ml @@ -18,17 +18,6 @@ let rec addAnnotationsToTypes_ ~config ~(expr : Typedtree.expression) else a_name in {a_name; a_type} :: next_types1 - | ( Texp_apply - {funct = {exp_desc = Texp_ident (path, _, _)}; args = [(_, Some expr1)]}, - _, - _ ) -> ( - match path |> Translate_type_expr_from_types.path_to_list |> List.rev with - | ["Js"; "Internal"; fn_mk] - when (* Uncurried function definition uses Js.Internal.fn_mkX(...) *) - String.length fn_mk >= 5 - && (String.sub fn_mk 0 5 [@doesNotRaise]) = "fn_mk" -> - arg_types |> addAnnotationsToTypes_ ~config ~expr:expr1 - | _ -> arg_types) | _ -> arg_types and add_annotations_to_types ~config ~(expr : Typedtree.expression) diff --git a/compiler/gentype/translate_type_expr_from_types.ml b/compiler/gentype/translate_type_expr_from_types.ml index 96dd88cabe0..a55756c0645 100644 --- a/compiler/gentype/translate_type_expr_from_types.ml +++ b/compiler/gentype/translate_type_expr_from_types.ml @@ -79,19 +79,10 @@ let translate_constr ~config ~params_translation ~(path : Path.t) ~type_env = | ["bool"], [] -> {dependencies = []; type_ = boolean_t} | ["int"], [] -> {dependencies = []; type_ = number_t} | ["float"], [] -> {dependencies = []; type_ = number_t} - | ( ( ["string"] - | ["String"; "t"] - | ["Stdlib"; "String"; "t"] - | ["Js"; ("String" | "String2"); "t"] ), - [] ) -> + | (["string"] | ["Stdlib"; "String"; "t"]), [] -> {dependencies = []; type_ = string_t} - | ( ( ["Js"; "Types"; "bigint_val"] - | ["BigInt"; "t"] - | ["Stdlib"; "BigInt"; "t"] ), - [] ) -> - {dependencies = []; type_ = bigint_t} - | (["Js"; "Date"; "t"] | ["Date"; "t"] | ["Stdlib"; "Date"; "t"]), [] -> - {dependencies = []; type_ = date_t} + | ["Stdlib"; "BigInt"; "t"], [] -> {dependencies = []; type_ = bigint_t} + | ["Stdlib"; "Date"; "t"], [] -> {dependencies = []; type_ = date_t} | ( (["Map"; "t"] | ["Stdlib"; "Map"; "t"]), [param_translation1; param_translation2] ) -> { @@ -116,8 +107,7 @@ let translate_constr ~config ~params_translation ~(path : Path.t) ~type_env = dependencies = param_translation.dependencies; type_ = weakset_t param_translation.type_; } - | (["Js"; "Re"; "t"] | ["RegExp"; "t"] | ["Stdlib"; "RegExp"; "t"]), [] -> - {dependencies = []; type_ = regexp_t} + | ["Stdlib"; "RegExp"; "t"], [] -> {dependencies = []; type_ = regexp_t} | ["Stdlib"; "ArrayBuffer"; "t"], [] -> {dependencies = []; type_ = ident "ArrayBuffer"} | ["Stdlib"; "DataView"; "t"], [] -> @@ -302,7 +292,7 @@ let translate_constr ~config ~params_translation ~(path : Path.t) ~type_env = } | ["Stdlib"; "Ordering"; "t"], [] -> {dependencies = []; type_ = number_t} | ["unit"], [] -> {dependencies = []; type_ = unit_t} - | (["array"] | ["Js"; ("Array" | "Array2"); "t"]), [param_translation] -> + | (["array"] | ["Stdlib"; "Array"; "t"]), [param_translation] -> {param_translation with type_ = Array (param_translation.type_, Mutable)} | ["ImmutableArray"; "t"], [param_translation] -> {param_translation with type_ = Array (param_translation.type_, Immutable)} @@ -404,36 +394,16 @@ let translate_constr ~config ~params_translation ~(path : Path.t) ~type_env = {dependencies = []; type_ = Emit_type.type_react_element} | ["option"], [param_translation] -> {param_translation with type_ = Option param_translation.type_} - | ( ( ["Js"; "Undefined"; "t"] - | ["Undefined"; "t"] - | ["Js"; "undefined"] - | ["Stdlib"; "undefined"] ), - [param_translation] ) -> + | ["Stdlib"; "undefined"], [param_translation] -> {param_translation with type_ = Option param_translation.type_} - | ( ( ["Js"; "Null"; "t"] - | ["Null"; "t"] - | ["Js"; "null"] - | ["Stdlib"; "Null"; "t"] - | ["Stdlib"; "null"] ), - [param_translation] ) -> + | (["Stdlib"; "Null"; "t"] | ["Stdlib"; "null"]), [param_translation] -> {param_translation with type_ = Null param_translation.type_} - | ( ( ["Js"; "Nullable"; "t"] - | ["Nullable"; "t"] - | ["Js"; "nullable"] - | ["Js"; "Null_undefined"; "t"] - | ["Js"; "null_undefined"] - | ["Stdlib"; "Nullable"; "t"] - | ["Stdlib"; "nullable"] ), - [param_translation] ) -> + | (["Stdlib"; "Nullable"; "t"] | ["Stdlib"; "nullable"]), [param_translation] + -> {param_translation with type_ = Nullable param_translation.type_} - | ( ( ["Js"; "Promise"; "t"] - | ["Promise"; "t"] - | ["promise"] - | ["Stdlib"; "Promise"; "t"] ), - [param_translation] ) -> + | (["promise"] | ["Stdlib"; "Promise"; "t"]), [param_translation] -> {param_translation with type_ = Promise param_translation.type_} - | ( (["Js"; "Dict"; "t"] | ["Dict"; "t"] | ["dict"] | ["Stdlib"; "Dict"; "t"]), - [param_translation] ) -> + | (["dict"] | ["Stdlib"; "Dict"; "t"]), [param_translation] -> {param_translation with type_ = Dict param_translation.type_} | ["Stdlib"; "JSON"; "t"], [] -> {dependencies = []; type_ = unknown} | ( (["taggedTemplate"] | ["Stdlib"; "TaggedTemplate"; "t"]), @@ -556,12 +526,6 @@ and translateTypeExprFromTypes_ ~config ~type_vars_gen ~type_env in {dependencies = []; type_ = TypeVar type_name} | Tvar (Some s) -> {dependencies = []; type_ = TypeVar s} - | Tconstr - (Pdot (Pident {name = "Js"}, "t", _), [{desc = Tvar _ | Tconstr _}], _) -> - (* Preserve some existing uses of Js.t(Obj.t) and Js.t('a). *) - translate_obj_type Closed [] - | Tconstr (Pdot (Pident {name = "Js"}, "t", _), [t], _) -> - t |> translateTypeExprFromTypes_ ~config ~type_vars_gen ~type_env | Tobject (t_obj, _) -> let rec get_field_types (texp : Types.type_expr) = match texp.desc with @@ -629,8 +593,7 @@ and translateTypeExprFromTypes_ ~config ~type_vars_gen ~type_env in {dependencies = []; type_} | {no_payloads = []; payloads = [(_label, t)]; unknowns = []} -> - (* Handle ReScript's "Arity_" encoding in first argument of Js.Internal.fn(_,_) for uncurried functions. - Return the argument tuple. *) + (* A single payload translates directly to its payload type. *) t |> translateTypeExprFromTypes_ ~config ~type_vars_gen ~type_env | {no_payloads; payloads; unknowns = []} -> let no_payloads = diff --git a/compiler/ml/ast_await.ml b/compiler/ml/ast_await.ml index 588a0fa3a1d..319b315c4e0 100644 --- a/compiler/ml/ast_await.ml +++ b/compiler/ml/ast_await.ml @@ -28,7 +28,7 @@ let is_await_expr (e : Parsetree.expression) = true | _ -> false -(* Transform `@res.await M` to unpack(@res.await Js.import(module(M: __M0__))) *) +(* Transform `@res.await M` to unpack(@res.await import(module(M: __M0__))) *) let create_await_module_expression ~module_type_lid (e : Parsetree.module_expr) = let open Ast_helper in diff --git a/compiler/ml/ast_untagged_variants.ml b/compiler/ml/ast_untagged_variants.ml index 281c2f418c2..a95cd120d50 100644 --- a/compiler/ml/ast_untagged_variants.ml +++ b/compiler/ml/ast_untagged_variants.ml @@ -238,7 +238,7 @@ let type_is_builtin_object (t : Types.type_expr) = | Tconstr (Path.Pident ident, [_], _) when Ident.name ident = "dict" -> true | Tconstr (path, _, _) -> let name = Path.name path in - name = "Js.Dict.t" || name = "Js_dict.t" + name = "Stdlib.Dict.t" || name = "Stdlib_Dict.t" | _ -> false let type_to_instanceof_backed_obj (t : Types.type_expr) = @@ -263,8 +263,8 @@ let type_to_instanceof_backed_obj (t : Types.type_expr) = | "Stdlib.Uint32Array.t" -> Some Uint32Array | "Stdlib.Uint8Array.t" -> Some Uint8Array | "Stdlib.Uint8ClampedArray.t" -> Some Uint8ClampedArray - | "Js_file.t" -> Some File - | "Js_blob.t" -> Some Blob + | "Stdlib_File.t" -> Some File + | "Stdlib_Blob.t" -> Some Blob | "Stdlib.Set.t" -> Some Set | "Stdlib.Map.t" -> Some Map | "Stdlib.WeakSet.t" -> Some WeakSet diff --git a/compiler/ml/typetexp.ml b/compiler/ml/typetexp.ml index 4e8617b863b..d188a3b0b9f 100644 --- a/compiler/ml/typetexp.ml +++ b/compiler/ml/typetexp.ml @@ -864,7 +864,7 @@ let report_error env ppf = function "@[@{The module or file %a can't be found.@}@,\ @,\ Are you trying to use the standard library's Str?@ If you're \ - compiling to JavaScript,@ use @{Js.Re@} instead.@ Otherwise, \ + compiling to JavaScript,@ use @{RegExp@} instead.@ Otherwise, \ add str.cma to your ocamlc/ocamlopt command.@]" Printtyp.longident lid | lid -> diff --git a/compiler/syntax/src/jsx_v4.ml b/compiler/syntax/src/jsx_v4.ml index 5cf7eaf37ca..dfbefe65f07 100644 --- a/compiler/syntax/src/jsx_v4.ml +++ b/compiler/syntax/src/jsx_v4.ml @@ -43,7 +43,7 @@ let ref_type_var loc = Typ.var ~loc "ref" let ref_type loc = Typ.constr ~loc - {loc; txt = Ldot (Ldot (Lident "Js", "Nullable"), "t")} + {loc; txt = Ldot (Ldot (Lident "Stdlib", "Nullable"), "t")} [ref_type_var loc] let jsx_element_type config ~loc = @@ -117,12 +117,17 @@ let strip_option core_type = List.nth_opt core_types 0 [@doesNotRaise] | _ -> Some core_type -let strip_js_nullable core_type = +let strip_nullable core_type = match core_type with + | {ptyp_desc = Ptyp_constr ({txt = Lident "nullable"}, core_types)} | { - ptyp_desc = - Ptyp_constr ({txt = Ldot (Ldot (Lident "Js", "Nullable"), "t")}, core_types); - } -> + ptyp_desc = Ptyp_constr ({txt = Ldot (Lident "Nullable", "t")}, core_types); + } + | { + ptyp_desc = + Ptyp_constr + ({txt = Ldot (Ldot (Lident "Stdlib", "Nullable"), "t")}, core_types); + } -> List.nth_opt core_types 0 [@doesNotRaise] | _ -> Some core_type @@ -131,7 +136,7 @@ let strip_js_nullable core_type = (* (Str) let make = ({x, _}: props<'x>) => body *) (* (Str) external make: React.componentLike, React.element> = "default" *) let make_props_type_params ?(strip_explicit_option = false) - ?(strip_explicit_js_nullable_of_ref = false) named_type_list = + ?(strip_explicit_nullable_of_ref = false) named_type_list = named_type_list |> List.filter_map (fun (is_optional, label, _, loc, interior_type) -> if label = "key" then None @@ -144,9 +149,7 @@ let make_props_type_params ?(strip_explicit_option = false) match interior_type with | {ptyp_desc = Ptyp_any} -> Some (ref_type_var loc) | _ -> - (* Strip explicit Js.Nullable.t in case of forwardRef *) - if strip_explicit_js_nullable_of_ref then - strip_js_nullable interior_type + if strip_explicit_nullable_of_ref then strip_nullable interior_type else Some interior_type (* Strip the explicit option type in implementation *) (* let make = (~x: option=?) => ... *) @@ -622,7 +625,7 @@ let map_binding ~config ~empty_loc ~pstr_loc ~file_name binding = (* React component name should start with uppercase letter *) (* let make = { let \"App" = props => make(props); \"App" } *) (* let make = React.forwardRef({ - let \"App" = (props, ref) => make({...props, ref: @optional (Js.Nullabel.toOption(ref))}) + let \"App" = (props, ref) => make({...props, ref: @optional (Stdlib.Nullable.toOption(ref))}) })*) let total_arity = if has_forward_ref then 2 else 1 in Exp.fun_ ~arity:(Some total_arity) Nolabel None @@ -769,7 +772,7 @@ let map_binding ~config ~empty_loc ~pstr_loc ~file_name binding = (match core_type_of_attr with | None -> make_props_type_params ~strip_explicit_option:true - ~strip_explicit_js_nullable_of_ref:has_forward_ref + ~strip_explicit_nullable_of_ref:has_forward_ref named_type_list | Some _ -> ( match typ_vars_of_core_type with diff --git a/compiler/syntax/src/res_core.ml b/compiler/syntax/src/res_core.ml index 3e67dcbf26f..91b821a459d 100644 --- a/compiler/syntax/src/res_core.ml +++ b/compiler/syntax/src/res_core.ml @@ -5240,7 +5240,7 @@ and parse_type_constructor_arg_region ?inline_types_context ?current_type_name_path p) else None -(* Js.Nullable.value<'a> *) +(* Nullable.t<'a> *) and parse_type_constructor_args ?inline_types_context ?current_type_name_path ~constr_name p = let opening = p.Parser.token in diff --git a/compiler/syntax/src/res_outcome_printer.ml b/compiler/syntax/src/res_outcome_printer.ml index f6fd5aec84c..5bf0598fb4c 100644 --- a/compiler/syntax/src/res_outcome_printer.ml +++ b/compiler/syntax/src/res_outcome_printer.ml @@ -153,9 +153,6 @@ let rec print_out_type_doc (out_type : Outcometree.out_type) = (* example: Red | Blue | Green | CustomColour(float, float, float) *) | Otyp_sum constructors -> print_out_constructors_doc constructors (* example: {"name": string, "age": int} *) - | Otyp_constr (Oide_dot (Oide_ident "Js", "t"), [Otyp_object (fields, rest)]) - -> - print_object_fields fields rest (* example: node *) | Otyp_constr (out_ident, args) -> let args_doc = diff --git a/compiler/syntax/src/res_parsetree_viewer.ml b/compiler/syntax/src/res_parsetree_viewer.ml index 04c8395bbe7..5a0301dbc7a 100644 --- a/compiler/syntax/src/res_parsetree_viewer.ml +++ b/compiler/syntax/src/res_parsetree_viewer.ml @@ -822,8 +822,8 @@ let collect_or_pattern_chain pat = let is_single_pipe_expr expr = (* handles: * x - * ->Js.Dict.get("wm-property") - * ->Option.flatMap(Js.Json.decodeString) + * ->Dict.get("wm-property") + * ->Option.flatMap(JSON.decodeString) * ->Option.flatMap(x => * switch x { * | "like-of" => Some(#like) diff --git a/compiler/syntax/src/res_printer.ml b/compiler/syntax/src/res_printer.ml index dd15d0bb630..da48b02561e 100644 --- a/compiler/syntax/src/res_printer.ml +++ b/compiler/syntax/src/res_printer.ml @@ -2446,13 +2446,13 @@ and print_value_binding ~state ~rec_flag (vb : Parsetree.value_binding) cmt_tbl in (* * we want to optimize the layout of one pipe: - * let tbl = data->Js.Array2.reduce((map, curr) => { + * let tbl = data->Array.reduce((map, curr) => { * ... * }) * important is that we don't do this for multiple pipes: * let decoratorTags = * items - * ->Js.Array2.filter(items => {items.category === Decorators}) + * ->Array.filter(items => {items.category === Decorators}) * ->Belt.Array.map(...) * Multiple pipes chained together lend themselves more towards the last layout. *) diff --git a/docs/JSXV4.md b/docs/JSXV4.md index 7b2f1562083..927de6b0a63 100644 --- a/docs/JSXV4.md +++ b/docs/JSXV4.md @@ -165,7 +165,7 @@ module FancyInput = { Js.Nullable.toOption->Belt.Option.map(ReactDOM.Ref.domRef)} + ref=?{ref_->Nullable.toOption->Belt.Option.map(ReactDOM.Ref.domRef)} /> children @@ -174,7 +174,7 @@ module FancyInput = { @react.component let make = () => { - let input = React.useRef(Js.Nullable.null) + let input = React.useRef(Nullable.null)
// prop @@ -198,7 +198,7 @@ module FancyInput = { Js.Nullable.toOption->Belt.Option.map(ReactDOM.Ref.domRef)} + ref=?{ref->Nullable.toOption->Belt.Option.map(ReactDOM.Ref.domRef)} /> children
@@ -207,7 +207,7 @@ module FancyInput = { @react.component let make = () => { - let input = React.useRef(Js.Nullable.null) + let input = React.useRef(Nullable.null)
diff --git a/packages/@rescript/runtime/Belt.res b/packages/@rescript/runtime/Belt.res index c65ed18dfca..4b59fcb5094 100644 --- a/packages/@rescript/runtime/Belt.res +++ b/packages/@rescript/runtime/Belt.res @@ -6,7 +6,7 @@ /*** The ReScript standard library. -Belt is currently mostly covering collection types. It has no string or date functions yet, although Belt.String is in the works. In the meantime, use [Js.String](js/string) for string functions and [Js.Date](js/date) for date functions. +Belt mostly covers collection types. Use the top-level `String` and `Date` modules for string and date functions. ## Motivation @@ -56,7 +56,7 @@ let greaterThan2UniqueAndSorted = ->Belt.Set.Int.fromArray ->Belt.Set.Int.toArray // output is already sorted -Js.log2("result", greaterThan2UniqueAndSorted) +Console.log2("result", greaterThan2UniqueAndSorted) ``` ## Specialized Collections @@ -80,7 +80,7 @@ One common confusion comes from the way Belt handles array access. It differs fr ```rescript let letters = ["a", "b", "c"] let a = letters[0] // a == "a" -let capitalA = Js.String.toUpperCase(a) +let capitalA = String.toUpperCase(a) let k = letters[10] // Throws an exception! The 10th index doesn't exist. ``` @@ -92,7 +92,7 @@ Because Belt avoids exceptions and returns `options` instead, this code behaves open Belt let letters = ["a", "b", "c"] let a = letters[0] // a == Some("a") -let captialA = Js.String.toUpperCase(a) // Type error! This code will not compile. +let captialA = String.toUpperCase(a) // Type error! This code will not compile. let k = letters[10] // k == None ``` @@ -113,7 +113,7 @@ let a = letters[0] // Use a switch statement: let capitalA = switch a { -| Some(a) => Some(Js.String.toUpperCase(a)) +| Some(a) => Some(String.toUpperCase(a)) | None => None } diff --git a/packages/@rescript/runtime/Belt_Array.res b/packages/@rescript/runtime/Belt_Array.res index dc1003d273f..11afbf34d54 100644 --- a/packages/@rescript/runtime/Belt_Array.res +++ b/packages/@rescript/runtime/Belt_Array.res @@ -47,7 +47,7 @@ let setExn = setOrThrow @set external truncateToLengthUnsafe: (t<'a>, int) => unit = "length" -@new external makeUninitialized: int => array> = "Array" +@new external makeUninitialized: int => array> = "Array" @new external makeUninitializedUnsafe: int => array<'a> = "Array" diff --git a/packages/@rescript/runtime/Belt_Array.resi b/packages/@rescript/runtime/Belt_Array.resi index 8f6cac74c56..8609a51c800 100644 --- a/packages/@rescript/runtime/Belt_Array.resi +++ b/packages/@rescript/runtime/Belt_Array.resi @@ -118,13 +118,13 @@ value. You must specify the type of data that will eventually fill the array. ## Examples ```rescript -let arr: array> = Belt.Array.makeUninitialized(5) +let arr: array> = Belt.Array.makeUninitialized(5) -Belt.Array.getExn(arr, 0) == Js.undefined +Type.typeof(Belt.Array.getExn(arr, 0)) == #undefined ``` */ @new -external makeUninitialized: int => array> = "Array" +external makeUninitialized: int => array> = "Array" /** **Unsafe** @@ -134,7 +134,7 @@ external makeUninitialized: int => array> = "Array" ```rescript let arr = Belt.Array.makeUninitializedUnsafe(5) -Js.log(Belt.Array.getExn(arr, 0)) // undefined +Console.log(Belt.Array.getExn(arr, 0)) // undefined Belt.Array.setExn(arr, 0, "example") @@ -392,7 +392,7 @@ repetitively creating side effects. ## Examples ```rescript -Belt.Array.forEach(["a", "b", "c"], x => Js.log("Item: " ++ x)) +Belt.Array.forEach(["a", "b", "c"], x => Console.log("Item: " ++ x)) /* prints: @@ -518,7 +518,7 @@ supplied two arguments: the index starting from 0 and the element from `xs`. ```rescript Belt.Array.forEachWithIndex(["a", "b", "c"], (i, x) => - Js.log("Item " ++ Belt.Int.toString(i) ++ " is " ++ x) + Console.log("Item " ++ Belt.Int.toString(i) ++ " is " ++ x) ) /* @@ -641,9 +641,9 @@ using the separator. If the array is empty, the empty string will be returned. ## Examples ```rescript -Belt.Array.joinWith([0, 1], ", ", Js.Int.toString) == "0, 1" -Belt.Array.joinWith([], " ", Js.Int.toString) == "" -Belt.Array.joinWith([1], " ", Js.Int.toString) == "1" +Belt.Array.joinWith([0, 1], ", ", x => Int.toString(x)) == "0, 1" +Belt.Array.joinWith([], " ", x => Int.toString(x)) == "" +Belt.Array.joinWith([1], " ", x => Int.toString(x)) == "1" ``` */ let joinWith: (t<'a>, string, 'a => string) => string @@ -756,7 +756,7 @@ let eq: (t<'a>, t<'a>, ('a, 'a) => bool) => bool /** Unsafe `truncateToLengthUnsafe(xs, n)` sets length of array `xs` to `n`. If `n` -is greater than the length of `xs`; the extra elements are set to `Js.Null_undefined.null`. +is greater than the length of `xs`; the extra elements are set to `undefined`. If `n` is less than zero; throws a `RangeError`. ## Examples diff --git a/packages/@rescript/runtime/Belt_HashMap.resi b/packages/@rescript/runtime/Belt_HashMap.resi index 3a9c3a88982..5a69ba4f036 100644 --- a/packages/@rescript/runtime/Belt_HashMap.resi +++ b/packages/@rescript/runtime/Belt_HashMap.resi @@ -241,7 +241,7 @@ module IntHash = Belt.Id.MakeHashable({ let s0 = Belt.HashMap.make(~hintSize=10, ~id=module(IntHash)) Belt.HashMap.set(s0, 1, "value1") -Belt.HashMap.forEach(s0, (key, value) => Js.log2(key, value)) +Belt.HashMap.forEach(s0, (key, value) => Console.log2(key, value)) // prints (1, "value1") ``` */ diff --git a/packages/@rescript/runtime/Belt_List.res b/packages/@rescript/runtime/Belt_List.res index 0fbc5c2b935..a000e415d4c 100644 --- a/packages/@rescript/runtime/Belt_List.res +++ b/packages/@rescript/runtime/Belt_List.res @@ -13,7 +13,7 @@ mutable tail : 'a opt_cell } - and 'a opt_cell = 'a cell Js.null + and 'a opt_cell = 'a cell Primitive_js_extern.null and 'a t = { length : int ; @@ -468,7 +468,7 @@ let shuffle = xs => { A.setUnsafe arr i (f h [@bs]) ; fillAuxMap arr (i + 1) t f */ -/* module J = Js_json */ +/* module J = Stdlib_JSON */ /* type json = J.t */ /* let toJson x f = */ /* let len = length x in */ diff --git a/packages/@rescript/runtime/Belt_List.resi b/packages/@rescript/runtime/Belt_List.resi index 80b3d8303d1..d03595b9d29 100644 --- a/packages/@rescript/runtime/Belt_List.resi +++ b/packages/@rescript/runtime/Belt_List.resi @@ -406,7 +406,7 @@ Belt.List.toArray(list{1, 2, 3}) == [1, 2, 3] */ let toArray: t<'a> => array<'a> -/* type json = Js_json.t */ +/* type json = Stdlib_JSON.t */ /* val toJson : 'a t -> ('a -> json [@bs]) -> json */ /* val fromJson : json -> (json -> 'a [@bs]) -> 'a t */ @@ -448,7 +448,7 @@ Call `f` on each element of `someList` from the beginning to end. ## Examples ```rescript -Belt.List.forEach(list{"a", "b", "c"}, x => Js.log("Item: " ++ x)) +Belt.List.forEach(list{"a", "b", "c"}, x => Console.log("Item: " ++ x)) /* prints: Item: a @@ -471,7 +471,7 @@ Function `f` takes two arguments: the index starting from 0 and the element from ```rescript Belt.List.forEachWithIndex(list{"a", "b", "c"}, (index, x) => { - Js.log("Item " ++ Belt.Int.toString(index) ++ " is " ++ x) + Console.log("Item " ++ Belt.Int.toString(index) ++ " is " ++ x) }) /* prints: @@ -562,7 +562,7 @@ Stops at the length of the shorter list. ## Examples ```rescript -Belt.List.forEach2(list{"Z", "Y"}, list{"A", "B", "C"}, (x, y) => Js.log2(x, y)) +Belt.List.forEach2(list{"Z", "Y"}, list{"A", "B", "C"}, (x, y) => Console.log2(x, y)) /* prints: diff --git a/packages/@rescript/runtime/Belt_MapDict.res b/packages/@rescript/runtime/Belt_MapDict.res index 229ad0e37d1..ea2b5b4997d 100644 --- a/packages/@rescript/runtime/Belt_MapDict.res +++ b/packages/@rescript/runtime/Belt_MapDict.res @@ -110,7 +110,7 @@ let rec update = (t: t<_>, newK, f, ~cmp): t<_> => /* unboxing API was not exported since the correct API is really awkard - `bool -> 'k Js.null -> ('a Js.null * bool)` + `bool -> 'k Primitive_js_extern.null -> ('a Primitive_js_extern.null * bool)` even for specialized `k` the first `bool` can be erased, maybe the perf boost does not justify the inclusion of such API diff --git a/packages/@rescript/runtime/Belt_Option.resi b/packages/@rescript/runtime/Belt_Option.resi index 67bb245793b..1fad05201fd 100644 --- a/packages/@rescript/runtime/Belt_Option.resi +++ b/packages/@rescript/runtime/Belt_Option.resi @@ -49,8 +49,8 @@ If `optionValue` is `Some(value`), it calls `f(value)`; otherwise returns `()` ## Examples ```rescript -Belt.Option.forEach(Some("thing"), x => Js.log(x)) /* logs "thing" */ -Belt.Option.forEach(None, x => Js.log(x)) /* returns () */ +Belt.Option.forEach(Some("thing"), x => Console.log(x)) /* logs "thing" */ +Belt.Option.forEach(None, x => Console.log(x)) /* returns () */ ``` */ let forEach: (option<'a>, 'a => unit) => unit diff --git a/packages/@rescript/runtime/Belt_Range.resi b/packages/@rescript/runtime/Belt_Range.resi index 84b6a4b1e23..acb6cf7141c 100644 --- a/packages/@rescript/runtime/Belt_Range.resi +++ b/packages/@rescript/runtime/Belt_Range.resi @@ -19,7 +19,7 @@ let forEachU: (int, int, int => unit) => unit ## Examples ```rescript -Belt.Range.forEach(0, 4, i => Js.log(i)) +Belt.Range.forEach(0, 4, i => Console.log(i)) // Prints: // 0 diff --git a/packages/@rescript/runtime/Belt_internalBuckets.res b/packages/@rescript/runtime/Belt_internalBuckets.res index ff9ed2cbcf5..373385c8f35 100644 --- a/packages/@rescript/runtime/Belt_internalBuckets.res +++ b/packages/@rescript/runtime/Belt_internalBuckets.res @@ -117,7 +117,7 @@ let getBucketHistogram = h => { let logStats = h => { let histogram = getBucketHistogram(h) - Js.log({ + Stdlib_Console.log({ "bindings": h.C.size, "buckets": A.length(h.C.buckets), "histogram": histogram, diff --git a/packages/@rescript/runtime/Belt_internalBucketsType.res b/packages/@rescript/runtime/Belt_internalBucketsType.res index 767194259e7..6e9b5818eb4 100644 --- a/packages/@rescript/runtime/Belt_internalBucketsType.res +++ b/packages/@rescript/runtime/Belt_internalBucketsType.res @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: MIT */ -type opt<'a> = Js.undefined<'a> +type opt<'a> = Primitive_js_extern.undefined<'a> type container<'hash, 'eq, 'c> = { mutable size: int /* number of entries */, @@ -16,7 +16,7 @@ module A = Belt_Array external toOpt: opt<'a> => option<'a> = "%identity" external return: 'a => opt<'a> = "%identity" -let emptyOpt = Js.undefined +let emptyOpt = Primitive_js_extern.undefined let rec power_2_above = (x, n) => if x >= n { x diff --git a/packages/@rescript/runtime/Belt_internalBucketsType.resi b/packages/@rescript/runtime/Belt_internalBucketsType.resi index 00beacf052a..b0092639ea1 100644 --- a/packages/@rescript/runtime/Belt_internalBucketsType.resi +++ b/packages/@rescript/runtime/Belt_internalBucketsType.resi @@ -4,7 +4,7 @@ * SPDX-License-Identifier: MIT */ -type opt<'a> = Js.undefined<'a> +type opt<'a> = Primitive_js_extern.undefined<'a> type container<'hash, 'eq, 'c> = { mutable size: int /* number of entries */, mutable buckets: array> /* the buckets */, @@ -15,7 +15,7 @@ type container<'hash, 'eq, 'c> = { external toOpt: opt<'a> => option<'a> = "%identity" external return: 'a => opt<'a> = "%identity" -let emptyOpt: Js.undefined<'a> +let emptyOpt: Primitive_js_extern.undefined<'a> let make: (~hash: 'hash, ~eq: 'eq, ~hintSize: int) => container<'hash, 'eq, _> let clear: container<_> => unit diff --git a/packages/@rescript/runtime/Belt_internalSetBuckets.res b/packages/@rescript/runtime/Belt_internalSetBuckets.res index e5dde3fa056..5be597e040c 100644 --- a/packages/@rescript/runtime/Belt_internalSetBuckets.res +++ b/packages/@rescript/runtime/Belt_internalSetBuckets.res @@ -131,7 +131,7 @@ let getBucketHistogram = h => { let logStats = h => { let histogram = getBucketHistogram(h) - Js.log({ + Stdlib_Console.log({ "bindings": h.C.size, "buckets": A.length(h.C.buckets), "histogram": histogram, diff --git a/packages/@rescript/runtime/Js.res b/packages/@rescript/runtime/Js.res deleted file mode 100644 index 590547203a4..00000000000 --- a/packages/@rescript/runtime/Js.res +++ /dev/null @@ -1,342 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -@@config({flags: ["-unboxed-types", "-w", "-49"]}) - -/* DESIGN: - - It does not have any code, all its code will be inlined so that - there will never be - {[ require('js')]} - - Its interface should be minimal -*/ - -/*** -The Js module mostly contains ReScript bindings to _standard JavaScript APIs_ -like [console.log](https://developer.mozilla.org/en-US/docs/Web/API/Console/log), -or the JavaScript -[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String), -[Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date), and -[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) -classes. - -It is meant as a zero-abstraction interop layer and directly exposes JavaScript functions as they are. If you can find your API in this module, prefer this over an equivalent Belt helper. For example, prefer [Js.Array2](js/array2) over [Belt.Array](belt/array) - -## Argument Order - -For historical reasons, some APIs in the Js namespace (e.g. [Js.String](js/string)) are -using the data-last argument order whereas others (e.g. [Js.Date](js/date)) are using data-first. - -For more information about these argument orders and the trade-offs between them, see -[this blog post](https://www.javierchavarri.com/data-first-and-data-last-a-comparison/). - -_Eventually, all modules in the Js namespace are going to be migrated to data-first though._ - -## Js.Xxx2 Modules - -Prefer `Js.Array2` over `Js.Array`, `Js.String2` over `Js.String`, etc. The latters are old modules. - */ - -/** Provide utilities for `Js.null<'a>` */ -module Null = Js_null - -/** Provide utilities for `Js.undefined<'a>` */ -module Undefined = Js_undefined - -/** Provide utilities for `Js.null_undefined` */ -module Nullable = Js_null_undefined - -module Null_undefined = Js_null_undefined - -/** Provide utilities for dealing with Js exceptions */ -module Exn = Stdlib_Exn - -/** Provide bindings to JS array*/ -module Array = Js_array - -/** Provide bindings to JS array*/ -module Array2 = Js_array2 - -/** Provide bindings to JS string */ -module String = Js_string - -/** Provide bindings to JS string */ -module String2 = Js_string2 - -/** Provide bindings to JS regex expression */ -module Re = Js_re - -/** Provide bindings to JS Promise */ -module Promise = Js_promise - -/** Provide bindings to JS Promise */ -module Promise2 = Js_promise2 - -/** Provide bindings for JS Date */ -module Date = Js_date - -/** Provide utilities for JS dictionary object */ -module Dict = Js_dict - -/** Provide bindings to JS global functions in global namespace*/ -module Global = Js_global - -/** Provide utilities for json */ -module Json = Js_json - -/** Provide bindings for JS `Math` object */ -module Math = Js_math - -/** Provide utilities for `Js.t` */ -module Obj = Js_obj - -/** Provide bindings for JS typed array */ -module Typed_array = Js_typed_array - -/** Provide bindings for JS typed array */ -module TypedArray2 = Js_typed_array2 - -/** Provide utilities for manipulating JS types */ -module Types = Js_types - -/** Provide utilities for JS float */ -module Float = Js_float - -/** Provide utilities for int */ -module Int = Js_int - -/** Provide utilities for bigint */ -module BigInt = Js_bigint - -/** Provide utilities for File */ -module File = Js_file - -/** Provide utilities for Blob */ -module Blob = Js_blob - -/** Provide utilities for option */ -module Option = Js_option - -/** Define the interface for result */ -module Result = Js_result - -/** Provides bindings for console */ -module Console = Js_console - -/** Provides bindings for ES6 Set */ -module Set = Js_set - -/** Provides bindings for ES6 WeakSet */ -module WeakSet = Js_weakset - -/** Provides bindings for ES6 Map */ -module Map = Js_map - -/** Provides bindings for ES6 WeakMap */ -module WeakMap = Js_weakmap - -/** JS object type */ -@deprecated( - "This has been deprecated and will be removed in v13. Use the `{..}` type directly instead." -) -type t<'a> = {..} as 'a - -/** JS global object reference */ -@val -@deprecated({ - reason: "Use `globalThis` directly instead.", - migrate: globalThis(), -}) -external globalThis: t<'a> = "globalThis" - -@deprecated({ - reason: "Use `Null.t` directly instead.", - migrate: %replace.type(: Null.t), -}) -@unboxed -type null<+'a> = Js_null.t<'a> = Value('a) | @as(null) Null - -@deprecated("This has been deprecated and will be removed in v13.") -type undefined<+'a> = Js_undefined.t<'a> - -@unboxed -@deprecated({ - reason: "Use `Nullable.t` directly instead.", - migrate: %replace.type(: Nullable.t), -}) -type nullable<+'a> = Js_null_undefined.t<'a> = Value('a) | @as(null) Null | @as(undefined) Undefined - -@deprecated({ - reason: "Use `Nullable.t` directly instead.", - migrate: %replace.type(: Nullable.t), -}) -type null_undefined<+'a> = nullable<'a> - -external toOption: nullable<'a> => option<'a> = "%nullable_to_opt" -@deprecated({ - reason: "Use `fromUndefined` instead.", - migrate: fromUndefined(), -}) -let undefinedToOption: undefined<'a> => option<'a> = Primitive_option.fromUndefined -@deprecated({ - reason: "Use `Null.toOption` instead.", - migrate: Null.toOption(), -}) -external nullToOption: null<'a> => option<'a> = "%null_to_opt" -@deprecated({ - reason: "Use `isNullable` directly instead.", - migrate: isNullable(), -}) -external isNullable: nullable<'a> => bool = "%is_nullable" -@deprecated({ - reason: "Use `import` directly instead.", - migrate: import(), -}) -external import: 'a => promise<'a> = "%import" - -/** The same as {!test} except that it is more permissive on the types of input */ -@deprecated({ - reason: "Use `testAny` directly instead.", - migrate: testAny(), -}) -external testAny: 'a => bool = "%is_nullable" - -/** - The promise type, defined here for interoperation across packages. -*/ -@deprecated( - "This is deprecated and will be removed in v13. Use the `promise` type directly instead." -) -type promise<+'a, +'e> - -/** - The same as empty in `Js.Null`. Compiles to `null`. -*/ -@deprecated({ - reason: "Use `null` instead.", - migrate: null(), -}) -external null: null<'a> = "%null" - -/** - The same as empty `Js.Undefined`. Compiles to `undefined`. -*/ -@deprecated({ - reason: "Use `undefined` instead.", - migrate: undefined(), -}) -external undefined: undefined<'a> = "%undefined" - -/** -`typeof x` will be compiled as `typeof x` in JS. Please consider functions in -`Js.Types` for a type safe way of reflection. -*/ -@deprecated({ - reason: "Use `typeof` instead.", - migrate: typeof(), -}) -external typeof: 'a => string = "%typeof" - -/** Equivalent to console.log any value. */ -@deprecated({ - reason: "Use `Console.log` instead.", - migrate: Console.log(), -}) -@val -@scope("console") -external log: 'a => unit = "log" - -@deprecated({ - reason: "Use `Console.log2` instead.", - migrate: Console.log2(), -}) -@val -@scope("console") -external log2: ('a, 'b) => unit = "log" - -@deprecated({ - reason: "Use `Console.log3` instead.", - migrate: Console.log3(), -}) -@val -@scope("console") -external log3: ('a, 'b, 'c) => unit = "log" - -@deprecated({ - reason: "Use `Console.log4` instead.", - migrate: Console.log4(), -}) -@val -@scope("console") -external log4: ('a, 'b, 'c, 'd) => unit = "log" - -/** A convenience function to console.log more than 4 arguments */ -@deprecated({ - reason: "Use `Console.logMany` instead.", - migrate: Console.logMany(), -}) -@val -@scope("console") -@variadic -external logMany: array<'a> => unit = "log" - -@deprecated({ - reason: "Use `eqNull` directly instead.", - migrate: eqNull(), -}) -external eqNull: ('a, null<'a>) => bool = "%equal_null" -@deprecated({ - reason: "Use `eqUndefined` directly instead.", - migrate: eqUndefined(), -}) -external eqUndefined: ('a, undefined<'a>) => bool = "%equal_undefined" -@deprecated({ - reason: "Use `eqNullable` directly instead.", - migrate: eqNullable(), -}) -external eqNullable: ('a, nullable<'a>) => bool = "%equal_nullable" - -/* ## Operators */ - -/** - `unsafe_lt(a, b)` will be compiled as `a < b`. - It is marked as unsafe, since it is impossible - to give a proper semantics for comparision which applies to any type -*/ -@deprecated({ - reason: "Use `lt` instead.", - migrate: lt(), -}) -external unsafe_lt: ('a, 'a) => bool = "%unsafe_lt" - -/** - `unsafe_le(a, b)` will be compiled as `a <= b`. - See also `Js.unsafe_lt`. -*/ -@deprecated({ - reason: "Use `le` instead.", - migrate: le(), -}) -external unsafe_le: ('a, 'a) => bool = "%unsafe_le" - -/** - `unsafe_gt(a, b)` will be compiled as `a > b`. - See also `Js.unsafe_lt`. -*/ -@deprecated({ - reason: "Use `gt` instead.", - migrate: gt(), -}) -external unsafe_gt: ('a, 'a) => bool = "%unsafe_gt" - -/** - `unsafe_ge(a, b)` will be compiled as `a >= b`. - See also `Js.unsafe_lt`. -*/ -@deprecated({ - reason: "Use `ge` instead.", - migrate: ge(), -}) -external unsafe_ge: ('a, 'a) => bool = "%unsafe_ge" diff --git a/packages/@rescript/runtime/Js_OO.res b/packages/@rescript/runtime/Js_OO.res deleted file mode 100644 index 521807eeb2e..00000000000 --- a/packages/@rescript/runtime/Js_OO.res +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -@@config({flags: ["-unboxed-types"]}) - -external unsafe_to_method: 'a => 'a = "%unsafe_to_method" - -module Callback = { - type arity1<'a> = {@internal i1: 'a} - type arity2<'a> = {@internal i2: 'a} - type arity3<'a> = {@internal i3: 'a} - type arity4<'a> = {@internal i4: 'a} - type arity5<'a> = {@internal i5: 'a} - type arity6<'a> = {@internal i6: 'a} - type arity7<'a> = {@internal i7: 'a} - type arity8<'a> = {@internal i8: 'a} - type arity9<'a> = {@internal i9: 'a} - type arity10<'a> = {@internal i10: 'a} - type arity11<'a> = {@internal i11: 'a} - type arity12<'a> = {@internal i12: 'a} - type arity13<'a> = {@internal i13: 'a} - type arity14<'a> = {@internal i14: 'a} - type arity15<'a> = {@internal i15: 'a} - type arity16<'a> = {@internal i16: 'a} - type arity17<'a> = {@internal i17: 'a} - type arity18<'a> = {@internal i18: 'a} - type arity19<'a> = {@internal i19: 'a} - type arity20<'a> = {@internal i20: 'a} - type arity21<'a> = {@internal i21: 'a} - type arity22<'a> = {@internal i22: 'a} -} diff --git a/packages/@rescript/runtime/Js_array.res b/packages/@rescript/runtime/Js_array.res deleted file mode 100644 index 93b2ff8458c..00000000000 --- a/packages/@rescript/runtime/Js_array.res +++ /dev/null @@ -1,1128 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** -Provides bindings to JavaScript’s `Array` functions. These bindings are -optimized for pipe-last (`|>`), where the array to be processed is the last -parameter in the function. -*/ - -@@warning("-103") - -/** -The type used to describe a JavaScript array. -*/ -@deprecated({ - reason: "Use `array` directly instead.", - migrate: %replace.type(: array), -}) -type t<'a> = array<'a> - -/** -A type used to describe JavaScript objects that are like an array or are iterable. -*/ -@deprecated({ - reason: "Use `Array.arrayLike` instead.", - migrate: %replace.type(: Array.arrayLike), -}) -type array_like<'a> = Js_array2.array_like<'a> - -/* commented out until bs has a plan for iterators - type 'a array_iter = 'a array_like -*/ - -/** -Creates a shallow copy of an array from an array-like object. See [`Array.from`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from) on MDN. - -## Examples - -```rescript -let strArr = Js.String.castToArrayLike("abcd") -Js.Array.from(strArr) == ["a", "b", "c", "d"] -``` -*/ -@val -@deprecated({ - reason: "Use `Array.fromArrayLike` instead.", - migrate: Array.fromArrayLike(), -}) -external from: array_like<'a> => array<'a> = "Array.from" - -/* ES2015 */ - -/** -Creates a new array by applying a function (the second argument) to each item -in the `array_like` first argument. See -[`Array.from`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from) -on MDN. - -## Examples - -```rescript -let strArr = Js.String.castToArrayLike("abcd") -let code = s => Js.String.charCodeAt(0, s) -Js.Array.fromMap(strArr, code) == [97.0, 98.0, 99.0, 100.0] -``` -*/ -@val -@deprecated({ - reason: "Use `Array.fromArrayLikeWithMap` instead.", - migrate: Array.fromArrayLikeWithMap(), -}) -external fromMap: (array_like<'a>, 'a => 'b) => array<'b> = "Array.from" - -/* ES2015 */ - -@deprecated({ - reason: "Use `Array.isArray` instead.", - migrate: Array.isArray(), -}) -@val -external isArray: 'a => bool = "Array.isArray" -/* ES2015 */ -/* -Returns `true` if its argument is an array; `false` otherwise. This is a -runtime check, which is why the second example returns `true` — a list is -internally represented as a nested JavaScript array. - -## Examples - -```rescript -Js.Array.isArray([5, 2, 3, 1, 4]) == true -Js.Array.isArray(list{5, 2, 3, 1, 4}) == true -Js.Array.isArray("abcd") == false -``` -*/ - -/** -Returns the number of elements in the array. See [`Array.length`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length) on MDN. -*/ -@deprecated({ - reason: "Use `Array.length` instead.", - migrate: Array.length(), -}) -external length: array<'a> => int = "%array_length" - -/* Mutator functions */ - -/** -Copies from the first element in the given array to the designated `~to_` position, returning the resulting array. *This function modifies the original array.* See [`Array.copyWithin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin) on MDN. - -## Examples - -```rescript -let arr = [100, 101, 102, 103, 104] -Js.Array.copyWithin(~to_=2, arr) == [100, 101, 100, 101, 102] -arr == [100, 101, 100, 101, 102] -``` -*/ -@send -external copyWithin: (t<'a>, ~to_: int) => 'this = "copyWithin" -let copyWithin = (~to_, obj) => copyWithin(obj, ~to_) - -/* ES2015 */ - -/** -Copies starting at element `~from` in the given array to the designated `~to_` position, returning the resulting array. *This function modifies the original array.* See [`Array.copyWithin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin) on MDN. - -## Examples - -```rescript -let arr = [100, 101, 102, 103, 104] -Js.Array.copyWithinFrom(~from=2, ~to_=0, arr) == [102, 103, 104, 103, 104] -arr == [102, 103, 104, 103, 104] -``` -*/ -@send -external copyWithinFrom: (t<'a>, ~to_: int, ~from: int) => 'this = "copyWithin" -let copyWithinFrom = (~to_, ~from, obj) => copyWithinFrom(obj, ~to_, ~from) - -/* ES2015 */ - -/** -Copies starting at element `~start` in the given array up to but not including `~end_` to the designated `~to_` position, returning the resulting array. *This function modifies the original array.* See [`Array.copyWithin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin) on MDN. - -## Examples - -```rescript -let arr = [100, 101, 102, 103, 104, 105] -Js.Array.copyWithinFromRange(~start=2, ~end_=5, ~to_=1, arr) == [100, 102, 103, 104, 104, 105] -arr == [100, 102, 103, 104, 104, 105] -``` -*/ -@send -external copyWithinFromRange: (t<'a>, ~to_: int, ~start: int, ~end_: int) => 'this = "copyWithin" -let copyWithinFromRange = (~to_, ~start, ~end_, obj) => - copyWithinFromRange(obj, ~to_, ~start, ~end_) - -/* ES2015 */ - -/** -Sets all elements of the given array (the second arumgent) to the designated value (the first argument), returning the resulting array. *This function modifies the original array.* See [`Array.fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill) on MDN. - -## Examples - -```rescript -let arr = [100, 101, 102, 103, 104] -Js.Array.fillInPlace(99, arr) == [99, 99, 99, 99, 99] -arr == [99, 99, 99, 99, 99] -``` -*/ -@send -external fillInPlace: (t<'a>, 'a) => 'this = "fill" -let fillInPlace = (arg1, obj) => fillInPlace(obj, arg1) - -/* ES2015 */ - -/** -Sets all elements of the given array (the last arumgent) from position `~from` to the end to the designated value (the first argument), returning the resulting array. *This function modifies the original array.* See [`Array.fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill) on MDN. - -## Examples - -```rescript -let arr = [100, 101, 102, 103, 104] -Js.Array.fillFromInPlace(99, ~from=2, arr) == [100, 101, 99, 99, 99] -arr == [100, 101, 99, 99, 99] -``` -*/ -@send -external fillFromInPlace: (t<'a>, 'a, ~from: int) => 'this = "fill" -let fillFromInPlace = (arg1, ~from, obj) => fillFromInPlace(obj, arg1, ~from) - -/* ES2015 */ - -/** -Sets the elements of the given array (the last arumgent) from position `~start` up to but not including position `~end_` to the designated value (the first argument), returning the resulting array. *This function modifies the original array.* See [`Array.fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill) on MDN. - -## Examples - -```rescript -let arr = [100, 101, 102, 103, 104] -Js.Array.fillRangeInPlace(99, ~start=1, ~end_=4, arr) == [100, 99, 99, 99, 104] -arr == [100, 99, 99, 99, 104] -``` -*/ -@send -external fillRangeInPlace: (t<'a>, 'a, ~start: int, ~end_: int) => 'this = "fill" -let fillRangeInPlace = (arg1, ~start, ~end_, obj) => fillRangeInPlace(obj, arg1, ~start, ~end_) - -/* ES2015 */ - -/** -If the array is not empty, removes the last element and returns it as `Some(value)`; returns `None` if the array is empty. *This function modifies the original array.* See [`Array.pop`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop) on MDN. - -## Examples - -```rescript -let arr = [100, 101, 102, 103, 104] -Js.Array.pop(arr) == Some(104) -arr == [100, 101, 102, 103] - -let empty: array = [] -Js.Array.pop(empty) == None -``` -*/ -@deprecated({ - reason: "Use `Array.pop` instead.", - migrate: Array.pop(), -}) -@send -external pop: t<'a> => option<'a> = "pop" - -/** -Appends the given value to the array, returning the number of elements in the updated array. *This function modifies the original array.* See [`Array.push`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push) on MDN. - -## Examples - -```rescript -let arr = ["ant", "bee", "cat"] -Js.Array.push("dog", arr) == 4 -arr == ["ant", "bee", "cat", "dog"] -``` -*/ -@send -external push: (t<'a>, 'a) => int = "push" -let push = (arg1, obj) => push(obj, arg1) - -/** -Appends the values from one array (the first argument) to another (the second argument), returning the number of elements in the updated array. *This function modifies the original array.* See [`Array.push`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push) on MDN. - -## Examples - -```rescript -let arr = ["ant", "bee", "cat"] -Js.Array.pushMany(["dog", "elk"], arr) == 5 -arr == ["ant", "bee", "cat", "dog", "elk"] -``` -*/ -@send @variadic -external pushMany: (t<'a>, array<'a>) => int = "push" -let pushMany = (arg1, obj) => pushMany(obj, arg1) - -/** -Returns an array with the elements of the input array in reverse order. *This function modifies the original array.* See [`Array.reverse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse) on MDN. - -## Examples - -```rescript -let arr = ["ant", "bee", "cat"] -Js.Array.reverseInPlace(arr) == ["cat", "bee", "ant"] -arr == ["cat", "bee", "ant"] -``` -*/ -@deprecated({ - reason: "Use `Array.reverse` instead.", - migrate: Array.reverse(), -}) -@send -external reverseInPlace: t<'a> => 'this = "reverse" - -/** -If the array is not empty, removes the first element and returns it as `Some(value)`; returns `None` if the array is empty. *This function modifies the original array.* See [`Array.shift`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift) on MDN. - -## Examples - -```rescript -let arr = [100, 101, 102, 103, 104] -Js.Array.shift(arr) == Some(100) -arr == [101, 102, 103, 104] - -let empty: array = [] -Js.Array.shift(empty) == None -``` -*/ -@deprecated({ - reason: "Use `Array.shift` instead.", - migrate: Array.shift(), -}) -@send -external shift: t<'a> => option<'a> = "shift" - -/** -Sorts the given array in place and returns the sorted array. JavaScript sorts the array by converting the arguments to UTF-16 strings and sorting them. See the second example with sorting numbers, which does not do a numeric sort. *This function modifies the original array.* See [`Array.sort`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) on MDN. - -## Examples - -```rescript -let words = ["bee", "dog", "ant", "cat"] -Js.Array.sortInPlace(words) == ["ant", "bee", "cat", "dog"] -words == ["ant", "bee", "cat", "dog"] - -let numbers = [3, 30, 10, 1, 20, 2] -Js.Array.sortInPlace(numbers) == [1, 10, 2, 20, 3, 30] -numbers == [1, 10, 2, 20, 3, 30] -``` -*/ -@deprecated( - "This has been deprecated and will be removed in v13. Use functions from the `Array` module instead." -) -@send -external sortInPlace: t<'a> => 'this = "sort" - -/** -Sorts the given array in place and returns the sorted array. *This function modifies the original array.* - -The first argument to `sortInPlaceWith()` is a function that compares two items from the array and returns: - -* an integer less than zero if the first item is less than the second item -* zero if the items are equal -* an integer greater than zero if the first item is greater than the second item - -See [`Array.sort`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) on MDN. - -## Examples - -```rescript -// sort by word length -let words = ["horse", "aardvark", "dog", "camel"] -let byLength = (s1, s2) => Js.String.length(s1) - Js.String.length(s2) - -Js.Array.sortInPlaceWith(byLength, words) == ["dog", "horse", "camel", "aardvark"] - -// sort in reverse numeric order -let numbers = [3, 30, 10, 1, 20, 2] -let reverseNumeric = (n1, n2) => n2 - n1 -Js.Array.sortInPlaceWith(reverseNumeric, numbers) == [30, 20, 10, 3, 2, 1] -``` -*/ -@send -external sortInPlaceWith: (t<'a>, ('a, 'a) => int) => 'this = "sort" -let sortInPlaceWith = (arg1, obj) => sortInPlaceWith(obj, arg1) - -/** -Starting at position `~pos`, remove `~remove` elements and then add the -elements from the `~add` array. Returns an array consisting of the removed -items. *This function modifies the original array.* See -[`Array.splice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice) -on MDN. - -## Examples - -```rescript -let arr = ["a", "b", "c", "d", "e", "f"] -Js.Array.spliceInPlace(~pos=2, ~remove=2, ~add=["x", "y", "z"], arr) == ["c", "d"] -arr == ["a", "b", "x", "y", "z", "e", "f"] - -let arr2 = ["a", "b", "c", "d"] -Js.Array.spliceInPlace(~pos=3, ~remove=0, ~add=["x", "y"], arr2) == [] -arr2 == ["a", "b", "c", "x", "y", "d"] - -let arr3 = ["a", "b", "c", "d", "e", "f"] -Js.Array.spliceInPlace(~pos=9, ~remove=2, ~add=["x", "y", "z"], arr3) == [] -arr3 == ["a", "b", "c", "d", "e", "f", "x", "y", "z"] -``` -*/ -@send @variadic -external spliceInPlace: (t<'a>, ~pos: int, ~remove: int, ~add: array<'a>) => 'this = "splice" -let spliceInPlace = (~pos, ~remove, ~add, obj) => spliceInPlace(obj, ~pos, ~remove, ~add) - -/** -Removes elements from the given array starting at position `~pos` to the end -of the array, returning the removed elements. *This function modifies the -original array.* See -[`Array.splice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice) -on MDN. - -## Examples - -```rescript -let arr = ["a", "b", "c", "d", "e", "f"] -Js.Array.removeFromInPlace(~pos=4, arr) == ["e", "f"] -arr == ["a", "b", "c", "d"] -``` -*/ -@send -external removeFromInPlace: (t<'a>, ~pos: int) => 'this = "splice" -let removeFromInPlace = (~pos, obj) => removeFromInPlace(obj, ~pos) - -/** -Removes `~count` elements from the given array starting at position `~pos`, -returning the removed elements. *This function modifies the original array.* -See -[`Array.splice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice) -on MDN. - -## Examples - -```rescript -let arr = ["a", "b", "c", "d", "e", "f"] -Js.Array.removeCountInPlace(~pos=2, ~count=3, arr) == ["c", "d", "e"] -arr == ["a", "b", "f"] -``` -*/ -@send -external removeCountInPlace: (t<'a>, ~pos: int, ~count: int) => 'this = "splice" -let removeCountInPlace = (~pos, ~count, obj) => removeCountInPlace(obj, ~pos, ~count) - -/** -Adds the given element to the array, returning the new number of elements in -the array. *This function modifies the original array.* See -[`Array.unshift`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift) -on MDN. - -## Examples - -```rescript -let arr = ["b", "c", "d"] -Js.Array.unshift("a", arr) == 4 -arr == ["a", "b", "c", "d"] -``` -*/ -@send -external unshift: (t<'a>, 'a) => int = "unshift" -let unshift = (arg1, obj) => unshift(obj, arg1) - -/** -Adds the elements in the first array argument at the beginning of the second -array argument, returning the new number of elements in the array. *This -function modifies the original array.* See -[`Array.unshift`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift) -on MDN. - -## Examples - -```rescript -let arr = ["d", "e"] -Js.Array.unshiftMany(["a", "b", "c"], arr) == 5 -arr == ["a", "b", "c", "d", "e"] -``` -*/ -@send @variadic -external unshiftMany: (t<'a>, array<'a>) => int = "unshift" -let unshiftMany = (arg1, obj) => unshiftMany(obj, arg1) - -/* Accessor functions - */ -/** -Concatenates the first array argument to the second array argument, returning -a new array. The original arrays are not modified. See -[`Array.concat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat) -on MDN. - -## Examples - -```rescript -Js.Array.concat(["c", "d", "e"], ["a", "b"]) == ["a", "b", "c", "d", "e"] -``` -*/ -@send -external concat: (t<'a>, 'this) => 'this = "concat" -let concat = (arg1, obj) => concat(obj, arg1) - -/** -The first argument to `concatMany()` is an array of arrays; these are added -at the end of the second argument, returning a new array. See -[`Array.concat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat) -on MDN. - -## Examples - -```rescript -Js.Array.concatMany([["d", "e"], ["f", "g", "h"]], ["a", "b", "c"]) == [ - "a", - "b", - "c", - "d", - "e", - "f", - "g", - "h", - ] -``` -*/ -@send @variadic -external concatMany: (t<'a>, array<'this>) => 'this = "concat" -let concatMany = (arg1, obj) => concatMany(obj, arg1) - -/* ES2016 */ -/** -Returns true if the given value is in the array, `false` otherwise. See -[`Array.includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes) -on MDN. - -## Examples - -```rescript -Js.Array.includes("b", ["a", "b", "c"]) == true -Js.Array.includes("x", ["a", "b", "c"]) == false -``` -*/ -@send -external includes: (t<'a>, 'a) => bool = "includes" -let includes = (arg1, obj) => includes(obj, arg1) - -/** -Returns the index of the first element in the array that has the given value. -If the value is not in the array, returns -1. See -[`Array.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf) -on MDN. - -## Examples - -```rescript -Js.Array.indexOf(102, [100, 101, 102, 103]) == 2 -Js.Array.indexOf(999, [100, 101, 102, 103]) == -1 -``` -*/ -@send -external indexOf: (t<'a>, 'a) => int = "indexOf" -let indexOf = (arg1, obj) => indexOf(obj, arg1) - -/** -Returns the index of the first element in the array with the given value. The -search starts at position `~from`. See -[`Array.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf) -on MDN. - -## Examples - -```rescript -Js.Array.indexOfFrom("a", ~from=2, ["a", "b", "a", "c", "a"]) == 2 -Js.Array.indexOfFrom("a", ~from=3, ["a", "b", "a", "c", "a"]) == 4 -Js.Array.indexOfFrom("b", ~from=2, ["a", "b", "a", "c", "a"]) == -1 -``` -*/ -@send -external indexOfFrom: (t<'a>, 'a, ~from: int) => int = "indexOf" -let indexOfFrom = (arg1, ~from, obj) => indexOfFrom(obj, arg1, ~from) - -@send @deprecated({reason: "Use `Array.join` instead.", migrate: Array.join()}) -external join: t<'a> => string = "join" - -/** -This function converts each element of the array to a string (via JavaScript) -and concatenates them, separated by the string given in the first argument, -into a single string. See -[`Array.join`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join) -on MDN. - -## Examples - -```rescript -Js.Array.joinWith("--", ["ant", "bee", "cat"]) == "ant--bee--cat" -Js.Array.joinWith("", ["door", "bell"]) == "doorbell" -Js.Array.joinWith("/", [2020, 9, 4]) == "2020/9/4" -Js.Array.joinWith(";", [2.5, 3.6, 3e-2]) == "2.5;3.6;0.03" -``` -*/ -@send -external joinWith: (t<'a>, string) => string = "join" -let joinWith = (arg1, obj) => joinWith(obj, arg1) - -/** -Returns the index of the last element in the array that has the given value. -If the value is not in the array, returns -1. See -[`Array.lastIndexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf) -on MDN. - -## Examples - -```rescript -Js.Array.lastIndexOf("a", ["a", "b", "a", "c"]) == 2 -Js.Array.lastIndexOf("x", ["a", "b", "a", "c"]) == -1 -``` -*/ -@send -external lastIndexOf: (t<'a>, 'a) => int = "lastIndexOf" -let lastIndexOf = (arg1, obj) => lastIndexOf(obj, arg1) - -/** -Returns the index of the last element in the array that has the given value, -searching from position `~from` down to the start of the array. If the value -is not in the array, returns -1. See -[`Array.lastIndexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf) -on MDN. - -## Examples - -```rescript -Js.Array.lastIndexOfFrom("a", ~from=3, ["a", "b", "a", "c", "a", "d"]) == 2 -Js.Array.lastIndexOfFrom("c", ~from=2, ["a", "b", "a", "c", "a", "d"]) == -1 -``` -*/ -@send -external lastIndexOfFrom: (t<'a>, 'a, ~from: int) => int = "lastIndexOf" -let lastIndexOfFrom = (arg1, ~from, obj) => lastIndexOfFrom(obj, arg1, ~from) - -/** -Returns a shallow copy of the given array from the `~start` index up to but -not including the `~end_` position. Negative numbers indicate an offset from -the end of the array. See -[`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) -on MDN. - -## Examples - -```rescript -let arr = [100, 101, 102, 103, 104, 105, 106] -Js.Array.slice(~start=2, ~end_=5, arr) == [102, 103, 104] -Js.Array.slice(~start=-3, ~end_=-1, arr) == [104, 105] -Js.Array.slice(~start=9, ~end_=10, arr) == [] -``` -*/ -@send -external slice: (t<'a>, ~start: int, ~end_: int) => 'this = "slice" -let slice = (start, ~end_, ~obj) => slice(obj, ~start, ~end_) - -/** -Returns a copy of the entire array. Same as `Js.Array.Slice(~start=0, -~end_=Js.Array.length(arr), arr)`. See -[`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) -on MDN. -*/ -@deprecated({ - reason: "Use `Array.copy` instead.", - migrate: Array.copy(), -}) -@send -external copy: t<'a> => 'this = "slice" - -/** -Returns a shallow copy of the given array from the given index to the end. -See [`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) on MDN. - -## Examples - -```rescript -Js.Array.sliceFrom(2, [100, 101, 102, 103, 104]) == [102, 103, 104] -``` -*/ -@send -external sliceFrom: (t<'a>, int) => 'this = "slice" -let sliceFrom = (arg1, obj) => sliceFrom(obj, arg1) - -/** -Converts the array to a string. Each element is converted to a string using -JavaScript. Unlike the JavaScript `Array.toString()`, all elements in a -ReasonML array must have the same type. See -[`Array.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString) -on MDN. - -## Examples - -```rescript -Js.Array.toString([3.5, 4.6, 7.8]) == "3.5,4.6,7.8" -Js.Array.toString(["a", "b", "c"]) == "a,b,c" -``` -*/ -@deprecated({ - reason: "Use `Array.toString` instead.", - migrate: Array.toString(), -}) -@send -external toString: t<'a> => string = "toString" - -/** -Converts the array to a string using the conventions of the current locale. -Each element is converted to a string using JavaScript. Unlike the JavaScript -`Array.toLocaleString()`, all elements in a ReasonML array must have the same -type. See -[`Array.toLocaleString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString) -on MDN. - -## Examples - -```rescript -Js.Array.toLocaleString([Js.Date.make()]) -// returns "3/19/2020, 10:52:11 AM" for locale en_US.utf8 -// returns "2020-3-19 10:52:11" for locale de_DE.utf8 -``` -*/ -@deprecated({ - reason: "Use `Array.toLocaleString` instead.", - migrate: Array.toLocaleString(), -}) -@send -external toLocaleString: t<'a> => string = "toLocaleString" - -/* Iteration functions - */ - -/** -The first argument to `every()` is a predicate function that returns a boolean. The `every()` function returns `true` if the predicate function is true for all items in the given array. If given an empty array, returns `true`. See [`Array.every`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every) on MDN. - -## Examples - -```rescript -let isEven = x => mod(x, 2) == 0 -Js.Array.every(isEven, [6, 22, 8, 4]) == true -Js.Array.every(isEven, [6, 22, 7, 4]) == false -``` -*/ -@send -external every: (t<'a>, 'a => bool) => bool = "every" -let every = (arg1, obj) => every(obj, arg1) - -/** -The first argument to `everyi()` is a predicate function with two arguments: an array element and that element’s index; it returns a boolean. The `everyi()` function returns `true` if the predicate function is true for all items in the given array. If given an empty array, returns `true`. See [`Array.every`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every) on MDN. - -## Examples - -```rescript -// determine if all even-index items are positive -let evenIndexPositive = (item, index) => mod(index, 2) == 0 ? item > 0 : true - -Js.Array.everyi(evenIndexPositive, [6, -3, 5, 8]) == true -Js.Array.everyi(evenIndexPositive, [6, 3, -5, 8]) == false -``` -*/ -@send -external everyi: (t<'a>, ('a, int) => bool) => bool = "every" -let everyi = (arg1, obj) => everyi(obj, arg1) - -/** -Applies the given predicate function to each element in the array; the result is an array of those elements for which the predicate function returned `true`. See [`Array.filter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) on MDN. - -## Examples - -```rescript -let nonEmpty = s => s != "" -Js.Array.filter(nonEmpty, ["abc", "", "", "def", "ghi"]) == ["abc", "def", "ghi"] -``` -*/ -@send -external filter: (t<'a>, 'a => bool) => 'this = "filter" -let filter = (arg1, obj) => filter(obj, arg1) - -/** -Each element of the given array are passed to the predicate function. The -return value is an array of all those elements for which the predicate -function returned `true`. See -[`Array.filter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) -on MDN. - -## Examples - -```rescript -// keep only positive elements at odd indices -let positiveOddElement = (item, index) => mod(index, 2) == 1 && item > 0 - -Js.Array.filteri(positiveOddElement, [6, 3, 5, 8, 7, -4, 1]) == [3, 8] -``` -*/ -@send -external filteri: (t<'a>, ('a, int) => bool) => 'this = "filter" -let filteri = (arg1, obj) => filteri(obj, arg1) - -/** -Returns `Some(value)` for the first element in the array that satisifies the -given predicate function, or `None` if no element satisifies the predicate. -See -[`Array.find`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find) -on MDN. - -## Examples - -```rescript -// find first negative element -Js.Array.find(x => x < 0, [33, 22, -55, 77, -44]) == Some(-55) -Js.Array.find(x => x < 0, [33, 22, 55, 77, 44]) == None -``` -*/ -@send -external find: (t<'a>, 'a => bool) => option<'a> = "find" -let find = (arg1, obj) => find(obj, arg1) - -/** -Returns `Some(value)` for the first element in the array that satisifies the given predicate function, or `None` if no element satisifies the predicate. The predicate function takes an array element and an index as its parameters. See [`Array.find`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find) on MDN. - -## Examples - -```rescript -// find first positive item at an odd index -let positiveOddElement = (item, index) => mod(index, 2) == 1 && item > 0 - -Js.Array.findi(positiveOddElement, [66, -33, 55, 88, 22]) == Some(88) -Js.Array.findi(positiveOddElement, [66, -33, 55, -88, 22]) == None -``` -*/ -@send -external findi: (t<'a>, ('a, int) => bool) => option<'a> = "find" -let findi = (arg1, obj) => findi(obj, arg1) - -/** -Returns the index of the first element in the array that satisifies the given predicate function, or -1 if no element satisifies the predicate. See [`Array.find`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find) on MDN. - -## Examples - -```rescript -Js.Array.findIndex(x => x < 0, [33, 22, -55, 77, -44]) == 2 -Js.Array.findIndex(x => x < 0, [33, 22, 55, 77, 44]) == -1 -``` -*/ -@send -external findIndex: (t<'a>, 'a => bool) => int = "findIndex" -let findIndex = (arg1, obj) => findIndex(obj, arg1) - -/** -Returns `Some(value)` for the first element in the array that satisifies the given predicate function, or `None` if no element satisifies the predicate. The predicate function takes an array element and an index as its parameters. See [`Array.find`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find) on MDN. - -## Examples - -```rescript -// find index of first positive item at an odd index -let positiveOddElement = (item, index) => mod(index, 2) == 1 && item > 0 - -Js.Array.findIndexi(positiveOddElement, [66, -33, 55, 88, 22]) == 3 -Js.Array.findIndexi(positiveOddElement, [66, -33, 55, -88, 22]) == -1 -``` -*/ -@send -external findIndexi: (t<'a>, ('a, int) => bool) => int = "findIndex" -let findIndexi = (arg1, obj) => findIndexi(obj, arg1) - -/** -The `forEach()` function applies the function given as the first argument to each element in the array. The function you provide returns `unit`, and the `forEach()` function also returns `unit`. You use `forEach()` when you need to process each element in the array but not return any new array or value; for example, to print the items in an array. See [`Array.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) on MDN. - -## Examples - -```rescript -// display all elements in an array -Js.Array.forEach(x => Js.log(x), ["a", "b", "c"]) == () -``` -*/ -@send -external forEach: (t<'a>, 'a => unit) => unit = "forEach" -let forEach = (arg1, obj) => forEach(obj, arg1) - -/** -The `forEachi()` function applies the function given as the first argument to each element in the array. The function you provide takes an item in the array and its index number, and returns `unit`. The `forEachi()` function also returns `unit`. You use `forEachi()` when you need to process each element in the array but not return any new array or value; for example, to print the items in an array. See [`Array.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) on MDN. - -## Examples - -```rescript -// display all elements in an array as a numbered list -Js.Array.forEachi((item, index) => Js.log2(index + 1, item), ["a", "b", "c"]) == () -``` -*/ -@send -external forEachi: (t<'a>, ('a, int) => unit) => unit = "forEach" -let forEachi = (arg1, obj) => forEachi(obj, arg1) - -/** -Applies the function (given as the first argument) to each item in the array, -returning a new array. The result array does not have to have elements of the -same type as the input array. See -[`Array.map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) -on MDN. - -## Examples - -```rescript -Js.Array.map(x => x * x, [12, 4, 8]) == [144, 16, 64] -Js.Array.map(Js.String.length, ["animal", "vegetable", "mineral"]) == [6, 9, 7] -``` -*/ -@send -external map: (t<'a>, 'a => 'b) => t<'b> = "map" -let map = (arg1, obj) => map(obj, arg1) - -/** -Applies the function (given as the first argument) to each item in the array, -returning a new array. The function acceps two arguments: an item from the -array and its index number. The result array does not have to have elements -of the same type as the input array. See -[`Array.map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) -on MDN. - -## Examples - -```rescript -// multiply each item in array by its position -let product = (item, index) => item * index -Js.Array.mapi(product, [10, 11, 12]) == [0, 11, 24] -``` -*/ -@send -external mapi: (t<'a>, ('a, int) => 'b) => t<'b> = "map" -let mapi = (arg1, obj) => mapi(obj, arg1) - -/** -The `reduce()` function takes three parameters: a *reducer function*, a -beginning accumulator value, and an array. The reducer function has two -parameters: an accumulated value and an element of the array. - -`reduce()` first calls the reducer function with the beginning value and the -first element in the array. The result becomes the new accumulator value, which -is passed in to the reducer function along with the second element in the -array. `reduce()` proceeds through the array, passing in the result of each -stage as the accumulator to the reducer function. - -When all array elements are processed, the final value of the accumulator -becomes the return value of `reduce()`. See -[`Array.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce) -on MDN. - -## Examples - -```rescript -let sumOfSquares = (accumulator, item) => accumulator + item * item - -Js.Array.reduce(sumOfSquares, 0, [10, 2, 4]) == 120 -Js.Array.reduce(\"*", 1, [10, 2, 4]) == 80 -Js.Array.reduce( - (acc, item) => acc + Js.String.length(item), - 0, - ["animal", "vegetable", "mineral"], -) == 22 // 6 + 9 + 7 -Js.Array.reduce((acc, item) => item /. acc, 1.0, [2.0, 4.0]) == 2.0 // 4.0 / (2.0 / 1.0) -``` -*/ -@send -external reduce: (t<'a>, ('b, 'a) => 'b, 'b) => 'b = "reduce" -let reduce = (arg1, arg2, obj) => reduce(obj, arg1, arg2) - -/** -The `reducei()` function takes three parameters: a *reducer function*, a -beginning accumulator value, and an array. The reducer function has three -parameters: an accumulated value, an element of the array, and the index of -that element. - -`reducei()` first calls the reducer function with the beginning value, the -first element in the array, and zero (its index). The result becomes the new -accumulator value, which is passed to the reducer function along with the -second element in the array and one (its index). `reducei()` proceeds from left -to right through the array, passing in the result of each stage as the -accumulator to the reducer function. - -When all array elements are processed, the final value of the accumulator -becomes the return value of `reducei()`. See -[`Array.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce) -on MDN. - -## Examples - -```rescript -// find sum of even-index elements in array -let sumOfEvens = (accumulator, item, index) => - if mod(index, 2) == 0 { - accumulator + item - } else { - accumulator - } - -Js.Array.reducei(sumOfEvens, 0, [2, 5, 1, 4, 3]) == 6 -``` -*/ -@send -external reducei: (t<'a>, ('b, 'a, int) => 'b, 'b) => 'b = "reduce" -let reducei = (arg1, arg2, obj) => reducei(obj, arg1, arg2) - -/** -The `reduceRight()` function takes three parameters: a *reducer function*, a -beginning accumulator value, and an array. The reducer function has two -parameters: an accumulated value and an element of the array. - -`reduceRight()` first calls the reducer function with the beginning value and -the last element in the array. The result becomes the new accumulator value, -which is passed in to the reducer function along with the next-to-last element -in the array. `reduceRight()` proceeds from right to left through the array, -passing in the result of each stage as the accumulator to the reducer function. - -When all array elements are processed, the final value of the accumulator -becomes the return value of `reduceRight()`. See -[`Array.reduceRight`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight) -on MDN. - -**NOTE:** In many cases, `reduce()` and `reduceRight()` give the same result. However, see the last example here and compare it to the example from `reduce()`, where order makes a difference. - -## Examples - -```rescript -let sumOfSquares = (accumulator, item) => accumulator + item * item - -Js.Array.reduceRight(sumOfSquares, 0, [10, 2, 4]) == 120 -Js.Array.reduceRight((acc, item) => item /. acc, 1.0, [2.0, 4.0]) == 0.5 // 2.0 / (4.0 / 1.0) -``` -*/ -@send -external reduceRight: (t<'a>, ('b, 'a) => 'b, 'b) => 'b = "reduceRight" -let reduceRight = (arg1, arg2, obj) => reduceRight(obj, arg1, arg2) - -/** -The `reduceRighti()` function takes three parameters: a *reducer function*, a -beginning accumulator value, and an array. The reducer function has three -parameters: an accumulated value, an element of the array, and the index of -that element. `reduceRighti()` first calls the reducer function with the -beginning value, the last element in the array, and its index (length of array -minus one). The result becomes the new accumulator value, which is passed in to -the reducer function along with the second element in the array and one (its -index). `reduceRighti()` proceeds from right to left through the array, passing -in the result of each stage as the accumulator to the reducer function. - -When all array elements are processed, the final value of the accumulator -becomes the return value of `reduceRighti()`. See -[`Array.reduceRight`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight) -on MDN. - -**NOTE:** In many cases, `reducei()` and `reduceRighti()` give the same result. -However, there are cases where the order in which items are processed makes a -difference. - -## Examples - -```rescript -// find sum of even-index elements in array -let sumOfEvens = (accumulator, item, index) => - if mod(index, 2) == 0 { - accumulator + item - } else { - accumulator - } - -Js.Array.reduceRighti(sumOfEvens, 0, [2, 5, 1, 4, 3]) == 6 -``` -*/ -@send -external reduceRighti: (t<'a>, ('b, 'a, int) => 'b, 'b) => 'b = "reduceRight" -let reduceRighti = (arg1, arg2, obj) => reduceRighti(obj, arg1, arg2) - -/** -Returns `true` if the predicate function given as the first argument to -`some()` returns `true` for any element in the array; `false` otherwise. - -## Examples - -```rescript -let isEven = x => mod(x, 2) == 0 - -Js.Array.some(isEven, [3, 7, 5, 2, 9]) == true -Js.Array.some(isEven, [3, 7, 5, 1, 9]) == false -``` -*/ -@send -external some: (t<'a>, 'a => bool) => bool = "some" -let some = (arg1, obj) => some(obj, arg1) - -/** -Returns `true` if the predicate function given as the first argument to -`somei()` returns `true` for any element in the array; `false` otherwise. The -predicate function has two arguments: an item from the array and the index -value - -## Examples - -```rescript -// Does any string in the array -// have the same length as its index? - -let sameLength = (str, index) => Js.String.length(str) == index - -// "ef" has length 2 and is it at index 2 -Js.Array.somei(sameLength, ["ab", "cd", "ef", "gh"]) == true -// no item has the same length as its index -Js.Array.somei(sameLength, ["a", "bc", "def", "gh"]) == false -``` -*/ -@send -external somei: (t<'a>, ('a, int) => bool) => bool = "some" -let somei = (arg1, obj) => somei(obj, arg1) - -/** -Returns the value at the given position in the array if the position is in -bounds; returns the JavaScript value `undefined` otherwise. - -## Examples - -```rescript -let arr = [100, 101, 102, 103] -Js.Array.unsafe_get(arr, 3) == 103 -Js.Array.unsafe_get(arr, 4) // returns undefined -``` -*/ -@deprecated({ - reason: "Use `Array.getUnsafe` instead.", - migrate: Array.getUnsafe(), -}) -external unsafe_get: (array<'a>, int) => 'a = "%array_unsafe_get" - -/** -Sets the value at the given position in the array if the position is in bounds. -If the index is out of bounds, well, “here there be dragons.“ *This function -modifies the original array.* - -## Examples - -```rescript -let arr = [100, 101, 102, 103] -Js.Array.unsafe_set(arr, 3, 99) -// result is [100, 101, 102, 99] - -Js.Array.unsafe_set(arr, 4, 88) -// result is [100, 101, 102, 99, 88] - -Js.Array.unsafe_set(arr, 6, 77) -// result is [100, 101, 102, 99, 88, <1 empty item>, 77] - -Js.Array.unsafe_set(arr, -1, 66) -// you don't want to know. -``` -*/ -@deprecated({ - reason: "Use `Array.setUnsafe` instead.", - migrate: Array.setUnsafe(), -}) -external unsafe_set: (array<'a>, int, 'a) => unit = "%array_unsafe_set" diff --git a/packages/@rescript/runtime/Js_array2.res b/packages/@rescript/runtime/Js_array2.res deleted file mode 100644 index 4f0ac6133d3..00000000000 --- a/packages/@rescript/runtime/Js_array2.res +++ /dev/null @@ -1,1406 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** -Provides bindings to JavaScript’s `Array` functions. These bindings are optimized for pipe-first (`->`), where the array to be processed is the first parameter in the function. - -Here is an example to find the sum of squares of all even numbers in an array. -Without pipe first, we must call the functions in reverse order: - -## Examples - -```rescript -let isEven = x => mod(x, 2) == 0 -let square = x => x * x -let result = { - open Js.Array2 - reduce(map(filter([5, 2, 3, 4, 1], isEven), square), "+", 0) -} -``` - -With pipe first, we call the functions in the “natural†order: - -```rescript -let isEven = x => mod(x, 2) == 0 -let square = x => x * x -let result = { - open Js.Array2 - [5, 2, 3, 4, 1]->filter(isEven)->map(square)->reduce("+", 0) -} -``` -*/ - -/** -The type used to describe a JavaScript array. -*/ -@deprecated({ - reason: "Use `array` directly instead.", - migrate: %replace.type(: array), -}) -type t<'a> = array<'a> - -/** -A type used to describe JavaScript objects that are like an array or are iterable. -*/ -@deprecated({ - reason: "Use `Array.arrayLike` directly instead.", - migrate: %replace.type(: Array.arrayLike), -}) -type array_like<'a> = Stdlib_Array.arrayLike<'a> - -/* commented out until bs has a plan for iterators - type 'a array_iter = 'a array_like -*/ - -/** -Creates a shallow copy of an array from an array-like object. See -[`Array.from`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from) -on MDN. - -## Examples - -```rescript -let strArr = Js.String.castToArrayLike("abcd") -Js.Array2.from(strArr) == ["a", "b", "c", "d"] -``` -*/ -@deprecated({ - reason: "Use `Array.fromArrayLike` instead.", - migrate: Array.fromArrayLike(), -}) -@val -external from: array_like<'a> => array<'a> = "Array.from" - -/* ES2015 */ - -/** -Creates a new array by applying a function (the second argument) to each item -in the `array_like` first argument. See -[`Array.from`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from) -on MDN. - -## Examples - -```rescript -let strArr = Js.String.castToArrayLike("abcd") -let code = s => Js.String.charCodeAt(0, s) -Js.Array2.fromMap(strArr, code) == [97.0, 98.0, 99.0, 100.0] -``` -*/ -@deprecated({ - reason: "Use `Array.fromArrayLikeWithMap` instead.", - migrate: Array.fromArrayLikeWithMap(), -}) -@val -external fromMap: (array_like<'a>, 'a => 'b) => array<'b> = "Array.from" - -/* ES2015 */ - -/** -Returns `true` if its argument is an array; `false` otherwise. This is a runtime check, which is why the second example returns `true`\---a list is internally represented as a nested JavaScript array. - -## Examples - -```rescript -Js.Array2.isArray([5, 2, 3, 1, 4]) == true -Js.Array2.isArray(list{5, 2, 3, 1, 4}) == true -Js.Array2.isArray("abcd") == false -``` -*/ -@deprecated({ - reason: "Use `Array.isArray` instead.", - migrate: Array.isArray(), -}) -@val -external isArray: 'a => bool = "Array.isArray" - -/** -Returns the number of elements in the array. See -[`Array.length`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length) -on MDN. -*/ -@deprecated({ - reason: "Use `Array.length` instead.", - migrate: Array.length(), -}) -external length: array<'a> => int = "%array_length" - -/* Mutator functions */ - -/** -Copies from the first element in the given array to the designated `~to_` -position, returning the resulting array. *This function modifies the original -array.* See -[`Array.copyWithin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin) -on MDN. - -## Examples - -```rescript -let arr = [100, 101, 102, 103, 104] -Js.Array2.copyWithin(arr, ~to_=2) == [100, 101, 100, 101, 102] -arr == [100, 101, 100, 101, 102] -``` -*/ -@deprecated({ - reason: "Use `Array.copyAllWithin` instead.", - migrate: Array.copyAllWithin(~target=%insert.labelledArgument("to_")), -}) -@send -external copyWithin: (t<'a>, ~to_: int) => t<'a> = "copyWithin" - -/* ES2015 */ - -/** -Copies starting at element `~from` in the given array to the designated `~to_` -position, returning the resulting array. *This function modifies the original -array.* See -[`Array.copyWithin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin) -on MDN. - -## Examples - -```rescript -let arr = [100, 101, 102, 103, 104] -Js.Array2.copyWithinFrom(arr, ~from=2, ~to_=0) == [102, 103, 104, 103, 104] -arr == [102, 103, 104, 103, 104] -``` -*/ -@deprecated({ - reason: "Use `Array.copyWithinToEnd` instead.", - migrate: Array.copyWithinToEnd( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("from"), - ), -}) -@send -external copyWithinFrom: (t<'a>, ~to_: int, ~from: int) => t<'a> = "copyWithin" - -/* ES2015 */ - -/** -Copies starting at element `~start` in the given array up to but not including -`~end_` to the designated `~to_` position, returning the resulting array. *This -function modifies the original array.* See -[`Array.copyWithin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin) -on MDN. - -## Examples - -```rescript -let arr = [100, 101, 102, 103, 104, 105] -Js.Array2.copyWithinFromRange(arr, ~start=2, ~end_=5, ~to_=1) == [100, 102, 103, 104, 104, 105] -arr == [100, 102, 103, 104, 104, 105] -``` -*/ -@deprecated({ - reason: "Use `Array.copyWithin` instead.", - migrate: Array.copyWithin( - ~target=%insert.labelledArgument("to_"), - ~end=%insert.labelledArgument("end_"), - ), -}) -@send -external copyWithinFromRange: (t<'a>, ~to_: int, ~start: int, ~end_: int) => t<'a> = "copyWithin" - -/* ES2015 */ - -/** -Sets all elements of the given array (the first arumgent) to the designated -value (the secon argument), returning the resulting array. *This function -modifies the original array.* - -See -[`Array.fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill) -on MDN. - -## Examples - -```rescript -let arr = [100, 101, 102, 103, 104] -Js.Array2.fillInPlace(arr, 99) == [99, 99, 99, 99, 99] -arr == [99, 99, 99, 99, 99] -``` -*/ -@deprecated({ - reason: "Use `Array.fillAll` instead.", - migrate: Array.fillAll(), -}) -@send -external fillInPlace: (t<'a>, 'a) => t<'a> = "fill" - -/* ES2015 */ - -/** -Sets all elements of the given array (the first arumgent) from position `~from` -to the end to the designated value (the second argument), returning the -resulting array. *This function modifies the original array.* See -[`Array.fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill) -on MDN. - -## Examples - -```rescript -let arr = [100, 101, 102, 103, 104] -Js.Array2.fillFromInPlace(arr, 99, ~from=2) == [100, 101, 99, 99, 99] -arr == [100, 101, 99, 99, 99] -``` -*/ -@deprecated({ - reason: "Use `Array.fillToEnd` instead.", - migrate: Array.fillToEnd(~start=%insert.labelledArgument("from")), -}) -@send -external fillFromInPlace: (t<'a>, 'a, ~from: int) => t<'a> = "fill" - -/* ES2015 */ - -/** -Sets the elements of the given array (the first arumgent) from position -`~start` up to but not including position `~end_` to the designated value (the -second argument), returning the resulting array. *This function modifies the -original array.* See -[`Array.fill`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/fill) -on MDN. - -## Examples - -```rescript -let arr = [100, 101, 102, 103, 104] -Js.Array2.fillRangeInPlace(arr, 99, ~start=1, ~end_=4) == [100, 99, 99, 99, 104] -arr == [100, 99, 99, 99, 104] -``` -*/ -@deprecated({ - reason: "Use `Array.fill` instead.", - migrate: Array.fill(~end=%insert.labelledArgument("end_")), -}) -@send -external fillRangeInPlace: (t<'a>, 'a, ~start: int, ~end_: int) => t<'a> = "fill" - -/* ES2015 */ - -/** -If the array is not empty, removes the last element and returns it as -`Some(value)`; returns `None` if the array is empty. *This function modifies -the original array.* See -[`Array.pop`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop) -on MDN. - -## Examples - -```rescript -let arr = [100, 101, 102, 103, 104] -Js.Array2.pop(arr) == Some(104) -arr == [100, 101, 102, 103] - -let empty: array = [] -Js.Array2.pop(empty) == None -``` -*/ -@deprecated({ - reason: "Use `Array.pop` instead.", - migrate: Array.pop(), -}) -@send -external pop: t<'a> => option<'a> = "pop" - -/** -Appends the given value to the array, returning the number of elements in the -updated array. *This function modifies the original array.* See -[`Array.push`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push) -on MDN. - -## Examples - -```rescript -let arr = ["ant", "bee", "cat"] -Js.Array2.push(arr, "dog") == 4 -arr == ["ant", "bee", "cat", "dog"] -``` -*/ -@deprecated({ - reason: "Use `Array.push` instead. Note: `Array.push` returns `unit`, not the array length.", - migrate: Array.push(), -}) -@send -external push: (t<'a>, 'a) => int = "push" - -/** -Appends the values from one array (the second argument) to another (the first -argument), returning the number of elements in the updated array. *This -function modifies the original array.* See -[`Array.push`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push) -on MDN. - -## Examples - -```rescript -let arr = ["ant", "bee", "cat"] -Js.Array2.pushMany(arr, ["dog", "elk"]) == 5 -arr == ["ant", "bee", "cat", "dog", "elk"] -``` -*/ -@deprecated({ - reason: "Use `Array.pushMany` instead. Note: `Array.pushMany` returns `unit`, not the array length.", - migrate: Array.pushMany(), -}) -@send -@variadic -external pushMany: (t<'a>, array<'a>) => int = "push" - -/** -Returns an array with the elements of the input array in reverse order. *This -function modifies the original array.* See -[`Array.reverse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse) -on MDN. - -## Examples - -```rescript -let arr = ["ant", "bee", "cat"] -Js.Array2.reverseInPlace(arr) == ["cat", "bee", "ant"] -arr == ["cat", "bee", "ant"] -``` -*/ -@deprecated({ - reason: "Use `Array.reverse` instead.", - migrate: Array.reverse(), -}) -@send -external reverseInPlace: t<'a> => t<'a> = "reverse" - -/** -If the array is not empty, removes the first element and returns it as -`Some(value)`; returns `None` if the array is empty. *This function modifies -the original array.* See -[`Array.shift`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift) -on MDN. - -## Examples - -```rescript -let arr = [100, 101, 102, 103, 104] -Js.Array2.shift(arr) == Some(100) -arr == [101, 102, 103, 104] - -let empty: array = [] -Js.Array2.shift(empty) == None -``` -*/ -@deprecated({ - reason: "Use `Array.shift` instead.", - migrate: Array.shift(), -}) -@send -external shift: t<'a> => option<'a> = "shift" - -/** -Sorts the given array in place and returns the sorted array. JavaScript sorts -the array by converting the arguments to UTF-16 strings and sorting them. See -the second example with sorting numbers, which does not do a numeric sort. -*This function modifies the original array.* See -[`Array.sort`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) -on MDN. - -## Examples - -```rescript -let words = ["bee", "dog", "ant", "cat"] -Js.Array2.sortInPlace(words) == ["ant", "bee", "cat", "dog"] -words == ["ant", "bee", "cat", "dog"] - -let numbers = [3, 30, 10, 1, 20, 2] -Js.Array2.sortInPlace(numbers) == [1, 10, 2, 20, 3, 30] -numbers == [1, 10, 2, 20, 3, 30] -``` -*/ -@deprecated({ - reason: "Use `Array.toSorted` instead.", - migrate: Array.toSorted((_a, _b) => - %todo_("This needs a comparator function. Use `String.compare` for strings, etc.") - ), -}) -@send -external sortInPlace: t<'a> => t<'a> = "sort" - -/** -Sorts the given array in place and returns the sorted array. *This function -modifies the original array.* - -The first argument to `sortInPlaceWith()` is a function that compares two items -from the array and returns: - -* an integer less than zero if the first item is less than the second item \* - zero if the items are equal \* an integer greater than zero if the first item is - greater than the second item - -See -[`Array.sort`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) -on MDN. - -## Examples - -```rescript -// sort by word length -let words = ["horse", "aardvark", "dog", "camel"] -let byLength = (s1, s2) => Js.String.length(s1) - Js.String.length(s2) - -Js.Array2.sortInPlaceWith(words, byLength) == ["dog", "horse", "camel", "aardvark"] - -// sort in reverse numeric order -let numbers = [3, 30, 10, 1, 20, 2] -let reverseNumeric = (n1, n2) => n2 - n1 -Js.Array2.sortInPlaceWith(numbers, reverseNumeric) == [30, 20, 10, 3, 2, 1] -``` -*/ -@deprecated({ - reason: "Use `Array.sort` instead.", - migrate: Array.sort(), -}) -@send -external sortInPlaceWith: (t<'a>, ('a, 'a) => int) => t<'a> = "sort" - -/** -Starting at position `~pos`, remove `~remove` elements and then add the -elements from the `~add` array. Returns an array consisting of the removed -items. *This function modifies the original array.* See -[`Array.splice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice) -on MDN. - -## Examples - -```rescript -let arr = ["a", "b", "c", "d", "e", "f"] -Js.Array2.spliceInPlace(arr, ~pos=2, ~remove=2, ~add=["x", "y", "z"]) == ["c", "d"] -arr == ["a", "b", "x", "y", "z", "e", "f"] - -let arr2 = ["a", "b", "c", "d"] -Js.Array2.spliceInPlace(arr2, ~pos=3, ~remove=0, ~add=["x", "y"]) == [] -arr2 == ["a", "b", "c", "x", "y", "d"] - -let arr3 = ["a", "b", "c", "d", "e", "f"] -Js.Array2.spliceInPlace(arr3, ~pos=9, ~remove=2, ~add=["x", "y", "z"]) == [] -arr3 == ["a", "b", "c", "d", "e", "f", "x", "y", "z"] -``` -*/ -@send -@variadic -@deprecated({ - reason: "Use `Array.splice` instead.", - migrate: Array.splice( - ~start=%insert.labelledArgument("pos"), - ~remove=%insert.labelledArgument("remove"), - ~insert=%insert.labelledArgument("add"), - ), -}) -external spliceInPlace: (t<'a>, ~pos: int, ~remove: int, ~add: array<'a>) => t<'a> = "splice" - -/** -Removes elements from the given array starting at position `~pos` to the end of -the array, returning the removed elements. *This function modifies the original -array.* See -[`Array.splice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice) -on MDN. - -## Examples - -```rescript -let arr = ["a", "b", "c", "d", "e", "f"] -Js.Array2.removeFromInPlace(arr, ~pos=4) == ["e", "f"] -arr == ["a", "b", "c", "d"] -``` -*/ -@send -@deprecated({ - reason: "Use `Array.removeInPlace` instead.", - migrate: Array.removeInPlace(%insert.labelledArgument("pos")), -}) -external removeFromInPlace: (t<'a>, ~pos: int) => t<'a> = "splice" - -/** -Removes `~count` elements from the given array starting at position `~pos`, -returning the removed elements. *This function modifies the original array.* -See -[`Array.splice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice) -on MDN. - -## Examples - -```rescript -let arr = ["a", "b", "c", "d", "e", "f"] -Js.Array2.removeCountInPlace(arr, ~pos=2, ~count=3) == ["c", "d", "e"] -arr == ["a", "b", "f"] -``` -*/ -@send -@deprecated({ - reason: "Use `Array.splice` instead.", - migrate: Array.splice( - ~start=%insert.labelledArgument("pos"), - ~remove=%insert.labelledArgument("count"), - ~insert=[], - ), -}) -external removeCountInPlace: (t<'a>, ~pos: int, ~count: int) => t<'a> = "splice" - -/** -Adds the given element to the array, returning the new number of elements in -the array. *This function modifies the original array.* See -[`Array.unshift`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift) -on MDN. - -## Examples - -```rescript -let arr = ["b", "c", "d"] -Js.Array2.unshift(arr, "a") == 4 -arr == ["a", "b", "c", "d"] -``` -*/ -@deprecated({ - reason: "Use `Array.unshift` instead.", - migrate: Array.unshift(), -}) -@send -external unshift: (t<'a>, 'a) => int = "unshift" - -/** -Adds the elements in the second array argument at the beginning of the first -array argument, returning the new number of elements in the array. *This -function modifies the original array.* See -[`Array.unshift`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift) -on MDN. - -## Examples - -```rescript -let arr = ["d", "e"] -Js.Array2.unshiftMany(arr, ["a", "b", "c"]) == 5 -arr == ["a", "b", "c", "d", "e"] -``` -*/ -@deprecated({ - reason: "Use `Array.unshiftMany` instead.", - migrate: Array.unshiftMany(), -}) -@send -@variadic -external unshiftMany: (t<'a>, array<'a>) => int = "unshift" - -/* Accessor functions - */ -@send @deprecated("`append` is not type-safe. Use `concat` instead.") -external append: (t<'a>, 'a) => t<'a> = "concat" - -/** -Concatenates the second array argument to the first array argument, returning a -new array. The original arrays are not modified. See -[`Array.concat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat) -on MDN. - -## Examples - -```rescript -Js.Array2.concat(["a", "b"], ["c", "d", "e"]) == ["a", "b", "c", "d", "e"] -``` -*/ -@deprecated({ - reason: "Use `Array.concat` instead.", - migrate: Array.concat(), -}) -@send -external concat: (t<'a>, t<'a>) => t<'a> = "concat" - -/** -The second argument to `concatMany()` is an array of arrays; these are added at -the end of the first argument, returning a new array. See -[`Array.concat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat) -on MDN. - -## Examples - -```rescript -Js.Array2.concatMany(["a", "b", "c"], [["d", "e"], ["f", "g", "h"]]) == [ - "a", - "b", - "c", - "d", - "e", - "f", - "g", - "h", - ] -``` -*/ -@deprecated({ - reason: "Use `Array.concatMany` instead.", - migrate: Array.concatMany(), -}) -@send -@variadic -external concatMany: (t<'a>, array>) => t<'a> = "concat" - -/** -Returns true if the given value is in the array, `false` otherwise. See -[`Array.includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes) -on MDN. - -## Examples - -```rescript -Js.Array2.includes(["a", "b", "c"], "b") == true -Js.Array2.includes(["a", "b", "c"], "x") == false -``` -*/ -@deprecated({ - reason: "Use `Array.includes` instead.", - migrate: Array.includes(), -}) -@send -external includes: (t<'a>, 'a) => bool = "includes" - -/** -Returns the index of the first element in the array that has the given value. -If the value is not in the array, returns -1. See -[`Array.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf) -on MDN. - -## Examples - -```rescript -Js.Array2.indexOf([100, 101, 102, 103], 102) == 2 -Js.Array2.indexOf([100, 101, 102, 103], 999) == -1 -``` -*/ -@deprecated({ - reason: "Use `Array.indexOf` instead.", - migrate: Array.indexOf(), -}) -@send -external indexOf: (t<'a>, 'a) => int = "indexOf" - -/** -Returns the index of the first element in the array with the given value. The -search starts at position `~from`. See -[`Array.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf) -on MDN. - -## Examples - -```rescript -Js.Array2.indexOfFrom(["a", "b", "a", "c", "a"], "a", ~from=2) == 2 -Js.Array2.indexOfFrom(["a", "b", "a", "c", "a"], "a", ~from=3) == 4 -Js.Array2.indexOfFrom(["a", "b", "a", "c", "a"], "b", ~from=2) == -1 -``` -*/ -@deprecated({ - reason: "Use `Array.indexOfFrom` instead.", - migrate: Array.indexOfFrom(%insert.labelledArgument("from")), -}) -@send -external indexOfFrom: (t<'a>, 'a, ~from: int) => int = "indexOf" - -/** -This function converts each element of the array to a string (via JavaScript) -and concatenates them, separated by the string given in the first argument, -into a single string. See -[`Array.join`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join) -on MDN. - -## Examples - -```rescript -Js.Array2.joinWith(["ant", "bee", "cat"], "--") == "ant--bee--cat" -Js.Array2.joinWith(["door", "bell"], "") == "doorbell" -Js.Array2.joinWith([2020, 9, 4], "/") == "2020/9/4" -Js.Array2.joinWith([2.5, 3.6, 3e-2], ";") == "2.5;3.6;0.03" -``` -*/ -@deprecated({ - reason: "Use `Array.joinUnsafe` instead.", - migrate: Array.joinUnsafe(), -}) -@send -external joinWith: (t<'a>, string) => string = "join" - -/** -Returns the index of the last element in the array that has the given value. If -the value is not in the array, returns -1. See -[`Array.lastIndexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf) -on MDN. - -## Examples - -```rescript -Js.Array2.lastIndexOf(["a", "b", "a", "c"], "a") == 2 -Js.Array2.lastIndexOf(["a", "b", "a", "c"], "x") == -1 -``` -*/ -@deprecated({ - reason: "Use `Array.lastIndexOf` instead.", - migrate: Array.lastIndexOf(), -}) -@send -external lastIndexOf: (t<'a>, 'a) => int = "lastIndexOf" - -/** -Returns the index of the last element in the array that has the given value, -searching from position `~from` down to the start of the array. If the value is -not in the array, returns -1. See -[`Array.lastIndexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf) -on MDN. - -## Examples - -```rescript -Js.Array2.lastIndexOfFrom(["a", "b", "a", "c", "a", "d"], "a", ~from=3) == 2 -Js.Array2.lastIndexOfFrom(["a", "b", "a", "c", "a", "d"], "c", ~from=2) == -1 -``` -*/ -@deprecated({ - reason: "Use `Array.lastIndexOfFrom` instead.", - migrate: Array.lastIndexOfFrom(%insert.labelledArgument("from")), -}) -@send -external lastIndexOfFrom: (t<'a>, 'a, ~from: int) => int = "lastIndexOf" - -/** -Returns a shallow copy of the given array from the `~start` index up to but not -including the `~end_` position. Negative numbers indicate an offset from the -end of the array. See -[`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) -on MDN. - -## Examples - -```rescript -let arr = [100, 101, 102, 103, 104, 105, 106] -Js.Array2.slice(arr, ~start=2, ~end_=5) == [102, 103, 104] -Js.Array2.slice(arr, ~start=-3, ~end_=-1) == [104, 105] -Js.Array2.slice(arr, ~start=9, ~end_=10) == [] -``` -*/ -@deprecated({ - reason: "Use `Array.slice` instead.", - migrate: Array.slice(~end=%insert.labelledArgument("end_")), -}) -@send -external slice: (t<'a>, ~start: int, ~end_: int) => t<'a> = "slice" - -/** -Returns a copy of the entire array. Same as `Js.Array2.Slice(arr, ~start=0, -~end_=Js.Array2.length(arr))`. See -[`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) -on MDN. -*/ -@deprecated({ - reason: "Use `Array.copy` instead.", - migrate: Array.copy(), -}) -@send -external copy: t<'a> => t<'a> = "slice" - -/** -Returns a shallow copy of the given array from the given index to the end. See -[`Array.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice) -on MDN. -*/ -@deprecated({ - reason: "Use `Array.slice` instead.", - migrate: Array.slice(~start=%insert.unlabelledArgument(1)), -}) -@send -external sliceFrom: (t<'a>, int) => t<'a> = "slice" - -/** -Converts the array to a string. Each element is converted to a string using -JavaScript. Unlike the JavaScript `Array.toString()`, all elements in a -ReasonML array must have the same type. See -[`Array.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString) -on MDN. - -## Examples - -```rescript -Js.Array2.toString([3.5, 4.6, 7.8]) == "3.5,4.6,7.8" -Js.Array2.toString(["a", "b", "c"]) == "a,b,c" -``` -*/ -@deprecated({ - reason: "Use `Array.toString` instead.", - migrate: Array.toString(), -}) -@send -external toString: t<'a> => string = "toString" - -/** -Converts the array to a string using the conventions of the current locale. -Each element is converted to a string using JavaScript. Unlike the JavaScript -`Array.toLocaleString()`, all elements in a ReasonML array must have the same -type. See -[`Array.toLocaleString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toLocaleString) -on MDN. - -## Examples - -```rescript -Js.Array2.toLocaleString([Js.Date.make()]) -// returns "3/19/2020, 10:52:11 AM" for locale en_US.utf8 -// returns "2020-3-19 10:52:11" for locale de_DE.utf8 -``` -*/ -@deprecated({ - reason: "Use `Array.toLocaleString` instead.", - migrate: Array.toLocaleString(), -}) -@send -external toLocaleString: t<'a> => string = "toLocaleString" - -/* Iteration functions - */ -/* commented out until bs has a plan for iterators - external entries : 'a t -> (int * 'a) array_iter = "" [@@send] (* ES2015 *) -*/ - -/** -The first argument to `every()` is an array. The second argument is a predicate -function that returns a boolean. The `every()` function returns `true` if the -predicate function is true for all items in the given array. If given an empty -array, returns `true`. See -[`Array.every`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every) -on MDN. - -## Examples - -```rescript -let isEven = x => mod(x, 2) == 0 -Js.Array2.every([6, 22, 8, 4], isEven) == true -Js.Array2.every([6, 22, 7, 4], isEven) == false -``` -*/ -@deprecated({ - reason: "Use `Array.every` instead.", - migrate: Array.every(), -}) -@send -external every: (t<'a>, 'a => bool) => bool = "every" - -/** -The first argument to `everyi()` is an array. The second argument is a -predicate function with two arguments: an array element and that element’s -index; it returns a boolean. The `everyi()` function returns `true` if the -predicate function is true for all items in the given array. If given an empty -array, returns `true`. See -[`Array.every`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every) -on MDN. - -## Examples - -```rescript -// determine if all even-index items are positive -let evenIndexPositive = (item, index) => mod(index, 2) == 0 ? item > 0 : true - -Js.Array2.everyi([6, -3, 5, 8], evenIndexPositive) == true -Js.Array2.everyi([6, 3, -5, 8], evenIndexPositive) == false -``` -*/ -@deprecated({ - reason: "Use `Array.everyWithIndex` instead.", - migrate: Array.everyWithIndex(), -}) -@send -external everyi: (t<'a>, ('a, int) => bool) => bool = "every" - -/** -Applies the given predicate function (the second argument) to each element in -the array; the result is an array of those elements for which the predicate -function returned `true`. See -[`Array.filter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) -on MDN. - -## Examples - -```rescript -let nonEmpty = s => s != "" -Js.Array2.filter(["abc", "", "", "def", "ghi"], nonEmpty) == ["abc", "def", "ghi"] -``` -*/ -@deprecated({ - reason: "Use `Array.filter` instead.", - migrate: Array.filter(), -}) -@send -external filter: (t<'a>, 'a => bool) => t<'a> = "filter" - -/** -Each element of the given array are passed to the predicate function. The -return value is an array of all those elements for which the predicate function -returned `true`. - -See -[`Array.filter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) -on MDN. - -## Examples - -```rescript -// keep only positive elements at odd indices -let positiveOddElement = (item, index) => mod(index, 2) == 1 && item > 0 - -Js.Array2.filteri([6, 3, 5, 8, 7, -4, 1], positiveOddElement) == [3, 8] -``` -*/ -@deprecated({ - reason: "Use `Array.filterWithIndex` instead.", - migrate: Array.filterWithIndex(), -}) -@send -external filteri: (t<'a>, ('a, int) => bool) => t<'a> = "filter" - -/** -Returns `Some(value)` for the first element in the array that satisifies the -given predicate function, or `None` if no element satisifies the predicate. See -[`Array.find`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find) -on MDN. - -## Examples - -```rescript -// find first negative element -Js.Array2.find([33, 22, -55, 77, -44], x => x < 0) == Some(-55) -Js.Array2.find([33, 22, 55, 77, 44], x => x < 0) == None -``` -*/ -@deprecated({ - reason: "Use `Array.find` instead.", - migrate: Array.find(), -}) -@send -external find: (t<'a>, 'a => bool) => option<'a> = "find" - -/* ES2015 */ - -/** -Returns `Some(value)` for the first element in the array that satisifies the -given predicate function, or `None` if no element satisifies the predicate. The -predicate function takes an array element and an index as its parameters. See -[`Array.find`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find) -on MDN. - -## Examples - -```rescript -// find first positive item at an odd index -let positiveOddElement = (item, index) => mod(index, 2) == 1 && item > 0 - -Js.Array2.findi([66, -33, 55, 88, 22], positiveOddElement) == Some(88) -Js.Array2.findi([66, -33, 55, -88, 22], positiveOddElement) == None -``` -*/ -@deprecated({ - reason: "Use `Array.findWithIndex` instead.", - migrate: Array.findWithIndex(), -}) -@send -external findi: (t<'a>, ('a, int) => bool) => option<'a> = "find" - -/* ES2015 */ - -/** -Returns the index of the first element in the array that satisifies the given -predicate function, or -1 if no element satisifies the predicate. See -[`Array.find`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find) -on MDN. - -## Examples - -```rescript -Js.Array2.findIndex([33, 22, -55, 77, -44], x => x < 0) == 2 -Js.Array2.findIndex([33, 22, 55, 77, 44], x => x < 0) == -1 -``` -*/ -@deprecated({ - reason: "Use `Array.findIndex` instead.", - migrate: Array.findIndex(), -}) -@send -external findIndex: (t<'a>, 'a => bool) => int = "findIndex" - -/* ES2015 */ - -/** -Returns `Some(value)` for the first element in the array that satisifies the -given predicate function, or `None` if no element satisifies the predicate. The -predicate function takes an array element and an index as its parameters. See -[`Array.find`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find) -on MDN. - -## Examples - -```rescript -// find index of first positive item at an odd index -let positiveOddElement = (item, index) => mod(index, 2) == 1 && item > 0 - -Js.Array2.findIndexi([66, -33, 55, 88, 22], positiveOddElement) == 3 -Js.Array2.findIndexi([66, -33, 55, -88, 22], positiveOddElement) == -1 -``` -*/ -@deprecated({ - reason: "Use `Array.findIndexWithIndex` instead.", - migrate: Array.findIndexWithIndex(), -}) -@send -external findIndexi: (t<'a>, ('a, int) => bool) => int = "findIndex" - -/* ES2015 */ - -/** -The `forEach()` function applies the function given as the second argument to -each element in the array. The function you provide returns `unit`, and the -`forEach()` function also returns `unit`. You use `forEach()` when you need to -process each element in the array but not return any new array or value; for -example, to print the items in an array. See -[`Array.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) -on MDN. - -## Examples - -```rescript -// display all elements in an array -Js.Array2.forEach(["a", "b", "c"], x => Js.log(x)) == () -``` -*/ -@deprecated({ - reason: "Use `Array.forEach` instead.", - migrate: Array.forEach(), -}) -@send -external forEach: (t<'a>, 'a => unit) => unit = "forEach" - -/** -The `forEachi()` function applies the function given as the second argument to -each element in the array. The function you provide takes an item in the array -and its index number, and returns `unit`. The `forEachi()` function also -returns `unit`. You use `forEachi()` when you need to process each element in -the array but not return any new array or value; for example, to print the -items in an array. See -[`Array.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) -on MDN. - -## Examples - -```rescript -// display all elements in an array as a numbered list -Js.Array2.forEachi(["a", "b", "c"], (item, index) => Js.log2(index + 1, item)) == () -``` -*/ -@deprecated({ - reason: "Use `Array.forEachWithIndex` instead.", - migrate: Array.forEachWithIndex(), -}) -@send -external forEachi: (t<'a>, ('a, int) => unit) => unit = "forEach" - -/* commented out until bs has a plan for iterators - external keys : 'a t -> int array_iter = "" [@@send] (* ES2015 *) -*/ - -/** -Applies the function (the second argument) to each item in the array, returning -a new array. The result array does not have to have elements of the same type -as the input array. See -[`Array.map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) -on MDN. - -## Examples - -```rescript -Js.Array2.map([12, 4, 8], x => x * x) == [144, 16, 64] -Js.Array2.map(["animal", "vegetable", "mineral"], Js.String.length) == [6, 9, 7] -``` -*/ -@deprecated({ - reason: "Use `Array.map` instead.", - migrate: Array.map(), -}) -@send -external map: (t<'a>, 'a => 'b) => t<'b> = "map" - -/** -Applies the function (the second argument) to each item in the array, returning -a new array. The function acceps two arguments: an item from the array and its -index number. The result array does not have to have elements of the same type -as the input array. See -[`Array.map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map) -on MDN. - -## Examples - -```rescript -// multiply each item in array by its position -let product = (item, index) => item * index -Js.Array2.mapi([10, 11, 12], product) == [0, 11, 24] -``` -*/ -@deprecated({ - reason: "Use `Array.mapWithIndex` instead.", - migrate: Array.mapWithIndex(), -}) -@send -external mapi: (t<'a>, ('a, int) => 'b) => t<'b> = "map" - -/** -The `reduce()` function takes three parameters: an array, a *reducer function*, -and a beginning accumulator value. The reducer function has two parameters: an -accumulated value and an element of the array. - -`reduce()` first calls the reducer function with the beginning value and the -first element in the array. The result becomes the new accumulator value, which -is passed in to the reducer function along with the second element in the -array. `reduce()` proceeds through the array, passing in the result of each -stage as the accumulator to the reducer function. - -When all array elements are processed, the final value of the accumulator -becomes the return value of `reduce()`. See -[`Array.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce) -on MDN. - -## Examples - -```rescript -let sumOfSquares = (accumulator, item) => accumulator + item * item - -Js.Array2.reduce([10, 2, 4], sumOfSquares, 0) == 120 -Js.Array2.reduce([10, 2, 4], "*", 1) == 80 -Js.Array2.reduce( - ["animal", "vegetable", "mineral"], - (acc, item) => acc + Js.String.length(item), - 0, -) == 22 // 6 + 9 + 7 -Js.Array2.reduce([2.0, 4.0], (acc, item) => item /. acc, 1.0) == 2.0 // 4.0 / (2.0 / 1.0) -``` -*/ -@deprecated({ - reason: "Use `Array.reduce` instead.", - migrate: Array.reduce(%insert.unlabelledArgument(2), %insert.unlabelledArgument(1)), -}) -@send -external reduce: (t<'a>, ('b, 'a) => 'b, 'b) => 'b = "reduce" - -/** -The `reducei()` function takes three parameters: an array, a *reducer -function*, and a beginning accumulator value. The reducer function has three -parameters: an accumulated value, an element of the array, and the index of -that element. - -`reducei()` first calls the reducer function with the beginning value, the -first element in the array, and zero (its index). The result becomes the new -accumulator value, which is passed to the reducer function along with the -second element in the array and one (its index). `reducei()` proceeds from left -to right through the array, passing in the result of each stage as the -accumulator to the reducer function. - -When all array elements are processed, the final value of the accumulator -becomes the return value of `reducei()`. See -[`Array.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce) -on MDN. - -## Examples - -```rescript -// find sum of even-index elements in array -let sumOfEvens = (accumulator, item, index) => - if mod(index, 2) == 0 { - accumulator + item - } else { - accumulator - } - -Js.Array2.reducei([2, 5, 1, 4, 3], sumOfEvens, 0) == 6 -``` -*/ -@send -@deprecated({ - reason: "Use `Array.reduceWithIndex` instead.", - migrate: Array.reduceWithIndex(%insert.unlabelledArgument(2), %insert.unlabelledArgument(1)), -}) -external reducei: (t<'a>, ('b, 'a, int) => 'b, 'b) => 'b = "reduce" - -/** -The `reduceRight()` function takes three parameters: an array, a *reducer -function*, and a beginning accumulator value. The reducer function has two -parameters: an accumulated value and an element of the array. - -`reduceRight()` first calls the reducer function with the beginning value and -the last element in the array. The result becomes the new accumulator value, -which is passed in to the reducer function along with the next-to-last element -in the array. `reduceRight()` proceeds from right to left through the array, -passing in the result of each stage as the accumulator to the reducer function. - -When all array elements are processed, the final value of the accumulator -becomes the return value of `reduceRight()`. See -[`Array.reduceRight`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight) -on MDN. - -**NOTE:** In many cases, `reduce()` and `reduceRight()` give the same result. -However, see the last example here and compare it to the example from -`reduce()`, where order makes a difference. - -## Examples - -```rescript -let sumOfSquares = (accumulator, item) => accumulator + item * item - -Js.Array2.reduceRight([10, 2, 4], sumOfSquares, 0) == 120 -Js.Array2.reduceRight([2.0, 4.0], (acc, item) => item /. acc, 1.0) == 0.5 // 2.0 / (4.0 / 1.0) -``` -*/ -@send -@deprecated({ - reason: "Use `Array.reduceRight` instead.", - migrate: Array.reduceRight(%insert.unlabelledArgument(2), %insert.unlabelledArgument(1)), -}) -external reduceRight: (t<'a>, ('b, 'a) => 'b, 'b) => 'b = "reduceRight" - -/** -The `reduceRighti()` function takes three parameters: an array, a *reducer -function*, and a beginning accumulator value. The reducer function has three -parameters: an accumulated value, an element of the array, and the index of -that element. `reduceRighti()` first calls the reducer function with the -beginning value, the last element in the array, and its index (length of array -minus one). The result becomes the new accumulator value, which is passed in to -the reducer function along with the second element in the array and one (its -index). `reduceRighti()` proceeds from right to left through the array, passing -in the result of each stage as the accumulator to the reducer function. - -When all array elements are processed, the final value of the accumulator -becomes the return value of `reduceRighti()`. See -[`Array.reduceRight`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight) -on MDN. - -**NOTE:** In many cases, `reducei()` and `reduceRighti()` give the same result. -However, there are cases where the order in which items are processed makes a -difference. - -## Examples - -```rescript -// find sum of even-index elements in array -let sumOfEvens = (accumulator, item, index) => - if mod(index, 2) == 0 { - accumulator + item - } else { - accumulator - } - -Js.Array2.reduceRighti([2, 5, 1, 4, 3], sumOfEvens, 0) == 6 -``` -*/ -@send -@deprecated({ - reason: "Use `Array.reduceRightWithIndex` instead.", - migrate: Array.reduceRightWithIndex(%insert.unlabelledArgument(2), %insert.unlabelledArgument(1)), -}) -external reduceRighti: (t<'a>, ('b, 'a, int) => 'b, 'b) => 'b = "reduceRight" - -/** -Returns `true` if the predicate function given as the second argument to -`some()` returns `true` for any element in the array; `false` otherwise. - -## Examples - -```rescript -let isEven = x => mod(x, 2) == 0 - -Js.Array2.some([3, 7, 5, 2, 9], isEven) == true -Js.Array2.some([3, 7, 5, 1, 9], isEven) == false -``` -*/ -@deprecated({ - reason: "Use `Array.some` instead.", - migrate: Array.some(), -}) -@send -external some: (t<'a>, 'a => bool) => bool = "some" - -/** -Returns `true` if the predicate function given as the second argument to -`somei()` returns `true` for any element in the array; `false` otherwise. The -predicate function has two arguments: an item from the array and the index -value - -## Examples - -```rescript -// Does any string in the array -// have the same length as its index? - -let sameLength = (str, index) => Js.String.length(str) == index - -// "ef" has length 2 and is it at index 2 -Js.Array2.somei(["ab", "cd", "ef", "gh"], sameLength) == true -// no item has the same length as its index -Js.Array2.somei(["a", "bc", "def", "gh"], sameLength) == false -``` -*/ -@deprecated({ - reason: "Use `Array.someWithIndex` instead.", - migrate: Array.someWithIndex(), -}) -@send -external somei: (t<'a>, ('a, int) => bool) => bool = "some" - -/* commented out until bs has a plan for iterators - external values : 'a t -> 'a array_iter = "" [@@send] (* ES2015 *) -*/ - -/** -Returns the value at the given position in the array if the position is in -bounds; returns the JavaScript value `undefined` otherwise. - -## Examples - -```rescript -let arr = [100, 101, 102, 103] -Js.Array2.unsafe_get(arr, 3) == 103 -Js.Array2.unsafe_get(arr, 4) // returns undefined -``` -*/ -@deprecated({ - reason: "Use `Array.getUnsafe` instead.", - migrate: Array.getUnsafe(), -}) -external unsafe_get: (array<'a>, int) => 'a = "%array_unsafe_get" - -/** -Sets the value at the given position in the array if the position is in bounds. -If the index is out of bounds, well, “here there be dragons.“ - -*This function modifies the original array.* - -## Examples - -```rescript -let arr = [100, 101, 102, 103] -Js.Array2.unsafe_set(arr, 3, 99) -// result is [100, 101, 102, 99]; - -Js.Array2.unsafe_set(arr, 4, 88) -// result is [100, 101, 102, 99, 88] - -Js.Array2.unsafe_set(arr, 6, 77) -// result is [100, 101, 102, 99, 88, <1 empty item>, 77] - -Js.Array2.unsafe_set(arr, -1, 66) -// you don't want to know. -``` -*/ -@deprecated({ - reason: "Use `Array.setUnsafe` instead.", - migrate: Array.setUnsafe(), -}) -external unsafe_set: (array<'a>, int, 'a) => unit = "%array_unsafe_set" diff --git a/packages/@rescript/runtime/Js_bigint.res b/packages/@rescript/runtime/Js_bigint.res deleted file mode 100644 index 42ac5a14216..00000000000 --- a/packages/@rescript/runtime/Js_bigint.res +++ /dev/null @@ -1,126 +0,0 @@ -/*** JavaScript BigInt API */ - -/** -Parses the given `string` into a `bigint` using JavaScript semantics. Return the -number as a `bigint` if successfully parsed. Uncaught syntax exception otherwise. - -## Examples - -```rescript -/* returns 123n */ -Js.BigInt.fromStringExn("123") - -/* returns 0n */ -Js.BigInt.fromStringExn("") - -/* returns 17n */ -Js.BigInt.fromStringExn("0x11") - -/* returns 3n */ -Js.BigInt.fromStringExn("0b11") - -/* returns 9n */ -Js.BigInt.fromStringExn("0o11") - -/* catch exception */ -try { - Js.BigInt.fromStringExn("a") -} catch { -| _ => Console.error("Error parsing bigint") -} -``` -*/ -@deprecated({ - reason: "Use `fromStringOrThrow` instead", - migrate: BigInt.fromStringOrThrow(), -}) -@val -external fromStringExn: string => bigint = "BigInt" - -// Operations - -external \"~-": bigint => bigint = "%negbigint" -external \"~+": bigint => bigint = "%identity" -external \"+": (bigint, bigint) => bigint = "%addbigint" -external \"-": (bigint, bigint) => bigint = "%subbigint" -external \"*": (bigint, bigint) => bigint = "%mulbigint" -external \"/": (bigint, bigint) => bigint = "%divbigint" -external mod: (bigint, bigint) => bigint = "%modbigint" -external \"**": (bigint, bigint) => bigint = "%powbigint" - -@deprecated({ - reason: "Use `&&&` operator or `BigInt.bitwiseAnd` instead.", - migrate: %insert.unlabelledArgument(0) &&& %insert.unlabelledArgument(1), - migrateInPipeChain: BigInt.bitwiseAnd(), -}) -external land: (bigint, bigint) => bigint = "%andbigint" - -@deprecated({ - reason: "Use `|||` operator or `BigInt.bitwiseOr` instead.", - migrate: %insert.unlabelledArgument(0) ||| %insert.unlabelledArgument(1), - migrateInPipeChain: BigInt.bitwiseOr(), -}) -external lor: (bigint, bigint) => bigint = "%orbigint" - -@deprecated({ - reason: "Use `^^^` operator or `BigInt.bitwiseXor` instead.", - migrate: %insert.unlabelledArgument(0) ^^^ %insert.unlabelledArgument(1), - migrateInPipeChain: BigInt.bitwiseXor(), -}) -external lxor: (bigint, bigint) => bigint = "%xorbigint" - -@deprecated({ - reason: "Use `~~~` operator or `BigInt.bitwiseNot` instead.", - migrate: ~~~(%insert.unlabelledArgument(0)), - migrateInPipeChain: BigInt.bitwiseNot(), -}) -let lnot = x => lxor(x, -1n) - -@deprecated({ - reason: "Use `<<` operator or `BigInt.shiftLeft` instead.", - migrate: %insert.unlabelledArgument(0) << %insert.unlabelledArgument(1), - migrateInPipeChain: BigInt.shiftLeft(), -}) -external lsl: (bigint, bigint) => bigint = "%lslbigint" - -@deprecated({ - reason: "Use `>>` operator or `BigInt.shiftRight` instead.", - migrate: %insert.unlabelledArgument(0) >> %insert.unlabelledArgument(1), - migrateInPipeChain: BigInt.shiftRight(), -}) -external asr: (bigint, bigint) => bigint = "%asrbigint" - -/** -Formats a `bigint` as a string. Return a `string` representing the given value. -See [`toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString) on MDN. - -## Examples - -```rescript -/* prints "123" */ -Js.BigInt.toString(123n)->Js.log -``` -*/ -@deprecated({ - reason: "Use `BigInt.toString` instead.", - migrate: BigInt.toString(), -}) -@send -external toString: bigint => string = "toString" - -/** -Returns a string with a language-sensitive representation of this BigInt value. - -## Examples - -```rescript -/* prints "123" */ -Js.BigInt.toString(123n)->Js.log -``` -*/ -@deprecated({ - reason: "Use `BigInt.toLocaleString` instead.", - migrate: BigInt.toLocaleString(), -}) -@send -external toLocaleString: bigint => string = "toLocaleString" diff --git a/packages/@rescript/runtime/Js_blob.res b/packages/@rescript/runtime/Js_blob.res deleted file mode 100644 index 969208cea11..00000000000 --- a/packages/@rescript/runtime/Js_blob.res +++ /dev/null @@ -1,3 +0,0 @@ -/*** JavaScript Blob API */ - -type t diff --git a/packages/@rescript/runtime/Js_console.res b/packages/@rescript/runtime/Js_console.res deleted file mode 100644 index 594ff1bb61b..00000000000 --- a/packages/@rescript/runtime/Js_console.res +++ /dev/null @@ -1,195 +0,0 @@ -@deprecated({ - reason: "Use `Console.log` instead.", - migrate: Console.log(), -}) -@val -@scope("console") -external log: 'a => unit = "log" - -@deprecated({ - reason: "Use `Console.log2` instead.", - migrate: Console.log2(), -}) -@val -@scope("console") -external log2: ('a, 'b) => unit = "log" - -@deprecated({ - reason: "Use `Console.log3` instead.", - migrate: Console.log3(), -}) -@val -@scope("console") -external log3: ('a, 'b, 'c) => unit = "log" - -@deprecated({ - reason: "Use `Console.log4` instead.", - migrate: Console.log4(), -}) -@val -@scope("console") -external log4: ('a, 'b, 'c, 'd) => unit = "log" - -@deprecated({ - reason: "Use `Console.logMany` instead.", - migrate: Console.logMany(), -}) -@val -@scope("console") -@variadic -external logMany: array<'a> => unit = "log" - -@deprecated({ - reason: "Use `Console.info` instead.", - migrate: Console.info(), -}) -@val -@scope("console") -external info: 'a => unit = "info" - -@deprecated({ - reason: "Use `Console.info2` instead.", - migrate: Console.info2(), -}) -@val -@scope("console") -external info2: ('a, 'b) => unit = "info" - -@deprecated({ - reason: "Use `Console.info3` instead.", - migrate: Console.info3(), -}) -@val -@scope("console") -external info3: ('a, 'b, 'c) => unit = "info" - -@deprecated({ - reason: "Use `Console.info4` instead.", - migrate: Console.info4(), -}) -@val -@scope("console") -external info4: ('a, 'b, 'c, 'd) => unit = "info" - -@deprecated({ - reason: "Use `Console.infoMany` instead.", - migrate: Console.infoMany(), -}) -@val -@scope("console") -@variadic -external infoMany: array<'a> => unit = "info" - -@deprecated({ - reason: "Use `Console.warn` instead.", - migrate: Console.warn(), -}) -@val -@scope("console") -external warn: 'a => unit = "warn" - -@deprecated({ - reason: "Use `Console.warn2` instead.", - migrate: Console.warn2(), -}) -@val -@scope("console") -external warn2: ('a, 'b) => unit = "warn" - -@deprecated({ - reason: "Use `Console.warn3` instead.", - migrate: Console.warn3(), -}) -@val -@scope("console") -external warn3: ('a, 'b, 'c) => unit = "warn" - -@deprecated({ - reason: "Use `Console.warn4` instead.", - migrate: Console.warn4(), -}) -@val -@scope("console") -external warn4: ('a, 'b, 'c, 'd) => unit = "warn" - -@deprecated({ - reason: "Use `Console.warnMany` instead.", - migrate: Console.warnMany(), -}) -@val -@scope("console") -@variadic -external warnMany: array<'a> => unit = "warn" - -@deprecated({ - reason: "Use `Console.error` instead.", - migrate: Console.error(), -}) -@val -@scope("console") -external error: 'a => unit = "error" - -@deprecated({ - reason: "Use `Console.error2` instead.", - migrate: Console.error2(), -}) -@val -@scope("console") -external error2: ('a, 'b) => unit = "error" - -@deprecated({ - reason: "Use `Console.error3` instead.", - migrate: Console.error3(), -}) -@val -@scope("console") -external error3: ('a, 'b, 'c) => unit = "error" - -@deprecated({ - reason: "Use `Console.error4` instead.", - migrate: Console.error4(), -}) -@val -@scope("console") -external error4: ('a, 'b, 'c, 'd) => unit = "error" - -@deprecated({ - reason: "Use `Console.errorMany` instead.", - migrate: Console.errorMany(), -}) -@val -@scope("console") -@variadic -external errorMany: array<'a> => unit = "error" - -@deprecated({ - reason: "Use `Console.trace` instead.", - migrate: Console.trace(), -}) -@val -@scope("console") -external trace: unit => unit = "trace" - -@deprecated({ - reason: "Use `Console.time` instead.", - migrate: Console.time(), -}) -@val -@scope("console") -external timeStart: string => unit = "time" - -@deprecated({ - reason: "Use `Console.timeEnd` instead.", - migrate: Console.timeEnd(), -}) -@val -@scope("console") -external timeEnd: string => unit = "timeEnd" - -@deprecated({ - reason: "Use `Console.table` instead.", - migrate: Console.table(), -}) -@val -@scope("console") -external table: 'a => unit = "table" diff --git a/packages/@rescript/runtime/Js_date.res b/packages/@rescript/runtime/Js_date.res deleted file mode 100644 index 3235e2820f0..00000000000 --- a/packages/@rescript/runtime/Js_date.res +++ /dev/null @@ -1,1802 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** -Provide bindings to JS date. (See -[`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) -on MDN.) JavaScript stores dates as the number of milliseconds since the UNIX -*epoch*, midnight 1 January 1970, UTC. -*/ - -@deprecated({ - reason: "Use `Date.t` instead.", - migrate: %replace.type(: Date.t), -}) -type t = Stdlib_Date.t - -/** -Returns the primitive value of this date, equivalent to `getTime()`. (See -[`Date.valueOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/valueOf) -on MDN.) - -## Examples - -```rescript -Js.Date.valueOf(exampleDate) == 123456654321.0 -``` -*/ -@deprecated({ - reason: "Use `Date.getTime` instead.", - migrate: Date.getTime(), -}) -@send -external valueOf: t => float = "valueOf" - -/** -Returns a date representing the current time. See [`Date()` -Constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date) -on MDN. - -## Examples - -```rescript -let now = Js.Date.make() -``` -*/ -@deprecated({ - reason: "Use `Date.make` instead.", - migrate: Date.make(), -}) -@new -external make: unit => t = "Date" - -/** -Returns a date representing the given argument, which is a number of -milliseconds since the epoch. See [`Date()` -Constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date) -on MDN. - -## Examples - -```rescript -Js.Date.fromFloat(123456654321.0) == exampleDate -``` -*/ -@deprecated({ - reason: "Use `Date.fromTime` instead.", - migrate: Date.fromTime(), -}) -@new -external fromFloat: float => t = "Date" - -/** -Returns a `Js.Date.t` represented by the given string. The string can be in -“IETF-compliant RFC 2822 timestamps, and also strings in a version of ISO8601.†-Returns `NaN` if given an invalid date string. According to the [`Date()` -Constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date) -documentation on MDN, its use is discouraged. - -## Examples - -```rescript -Js.Date.fromString("Thu, 29 Nov 1973 21:30:54.321 GMT") == exampleDate -Js.Date.fromString("1973-11-29T21:30:54.321Z00:00") == exampleDate -Js.Date.fromString("Thor, 32 Lok -19 60:70:80 XYZ") // returns NaN -``` -*/ -@deprecated({ - reason: "Use `Date.fromString` instead.", - migrate: Date.fromString(), -}) -@new -external fromString: string => t = "Date" - -/** -Returns a date representing midnight of the first day of the given month and -year in the current time zone. Fractional parts of arguments are ignored. See -[`Date()` -Constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date) -on MDN. - -## Examples - -```rescript -let november1 = Js.Date.makeWithYM(~year=2020.0, ~month=10.0, ()) -``` -*/ -@deprecated({ - reason: "Use `Date.makeWithYM` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.makeWithYM( - ~year=Float.toInt(%insert.labelledArgument("year")), - ~month=Float.toInt(%insert.labelledArgument("month")), - ), -}) -@new -external makeWithYM: (~year: float, ~month: float, unit) => t = "Date" - -/** -Returns a date representing midnight of the given date of the given month and -year in the current time zone. Fractional parts of arguments are ignored. See -[`Date()` -Constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date) -on MDN. -*/ -@deprecated({ - reason: "Use `Date.makeWithYMD` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.makeWithYMD( - ~year=Float.toInt(%insert.labelledArgument("year")), - ~month=Float.toInt(%insert.labelledArgument("month")), - ~day=Float.toInt(%insert.labelledArgument("date")), - ), -}) -@new -external makeWithYMD: (~year: float, ~month: float, ~date: float, unit) => t = "Date" - -/** -Returns a date representing the given date of the given month and year, at zero -minutes and zero seconds past the given `hours`, in the current time zone. -Fractional parts of arguments are ignored. See [`Date()` -Constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date) -on MDN. Fractional parts of the arguments are ignored. -*/ -@deprecated({ - reason: "Use `Date.makeWithYMDH` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.makeWithYMDH( - ~year=Float.toInt(%insert.labelledArgument("year")), - ~month=Float.toInt(%insert.labelledArgument("month")), - ~day=Float.toInt(%insert.labelledArgument("date")), - ~hours=Float.toInt(%insert.labelledArgument("hours")), - ), -}) -@new -external makeWithYMDH: (~year: float, ~month: float, ~date: float, ~hours: float, unit) => t = - "Date" - -/** -Returns a date representing the given date of the given month and year, at zero -seconds past the given time in hours and minutes in the current time zone. -Fractional parts of arguments are ignored. See [`Date()` -Constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date) -on MDN. -*/ -@deprecated({ - reason: "Use `Date.makeWithYMDHM` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.makeWithYMDHM( - ~year=Float.toInt(%insert.labelledArgument("year")), - ~month=Float.toInt(%insert.labelledArgument("month")), - ~day=Float.toInt(%insert.labelledArgument("date")), - ~hours=Float.toInt(%insert.labelledArgument("hours")), - ~minutes=Float.toInt(%insert.labelledArgument("minutes")), - ), -}) -@new -external makeWithYMDHM: ( - ~year: float, - ~month: float, - ~date: float, - ~hours: float, - ~minutes: float, - unit, -) => t = "Date" - -/** -Returns a date representing the given date of the given month and year, at the -given time in hours, minutes, and seconds in the current time zone. Fractional -parts of arguments are ignored. See [`Date()` -Constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date) -on MDN. - -## Examples - -```rescript -Js.Date.makeWithYMDHMS( - ~year=1973.0, - ~month=11.0, - ~date=29.0, - ~hours=21.0, - ~minutes=30.0, - ~seconds=54.321, - (), -) == exampleDate -``` -*/ -@deprecated({ - reason: "Use `Date.makeWithYMDHMS` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.makeWithYMDHMS( - ~year=Float.toInt(%insert.labelledArgument("year")), - ~month=Float.toInt(%insert.labelledArgument("month")), - ~day=Float.toInt(%insert.labelledArgument("date")), - ~hours=Float.toInt(%insert.labelledArgument("hours")), - ~minutes=Float.toInt(%insert.labelledArgument("minutes")), - ~seconds=Float.toInt(%insert.labelledArgument("seconds")), - ), -}) -@new -external makeWithYMDHMS: ( - ~year: float, - ~month: float, - ~date: float, - ~hours: float, - ~minutes: float, - ~seconds: float, - unit, -) => t = "Date" - -/** -Returns a float representing the number of milliseconds past the epoch for -midnight of the first day of the given month and year in UTC. Fractional parts -of arguments are ignored. See -[`Date.UTC`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC) -on MDN. - -## Examples - -```rescript -let november1 = Js.Date.utcWithYM(~year=2020.0, ~month=10.0, ()) -``` -*/ -@deprecated({ - reason: "Use `Date.UTC.makeWithYM` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.UTC.makeWithYM( - ~year=Float.toInt(%insert.labelledArgument("year")), - ~month=Float.toInt(%insert.labelledArgument("month")), - ), -}) -@val("Date.UTC") -external utcWithYM: (~year: float, ~month: float, unit) => float = "" - -/** -Returns a float representing the number of milliseconds past the epoch for -midnight of the given date of the given month and year in UTC. Fractional parts -of arguments are ignored. See -[`Date.UTC`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC) -on MDN. -*/ -@deprecated({ - reason: "Use `Date.UTC.makeWithYMD` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.UTC.makeWithYMD( - ~year=Float.toInt(%insert.labelledArgument("year")), - ~month=Float.toInt(%insert.labelledArgument("month")), - ~day=Float.toInt(%insert.labelledArgument("date")), - ), -}) -@val("Date.UTC") -external utcWithYMD: (~year: float, ~month: float, ~date: float, unit) => float = "" - -/** -Returns a float representing the number of milliseconds past the epoch for -midnight of the given date of the given month and year, at zero minutes and -seconds past the given hours in UTC. Fractional parts of arguments are ignored. -See -[`Date.UTC`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC) -on MDN. -*/ -@deprecated({ - reason: "Use `Date.UTC.makeWithYMDH` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.UTC.makeWithYMDH( - ~year=Float.toInt(%insert.labelledArgument("year")), - ~month=Float.toInt(%insert.labelledArgument("month")), - ~day=Float.toInt(%insert.labelledArgument("date")), - ~hours=Float.toInt(%insert.labelledArgument("hours")), - ), -}) -@val("Date.UTC") -external utcWithYMDH: (~year: float, ~month: float, ~date: float, ~hours: float, unit) => float = "" - -/** -Returns a float representing the number of milliseconds past the epoch for -midnight of the given date of the given month and year, at zero seconds past -the given number of minutes past the given hours in UTC. Fractional parts of -arguments are ignored. See -[`Date.UTC`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC) -on MDN. -*/ -@deprecated({ - reason: "Use `Date.UTC.makeWithYMDHM` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.UTC.makeWithYMDHM( - ~year=Float.toInt(%insert.labelledArgument("year")), - ~month=Float.toInt(%insert.labelledArgument("month")), - ~day=Float.toInt(%insert.labelledArgument("date")), - ~hours=Float.toInt(%insert.labelledArgument("hours")), - ~minutes=Float.toInt(%insert.labelledArgument("minutes")), - ), -}) -@val("Date.UTC") -external utcWithYMDHM: ( - ~year: float, - ~month: float, - ~date: float, - ~hours: float, - ~minutes: float, - unit, -) => float = "" - -/** -Returns a float representing the number of milliseconds past the epoch for -midnight of the given date of the given month and year, at the given time in -hours, minutes and seconds in UTC. Fractional parts of arguments are ignored. - -See -[`Date.UTC`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/UTC) -on MDN. -*/ -@deprecated({ - reason: "Use `Date.UTC.makeWithYMDHMS` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.UTC.makeWithYMDHMS( - ~year=Float.toInt(%insert.labelledArgument("year")), - ~month=Float.toInt(%insert.labelledArgument("month")), - ~day=Float.toInt(%insert.labelledArgument("date")), - ~hours=Float.toInt(%insert.labelledArgument("hours")), - ~minutes=Float.toInt(%insert.labelledArgument("minutes")), - ~seconds=Float.toInt(%insert.labelledArgument("seconds")), - ), -}) -@val("Date.UTC") -external utcWithYMDHMS: ( - ~year: float, - ~month: float, - ~date: float, - ~hours: float, - ~minutes: float, - ~seconds: float, - unit, -) => float = "" - -/** Returns the current time as number of milliseconds since Unix epoch. */ -@deprecated({ - reason: "Use `Date.now` instead.", - migrate: Date.now(), -}) -@val("Date.now") -external now: unit => float = "" - -@new -@deprecated({ - reason: "Use `Date.fromString` instead.", - migrate: Date.fromString(), -}) -external parse: string => t = "Date" - -/** -Returns a float with the number of milliseconds past the epoch represented by -the given string. The string can be in “IETF-compliant RFC 2822 timestamps, and -also strings in a version of ISO8601.†Returns `NaN` if given an invalid date -string. According to the -[`Date.parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse) -documentation on MDN, its use is discouraged. Returns `NaN` if passed invalid -date string. -*/ -@deprecated({ - reason: "Use `Date.fromString` + `Date.getTime` instead.", - migrate: Date.getTime(Date.fromString(%insert.unlabelledArgument(0))), -}) -@val("parse") -@scope("Date") -external parseAsFloat: string => float = "" - -/** -Returns the day of the month for its argument. The argument is evaluated in the -current time zone. See -[`Date.getDate`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDate) -on MDN. - -## Examples - -```rescript -Js.Date.getDate(exampleDate) == 29.0 -``` -*/ -@deprecated({ - reason: "Use `Date.getDate` instead.", - migrate: Date.getDate(), -}) -@send -external getDate: t => float = "getDate" - -/** -Returns the day of the week (0.0-6.0) for its argument, where 0.0 represents -Sunday. The argument is evaluated in the current time zone. See -[`Date.getDay`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getDay) -on MDN. - -## Examples - -```rescript -Js.Date.getDay(exampleDate) == 4.0 -``` -*/ -@deprecated({ - reason: "Use `Date.getDay` instead.", - migrate: Date.getDay(), -}) -@send -external getDay: t => float = "getDay" - -/** -Returns the full year (as opposed to the range 0-99) for its argument. The -argument is evaluated in the current time zone. See -[`Date.getFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getFullYear) -on MDN. - -## Examples - -```rescript -Js.Date.getFullYear(exampleDate) == 1973.0 -``` -*/ -@deprecated({ - reason: "Use `Date.getFullYear` instead.", - migrate: Date.getFullYear(), -}) -@send -external getFullYear: t => float = "getFullYear" - -/** -Returns the hours for its argument, evaluated in the current time zone. See -[`Date.getHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getHours) -on MDN. - -## Examples - -```rescript -Js.Date.getHours(exampleDate) == 22.0 // Vienna is in GMT+01:00 -``` -*/ -@deprecated({ - reason: "Use `Date.getHours` instead.", - migrate: Date.getHours(), -}) -@send -external getHours: t => float = "getHours" - -/** -Returns the number of milliseconds for its argument, evaluated in the current -time zone. See -[`Date.getMilliseconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds) -on MDN. - -## Examples - -```rescript -Js.Date.getMilliseconds(exampleDate) == 321.0 -``` -*/ -@deprecated({ - reason: "Use `Date.getMilliseconds` instead.", - migrate: Date.getMilliseconds(), -}) -@send -external getMilliseconds: t => float = "getMilliseconds" - -/** -Returns the number of minutes for its argument, evaluated in the current time -zone. See -[`Date.getMinutes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMinutes) -on MDN. - -## Examples - -```rescript -Js.Date.getMinutes(exampleDate) == 30.0 -``` -*/ -@deprecated({ - reason: "Use `Date.getMinutes` instead.", - migrate: Date.getMinutes(), -}) -@send -external getMinutes: t => float = "getMinutes" - -/** -Returns the month (0.0-11.0) for its argument, evaluated in the current time -zone. January is month zero. See -[`Date.getMonth`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMonth) -on MDN. - -## Examples - -```rescript -Js.Date.getMonth(exampleDate) == 10.0 -``` -*/ -@deprecated({ - reason: "Use `Date.getMonth` instead.", - migrate: Date.getMonth(), -}) -@send -external getMonth: t => float = "getMonth" - -/** -Returns the seconds for its argument, evaluated in the current time zone. See -[`Date.getSeconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getSeconds) -on MDN. - -## Examples - -```rescript -Js.Date.getSeconds(exampleDate) == 54.0 -``` -*/ -@deprecated({ - reason: "Use `Date.getSeconds` instead.", - migrate: Date.getSeconds(), -}) -@send -external getSeconds: t => float = "getSeconds" - -/** -Returns the number of milliseconds since Unix epoch, evaluated in UTC. See -[`Date.getTime`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime) -on MDN. - -## Examples - -```rescript -Js.Date.getTime(exampleDate) == 123456654321.0 -``` -*/ -@deprecated({ - reason: "Use `Date.getTime` instead.", - migrate: Date.getTime(), -}) -@send -external getTime: t => float = "getTime" - -/** -Returns the time zone offset in minutes from the current time zone to UTC. See -[`Date.getTimezoneOffset`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset) -on MDN. - -## Examples - -```rescript -Js.Date.getTimezoneOffset(exampleDate) == -60.0 -``` -*/ -@deprecated({ - reason: "Use `Date.getTimezoneOffset` instead.", - migrate: Date.getTimezoneOffset(), -}) -@send -external getTimezoneOffset: t => float = "getTimezoneOffset" - -/** -Returns the day of the month of the argument, evaluated in UTC. See -[`Date.getUTCDate`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDate) -on MDN. - -## Examples - -```rescript -Js.Date.getUTCDate(exampleDate) == 29.0 -``` -*/ -@deprecated({ - reason: "Use `Date.getUTCDate` instead.", - migrate: Date.getUTCDate(), -}) -@send -external getUTCDate: t => float = "getUTCDate" - -/** -Returns the day of the week of the argument, evaluated in UTC. The range of the -return value is 0.0-6.0, where Sunday is zero. See -[`Date.getUTCDay`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCDay) -on MDN. - -## Examples - -```rescript -Js.Date.getUTCDay(exampleDate) == 4.0 -``` -*/ -@deprecated({ - reason: "Use `Date.getUTCDay` instead.", - migrate: Date.getUTCDay(), -}) -@send -external getUTCDay: t => float = "getUTCDay" - -/** -Returns the full year (as opposed to the range 0-99) for its argument. The -argument is evaluated in UTC. See -[`Date.getUTCFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCFullYear) -on MDN. - -## Examples - -```rescript -Js.Date.getUTCFullYear(exampleDate) == 1973.0 -``` -*/ -@deprecated({ - reason: "Use `Date.getUTCFullYear` instead.", - migrate: Date.getUTCFullYear(), -}) -@send -external getUTCFullYear: t => float = "getUTCFullYear" - -/** -Returns the hours for its argument, evaluated in the current time zone. See -[`Date.getUTCHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCHours) -on MDN. - -## Examples - -```rescript -Js.Date.getUTCHours(exampleDate) == 21.0 -``` -*/ -@deprecated({ - reason: "Use `Date.getUTCHours` instead.", - migrate: Date.getUTCHours(), -}) -@send -external getUTCHours: t => float = "getUTCHours" - -/** -Returns the number of milliseconds for its argument, evaluated in UTC. See -[`Date.getUTCMilliseconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds) -on MDN. - -## Examples - -```rescript -Js.Date.getUTCMilliseconds(exampleDate) == 321.0 -``` -*/ -@deprecated({ - reason: "Use `Date.getUTCMilliseconds` instead.", - migrate: Date.getUTCMilliseconds(), -}) -@send -external getUTCMilliseconds: t => float = "getUTCMilliseconds" - -/** -Returns the number of minutes for its argument, evaluated in UTC. See -[`Date.getUTCMinutes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMinutes) -on MDN. - -## Examples - -```rescript -Js.Date.getUTCMinutes(exampleDate) == 30.0 -``` -*/ -@deprecated({ - reason: "Use `Date.getUTCMinutes` instead.", - migrate: Date.getUTCMinutes(), -}) -@send -external getUTCMinutes: t => float = "getUTCMinutes" - -/** -Returns the month (0.0-11.0) for its argument, evaluated in UTC. January is -month zero. See -[`Date.getUTCMonth`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth) -on MDN. - -## Examples - -```rescript -Js.Date.getUTCMonth(exampleDate) == 10.0 -``` -*/ -@deprecated({ - reason: "Use `Date.getUTCMonth` instead.", - migrate: Date.getUTCMonth(), -}) -@send -external getUTCMonth: t => float = "getUTCMonth" - -/** -Returns the seconds for its argument, evaluated in UTC. See -[`Date.getUTCSeconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCSeconds) -on MDN. - -## Examples - -```rescript -Js.Date.getUTCSeconds(exampleDate) == 54.0 -``` -*/ -@deprecated({ - reason: "Use `Date.getUTCSeconds` instead.", - migrate: Date.getUTCSeconds(), -}) -@send -external getUTCSeconds: t => float = "getUTCSeconds" - -@send @deprecated({reason: "Use `getFullYear` instead.", migrate: Date.getFullYear()}) -external getYear: t => float = "getYear" - -/** -Sets the given `Date`’s day of month to the value in the second argument -according to the current time zone. Returns the number of milliseconds since -the epoch of the updated `Date`. *This function modifies the original `Date`.* -See -[`Date.setDate`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setDate) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let twoWeeksBefore = Js.Date.setDate(date1, 15.0) -date1 == Js.Date.fromString("1973-11-15T21:30:54.321Z00:00") -twoWeeksBefore == Js.Date.getTime(date1) -``` -*/ -@deprecated({ - reason: "Use `Date.setDate` instead.", - migrate: Date.setDate(Float.toInt(%insert.unlabelledArgument(1))), -}) -@send -external setDate: (t, float) => float = "setDate" - -/** -Sets the given `Date`’s year to the value in the second argument according to -the current time zone. Returns the number of milliseconds since the epoch of -the updated `Date`. *This function modifies the original `Date`.* See -[`Date.setFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let nextYear = Js.Date.setFullYear(date1, 1974.0) -date1 == Js.Date.fromString("1974-11-15T21:30:54.321Z00:00") -nextYear == Js.Date.getTime(date1) -``` -*/ -@deprecated({ - reason: "Use `Date.setFullYear` instead.", - migrate: Date.setFullYear(Float.toInt(%insert.unlabelledArgument(1))), -}) -@send -external setFullYear: (t, float) => float = "setFullYear" - -/** -Sets the given `Date`’s year and month to the values in the labeled arguments -according to the current time zone. Returns the number of milliseconds since -the epoch of the updated `Date`. *This function modifies the original `Date`.* -See -[`Date.setFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let future = Js.Date.setFullYearM(date1, ~year=1974.0, ~month=0.0, ()) -date1 == Js.Date.fromString("1974-01-22T21:30:54.321Z00:00") -future == Js.Date.getTime(date1) -``` -*/ -@deprecated({ - reason: "Use `Date.setFullYearM` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.setFullYearM( - ~year=Float.toInt(%insert.labelledArgument("year")), - ~month=Float.toInt(%insert.labelledArgument("month")), - ), -}) -@send -external setFullYearM: (t, ~year: float, ~month: float, unit) => float = "setFullYear" - -/** -Sets the given `Date`’s year, month, and day of month to the values in the -labeled arguments according to the current time zone. Returns the number of -milliseconds since the epoch of the updated `Date`. *This function modifies the -original `Date`.* See -[`Date.setFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setFullYear) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let future = Js.Date.setFullYearMD(date1, ~year=1974.0, ~month=0.0, ~date=7.0, ()) -date1 == Js.Date.fromString("1974-01-07T21:30:54.321Z00:00") -future == Js.Date.getTime(date1) -``` -*/ -@send -@deprecated({ - reason: "Use `Date.setFullYearMD` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.setFullYearMD( - ~year=Float.toInt(%insert.labelledArgument("year")), - ~month=Float.toInt(%insert.labelledArgument("month")), - ~day=Float.toInt(%insert.labelledArgument("date")), - ), -}) -external setFullYearMD: (t, ~year: float, ~month: float, ~date: float, unit) => float = - "setFullYear" - -/** -Sets the given `Date`’s hours to the value in the second argument according to -the current time zone. Returns the number of milliseconds since the epoch of -the updated `Date`. *This function modifies the original `Date`.* See -[`Date.setHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let nextHour = Js.Date.setHours(date1, 22.0) -date1 == Js.Date.fromString("1973-11-29T22:30:54.321Z00:00") -nextHour == Js.Date.getTime(date1) -``` -*/ -@deprecated({ - reason: "Use `Date.setHours` instead.", - migrate: Date.setHours(Float.toInt(%insert.unlabelledArgument(1))), -}) -@send -external setHours: (t, float) => float = "setHours" - -/** -Sets the given `Date`’s hours and minutes to the values in the labeled -arguments according to the current time zone. Returns the number of -milliseconds since the epoch of the updated `Date`. *This function modifies the -original `Date`.* See -[`Date.setHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let futureTime = Js.Date.setHoursM(date1, ~hours=22.0, ~minutes=46.0, ()) -date1 == Js.Date.fromString("1973-11-29T22:46:54.321Z00:00") -futureTime == Js.Date.getTime(date1) -``` -*/ -@deprecated({ - reason: "Use `Date.setHoursM` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.setHoursM( - ~hours=Float.toInt(%insert.labelledArgument("hours")), - ~minutes=Float.toInt(%insert.labelledArgument("minutes")), - ), -}) -@send -external setHoursM: (t, ~hours: float, ~minutes: float, unit) => float = "setHours" - -/** -Sets the given `Date`’s hours, minutes, and seconds to the values in the -labeled arguments according to the current time zone. Returns the number of -milliseconds since the epoch of the updated `Date`. *This function modifies the -original `Date`.* See -[`Date.setHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let futureTime = Js.Date.setHoursMS(date1, ~hours=22.0, ~minutes=46.0, ~seconds=37.0, ()) -date1 == Js.Date.fromString("1973-11-29T22:46:37.321Z00:00") -futureTime == Js.Date.getTime(date1) -``` -*/ -@send -@deprecated({ - reason: "Use `Date.setHoursMS` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.setHoursMS( - ~hours=Float.toInt(%insert.labelledArgument("hours")), - ~minutes=Float.toInt(%insert.labelledArgument("minutes")), - ~seconds=Float.toInt(%insert.labelledArgument("seconds")), - ), -}) -external setHoursMS: (t, ~hours: float, ~minutes: float, ~seconds: float, unit) => float = - "setHours" - -/** -Sets the given `Date`’s hours, minutes, seconds, and milliseconds to the values -in the labeled arguments according to the current time zone. Returns the number -of milliseconds since the epoch of the updated `Date`. *This function modifies -the original `Date`.* See -[`Date.setHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setHours) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let futureTime = Js.Date.setHoursMSMs( - date1, - ~hours=22.0, - ~minutes=46.0, - ~seconds=37.0, - ~milliseconds=494.0, - (), -) -date1 == Js.Date.fromString("1973-11-29T22:46:37.494Z00:00") -futureTime == Js.Date.getTime(date1) -``` -*/ -@send -@deprecated({ - reason: "Use `Date.setHoursMSMs` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.setHoursMSMs( - ~hours=Float.toInt(%insert.labelledArgument("hours")), - ~minutes=Float.toInt(%insert.labelledArgument("minutes")), - ~seconds=Float.toInt(%insert.labelledArgument("seconds")), - ~milliseconds=Float.toInt(%insert.labelledArgument("milliseconds")), - ), -}) -external setHoursMSMs: ( - t, - ~hours: float, - ~minutes: float, - ~seconds: float, - ~milliseconds: float, - unit, -) => float = "setHours" - -/** -Sets the given `Date`’s milliseconds to the value in the second argument -according to the current time zone. Returns the number of milliseconds since -the epoch of the updated `Date`. *This function modifies the original `Date`.* -See -[`Date.setMilliseconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMilliseconds) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let futureTime = Js.Date.setMilliseconds(date1, 494.0) -date1 == Js.Date.fromString("1973-11-29T21:30:54.494Z00:00") -futureTime == Js.Date.getTime(date1) -``` -*/ -@deprecated({ - reason: "Use `Date.setMilliseconds` instead.", - migrate: Date.setMilliseconds(Float.toInt(%insert.unlabelledArgument(1))), -}) -@send -external setMilliseconds: (t, float) => float = "setMilliseconds" - -/** -Sets the given `Date`’s minutes to the value in the second argument according -to the current time zone. Returns the number of milliseconds since the epoch of -the updated `Date`. *This function modifies the original `Date`.* See -[`Date.setMinutes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let futureTime = Js.Date.setMinutes(date1, 34.0) -date1 == Js.Date.fromString("1973-11-29T21:34:54.494Z00:00") -futureTime == Js.Date.getTime(date1) -``` -*/ -@deprecated({ - reason: "Use `Date.setMinutes` instead.", - migrate: Date.setMinutes(Float.toInt(%insert.unlabelledArgument(1))), -}) -@send -external setMinutes: (t, float) => float = "setMinutes" - -/** -Sets the given `Date`’s minutes and seconds to the values in the labeled -arguments according to the current time zone. Returns the number of -milliseconds since the epoch of the updated `Date`. *This function modifies the -original `Date`.* See -[`Date.setMinutes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let futureTime = Js.Date.setMinutesS(date1, ~minutes=34.0, ~seconds=56.0, ()) -date1 == Js.Date.fromString("1973-11-29T21:34:56.494Z00:00") -futureTime == Js.Date.getTime(date1) -``` -*/ -@send -@deprecated({ - reason: "Use `Date.setMinutesS` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.setMinutesS( - ~minutes=Float.toInt(%insert.labelledArgument("minutes")), - ~seconds=Float.toInt(%insert.labelledArgument("seconds")), - ), -}) -external setMinutesS: (t, ~minutes: float, ~seconds: float, unit) => float = "setMinutes" - -/** -Sets the given `Date`’s minutes, seconds, and milliseconds to the values in the -labeled arguments according to the current time zone. Returns the number of -milliseconds since the epoch of the updated `Date`. *This function modifies the -original `Date`.* See -[`Date.setMinutes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMinutes) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let futureTime = Js.Date.setMinutesSMs(date1, ~minutes=34.0, ~seconds=56.0, ~milliseconds=789.0, ()) -date1 == Js.Date.fromString("1973-11-29T21:34:56.789Z00:00") -futureTime == Js.Date.getTime(date1) -``` -*/ -@send -@deprecated({ - reason: "Use `Date.setMinutesSMs` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.setMinutesSMs( - ~minutes=Float.toInt(%insert.labelledArgument("minutes")), - ~seconds=Float.toInt(%insert.labelledArgument("seconds")), - ~milliseconds=Float.toInt(%insert.labelledArgument("milliseconds")), - ), -}) -external setMinutesSMs: (t, ~minutes: float, ~seconds: float, ~milliseconds: float, unit) => float = - "setMinutes" - -/** -Sets the given `Date`’s month to the value in the second argument according to -the current time zone. Returns the number of milliseconds since the epoch of -the updated `Date`. *This function modifies the original `Date`.* See -[`Date.setMonth`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMonth) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let futureTime = Js.Date.setMonth(date1, 11.0) -date1 == Js.Date.fromString("1973-12-29T21:34:56.789Z00:00") -futureTime == Js.Date.getTime(date1) -``` -*/ -@deprecated({ - reason: "Use `Date.setMonth` instead.", - migrate: Date.setMonth(Float.toInt(%insert.unlabelledArgument(1))), -}) -@send -external setMonth: (t, float) => float = "setMonth" - -/** -Sets the given `Date`’s month and day of month to the values in the labeled -arguments according to the current time zone. Returns the number of -milliseconds since the epoch of the updated `Date`. *This function modifies the -original `Date`.* See -[`Date.setMonth`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setMonth) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let futureTime = Js.Date.setMonthD(date1, ~month=11.0, ~date=8.0, ()) -date1 == Js.Date.fromString("1973-12-08T21:34:56.789Z00:00") -futureTime == Js.Date.getTime(date1) -``` -*/ -@deprecated("Use `Date.setMonth` then `Date.setDate`. No direct 1:1 migration available.") @send -external setMonthD: (t, ~month: float, ~date: float, unit) => float = "setMonth" - -/** -Sets the given `Date`’s seconds to the value in the second argument according -to the current time zone. Returns the number of milliseconds since the epoch of -the updated `Date`. *This function modifies the original `Date`.* See -[`Date.setSeconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setSeconds) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let futureTime = Js.Date.setSeconds(date1, 56.0) -date1 == Js.Date.fromString("1973-12-29T21:30:56.321Z00:00") -futureTime == Js.Date.getTime(date1) -``` -*/ -@deprecated({ - reason: "Use `Date.setSeconds` instead.", - migrate: Date.setSeconds(Float.toInt(%insert.unlabelledArgument(1))), -}) -@send -external setSeconds: (t, float) => float = "setSeconds" - -/** -Sets the given `Date`’s seconds and milliseconds to the values in the labeled -arguments according to the current time zone. Returns the number of -milliseconds since the epoch of the updated `Date`. *This function modifies the -original `Date`.* See -[`Date.setSeconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setSeconds) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let futureTime = Js.Date.setSecondsMs(date1, ~seconds=56.0, ~milliseconds=789.0, ()) -date1 == Js.Date.fromString("1973-12-29T21:30:56.789Z00:00") -futureTime == Js.Date.getTime(date1) -``` -*/ -@send -@deprecated({ - reason: "Use `Date.setSecondsMs` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.setSecondsMs( - ~seconds=Float.toInt(%insert.labelledArgument("seconds")), - ~milliseconds=Float.toInt(%insert.labelledArgument("milliseconds")), - ), -}) -external setSecondsMs: (t, ~seconds: float, ~milliseconds: float, unit) => float = "setSeconds" - -/** -Sets the given `Date`’s value in terms of milliseconds since the epoch. Returns -the number of milliseconds since the epoch of the updated `Date`. *This -function modifies the original `Date`.* See -[`Date.setTime`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setTime) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let futureTime = Js.Date.setTime(date1, 198765432101.0) - -date1 == Js.Date.fromString("1976-04-19T12:37:12.101Z00:00") -futureTime == Js.Date.getTime(date1) -``` -*/ -@send @deprecated -external setTime: (t, float) => float = "setTime" - -/** -Sets the given `Date`’s day of month to the value in the second argument -according to UTC. Returns the number of milliseconds since the epoch of the -updated `Date`. *This function modifies the original `Date`.* See -[`Date.setUTCDate`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCDate) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let twoWeeksBefore = Js.Date.setUTCDate(date1, 15.0) -date1 == Js.Date.fromString("1973-11-15T21:30:54.321Z00:00") -twoWeeksBefore == Js.Date.getTime(date1) -``` -*/ -@deprecated({ - reason: "Use `Date.setUTCDate` instead.", - migrate: Date.setUTCDate(Float.toInt(%insert.unlabelledArgument(1))), -}) -@send -external setUTCDate: (t, float) => float = "setUTCDate" - -/** -Sets the given `Date`’s year to the value in the second argument according to -UTC. Returns the number of milliseconds since the epoch of the updated `Date`. -*This function modifies the original `Date`.* See -[`Date.setUTCFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let nextYear = Js.Date.setUTCFullYear(date1, 1974.0) -date1 == Js.Date.fromString("1974-11-15T21:30:54.321Z00:00") -nextYear == Js.Date.getTime(date1) -``` -*/ -@deprecated({ - reason: "Use `Date.setUTCFullYear` instead.", - migrate: Date.setUTCFullYear(Float.toInt(%insert.unlabelledArgument(1))), -}) -@send -external setUTCFullYear: (t, float) => float = "setUTCFullYear" - -/** -Sets the given `Date`’s year and month to the values in the labeled arguments -according to UTC. Returns the number of milliseconds since the epoch of the -updated `Date`. *This function modifies the original `Date`.* See -[`Date.setUTCFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let future = Js.Date.setUTCFullYearM(date1, ~year=1974.0, ~month=0.0, ()) -date1 == Js.Date.fromString("1974-01-22T21:30:54.321Z00:00") -future == Js.Date.getTime(date1) -``` -*/ -@send -@deprecated({ - reason: "Use `Date.setUTCFullYearM` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.setUTCFullYearM( - ~year=Float.toInt(%insert.labelledArgument("year")), - ~month=Float.toInt(%insert.labelledArgument("month")), - ), -}) -external setUTCFullYearM: (t, ~year: float, ~month: float, unit) => float = "setUTCFullYear" - -/** -Sets the given `Date`’s year, month, and day of month to the values in the -labeled arguments according to UTC. Returns the number of milliseconds since -the epoch of the updated `Date`. *This function modifies the original `Date`.* -See -[`Date.setUTCFullYear`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCFullYear) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let future = Js.Date.setUTCFullYearMD(date1, ~year=1974.0, ~month=0.0, ~date=7.0, ()) -date1 == Js.Date.fromString("1974-01-07T21:30:54.321Z00:00") -future == Js.Date.getTime(date1) -``` -*/ -@send -@deprecated({ - reason: "Use `Date.setUTCFullYearMD` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.setUTCFullYearMD( - ~year=Float.toInt(%insert.labelledArgument("year")), - ~month=Float.toInt(%insert.labelledArgument("month")), - ~day=Float.toInt(%insert.labelledArgument("date")), - ), -}) -external setUTCFullYearMD: (t, ~year: float, ~month: float, ~date: float, unit) => float = - "setUTCFullYear" - -/** -Sets the given `Date`’s hours to the value in the second argument according to -UTC. Returns the number of milliseconds since the epoch of the updated `Date`. -*This function modifies the original `Date`.* See -[`Date.setUTCHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let nextHour = Js.Date.setUTCHours(date1, 22.0) -date1 == Js.Date.fromString("1973-11-29T22:30:54.321Z00:00") -nextHour == Js.Date.getTime(date1) -``` -*/ -@deprecated({ - reason: "Use `Date.setUTCHours` instead.", - migrate: Date.setUTCHours(Float.toInt(%insert.unlabelledArgument(1))), -}) -@send -external setUTCHours: (t, float) => float = "setUTCHours" - -/** -Sets the given `Date`’s hours and minutes to the values in the labeled -arguments according to UTC. Returns the number of milliseconds since the epoch -of the updated `Date`. *This function modifies the original `Date`.* See -[`Date.setUTCHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let futureTime = Js.Date.setUTCHoursM(date1, ~hours=22.0, ~minutes=46.0, ()) -date1 == Js.Date.fromString("1973-11-29T22:46:54.321Z00:00") -futureTime == Js.Date.getTime(date1) -``` -*/ -@send -@deprecated({ - reason: "Use `Date.setUTCHoursM` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.setUTCHoursM( - ~hours=Float.toInt(%insert.labelledArgument("hours")), - ~minutes=Float.toInt(%insert.labelledArgument("minutes")), - ), -}) -external setUTCHoursM: (t, ~hours: float, ~minutes: float, unit) => float = "setUTCHours" - -/** -Sets the given `Date`’s hours, minutes, and seconds to the values in the -labeled arguments according to UTC. Returns the number of milliseconds since -the epoch of the updated `Date`. *This function modifies the original `Date`.* - -See -[`Date.setUTCHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let futureTime = Js.Date.setUTCHoursMS(date1, ~hours=22.0, ~minutes=46.0, ~seconds=37.0, ()) -date1 == Js.Date.fromString("1973-11-29T22:46:37.321Z00:00") -futureTime == Js.Date.getTime(date1) -``` -*/ -@send -@deprecated({ - reason: "Use `Date.setUTCHoursMS` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.setUTCHoursMS( - ~hours=Float.toInt(%insert.labelledArgument("hours")), - ~minutes=Float.toInt(%insert.labelledArgument("minutes")), - ~seconds=Float.toInt(%insert.labelledArgument("seconds")), - ), -}) -external setUTCHoursMS: (t, ~hours: float, ~minutes: float, ~seconds: float, unit) => float = - "setUTCHours" - -/** -Sets the given `Date`’s hours, minutes, seconds, and milliseconds to the values -in the labeled arguments according to UTC. Returns the number of milliseconds -since the epoch of the updated `Date`. *This function modifies the original -`Date`.* See -[`Date.setUTCHours`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCHours) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let futureTime = Js.Date.setUTCHoursMSMs( - date1, - ~hours=22.0, - ~minutes=46.0, - ~seconds=37.0, - ~milliseconds=494.0, - (), -) -date1 == Js.Date.fromString("1973-11-29T22:46:37.494Z00:00") -futureTime == Js.Date.getTime(date1) -``` -*/ -@send -@deprecated({ - reason: "Use `Date.setUTCHoursMSMs` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.setUTCHoursMSMs( - ~hours=Float.toInt(%insert.labelledArgument("hours")), - ~minutes=Float.toInt(%insert.labelledArgument("minutes")), - ~seconds=Float.toInt(%insert.labelledArgument("seconds")), - ~milliseconds=Float.toInt(%insert.labelledArgument("milliseconds")), - ), -}) -external setUTCHoursMSMs: ( - t, - ~hours: float, - ~minutes: float, - ~seconds: float, - ~milliseconds: float, - unit, -) => float = "setUTCHours" - -/** -Sets the given `Date`’s milliseconds to the value in the second argument -according to UTC. Returns the number of milliseconds since the epoch of the -updated `Date`. *This function modifies the original `Date`.* See -[`Date.setUTCMilliseconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMilliseconds) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let futureTime = Js.Date.setUTCMilliseconds(date1, 494.0) -date1 == Js.Date.fromString("1973-11-29T21:30:54.494Z00:00") -futureTime == Js.Date.getTime(date1) -``` -*/ -@deprecated({ - reason: "Use `Date.setUTCMilliseconds` instead.", - migrate: Date.setUTCMilliseconds(Float.toInt(%insert.unlabelledArgument(1))), -}) -@send -external setUTCMilliseconds: (t, float) => float = "setUTCMilliseconds" - -/** -Sets the given `Date`’s minutes to the value in the second argument according -to the current time zone. Returns the number of milliseconds since the epoch of -the updated `Date`. *This function modifies the original `Date`.* See -[`Date.setUTCMinutes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMinutes) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let futureTime = Js.Date.setUTCMinutes(date1, 34.0) -date1 == Js.Date.fromString("1973-11-29T21:34:54.494Z00:00") -futureTime == Js.Date.getTime(date1) -``` -*/ -@deprecated({ - reason: "Use `Date.setUTCMinutes` instead.", - migrate: Date.setUTCMinutes(Float.toInt(%insert.unlabelledArgument(1))), -}) -@send -external setUTCMinutes: (t, float) => float = "setUTCMinutes" - -/** -Sets the given `Date`’s minutes and seconds to the values in the labeled -arguments according to UTC. Returns the number of milliseconds since the epoch -of the updated `Date`. *This function modifies the original `Date`.* See -[`Date.setUTCMinutes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMinutes) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let futureTime = Js.Date.setUTCMinutesS(date1, ~minutes=34.0, ~seconds=56.0, ()) -date1 == Js.Date.fromString("1973-11-29T21:34:56.494Z00:00") -futureTime == Js.Date.getTime(date1) -``` -*/ -@send -@deprecated({ - reason: "Use `Date.setUTCMinutesS` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.setUTCMinutesS( - ~minutes=Float.toInt(%insert.labelledArgument("minutes")), - ~seconds=Float.toInt(%insert.labelledArgument("seconds")), - ), -}) -external setUTCMinutesS: (t, ~minutes: float, ~seconds: float, unit) => float = "setUTCMinutes" - -/** -Sets the given `Date`’s minutes, seconds, and milliseconds to the values in the -labeled arguments according to UTC. Returns the number of milliseconds since -the epoch of the updated `Date`. *This function modifies the original `Date`.* -See -[`Date.setUTCMinutes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMinutes) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let futureTime = Js.Date.setUTCMinutesSMs( - date1, - ~minutes=34.0, - ~seconds=56.0, - ~milliseconds=789.0, - (), -) -date1 == Js.Date.fromString("1973-11-29T21:34:56.789Z00:00") -futureTime == Js.Date.getTime(date1) -``` -*/ -@send -@deprecated({ - reason: "Use `Date.setUTCMinutesSMs` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.setUTCMinutesSMs( - ~minutes=Float.toInt(%insert.labelledArgument("minutes")), - ~seconds=Float.toInt(%insert.labelledArgument("seconds")), - ~milliseconds=Float.toInt(%insert.labelledArgument("milliseconds")), - ), -}) -external setUTCMinutesSMs: ( - t, - ~minutes: float, - ~seconds: float, - ~milliseconds: float, - unit, -) => float = "setUTCMinutes" - -/** -Sets the given `Date`’s month to the value in the second argument according to -UTC. Returns the number of milliseconds since the epoch of the updated `Date`. -*This function modifies the original `Date`.* See -[`Date.setUTCMonth`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMonth) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let futureTime = Js.Date.setUTCMonth(date1, 11.0) -date1 == Js.Date.fromString("1973-12-29T21:34:56.789Z00:00") -futureTime == Js.Date.getTime(date1) -``` -*/ -@deprecated({ - reason: "Use `Date.setUTCMonth` instead.", - migrate: Date.setUTCMonth(Float.toInt(%insert.unlabelledArgument(1))), -}) -@send -external setUTCMonth: (t, float) => float = "setUTCMonth" - -/** -Sets the given `Date`’s month and day of month to the values in the labeled -arguments according to UTC. Returns the number of milliseconds since the epoch -of the updated `Date`. *This function modifies the original `Date`.* See -[`Date.setUTCMonth`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCMonth) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let futureTime = Js.Date.setUTCMonthD(date1, ~month=11.0, ~date=8.0, ()) -date1 == Js.Date.fromString("1973-12-08T21:34:56.789Z00:00") -futureTime == Js.Date.getTime(date1) -``` -*/ -@deprecated("Use `Date.setUTCMonth` then `Date.setUTCDate`. No direct 1:1 migration available.") -@send -external setUTCMonthD: (t, ~month: float, ~date: float, unit) => float = "setUTCMonth" - -/** -Sets the given `Date`’s seconds to the value in the second argument according -to UTC. Returns the number of milliseconds since the epoch of the updated -`Date`. *This function modifies the original `Date`.* See -[`Date.setUTCSeconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCSeconds) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let futureTime = Js.Date.setUTCSeconds(date1, 56.0) -date1 == Js.Date.fromString("1973-12-29T21:30:56.321Z00:00") -futureTime == Js.Date.getTime(date1) -``` -*/ -@deprecated({ - reason: "Use `Date.setUTCSeconds` instead.", - migrate: Date.setUTCSeconds(Float.toInt(%insert.unlabelledArgument(1))), -}) -@send -external setUTCSeconds: (t, float) => float = "setUTCSeconds" - -/** -Sets the given `Date`’s seconds and milliseconds to the values in the labeled -arguments according to UTC. Returns the number of milliseconds since the epoch -of the updated `Date`. *This function modifies the original `Date`.* See -[`Date.setUTCSeconds`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setUTCSeconds) -on MDN. - -## Examples - -```rescript -let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT -let futureTime = Js.Date.setUTCSecondsMs(date1, ~seconds=56.0, ~milliseconds=789.0, ()) -date1 == Js.Date.fromString("1973-12-29T21:30:56.789Z00:00") -futureTime == Js.Date.getTime(date1) -``` -*/ -@send -@deprecated({ - reason: "Use `Date.setUTCSecondsMs` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Date.setUTCSecondsMs( - ~seconds=Float.toInt(%insert.labelledArgument("seconds")), - ~milliseconds=Float.toInt(%insert.labelledArgument("milliseconds")), - ), -}) -external setUTCSecondsMs: (t, ~seconds: float, ~milliseconds: float, unit) => float = - "setUTCSeconds" - -/** Same as [`setTime()`](#settime). */ -@deprecated @send -external setUTCTime: (t, float) => float = "setTime" - -@send @deprecated("Use `setFullYear` instead") external setYear: (t, float) => float = "setYear" - -/** -Returns the date (day of week, year, month, and day of month) portion of a -`Date` in English. See -[`Date.toDateString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toDateString) -on MDN. - -## Examples - -```rescript -Js.Date.toDateString(exampleDate) == "Thu Nov 29 1973" -``` -*/ -@deprecated({ - reason: "Use `Date.toDateString` instead.", - migrate: Date.toDateString(), -}) -@send -external toDateString: t => string = "toDateString" - -@send -@deprecated({ - reason: "Use `Date.toUTCString` instead.", - migrate: Date.toUTCString(), -}) -external toGMTString: t => string = "toGMTString" - -/** -Returns a simplified version of the ISO 8601 format for the date. See -[`Date.toISOString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) -on MDN. - -## Examples - -```rescript -Js.Date.toISOString(exampleDate) == "1973-11-29T21:30:54.321Z" -``` -*/ -@deprecated({ - reason: "Use `Date.toISOString` instead.", - migrate: Date.toISOString(), -}) -@send -external toISOString: t => string = "toISOString" - -@deprecated({ - reason: "This method is unsafe. It will be changed to return option in a future release. Please use toJSONUnsafe instead.", - migrate: Date.toJSON(), -}) -@send -external toJSON: t => string = "toJSON" - -/** -Returns a string representation of the given date. See -[`Date.toJSON`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toJSON) -on MDN. -*/ -@deprecated({ - reason: "Use `Date.toJSON` instead.", - migrate: Date.toJSON(), -}) -@send -external toJSONUnsafe: t => string = "toJSON" - -/** -Returns the year, month, and day for the given `Date` in the current locale -format. See -[`Date.toLocaleDateString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString) -on MDN. - -## Examples - -```rescript -Js.Date.toLocaleDateString(exampleDate) == "11/29/1973" // for en_US.utf8 -Js.Date.toLocaleDateString(exampleDate) == "29.11.73" // for de_DE.utf8 -``` -*/ -@deprecated({ - reason: "Use `Date.toLocaleDateString` instead.", - migrate: Date.toLocaleDateString(), -}) -@send -external toLocaleDateString: t => string = "toLocaleDateString" - -/* TODO: has overloads with somewhat poor browser support */ - -/** -Returns the time and date for the given `Date` in the current locale format. -See -[`Date.toLocaleString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString) -on MDN. - -## Examples - -```rescript -Js.Date.toLocaleString(exampleDate) == "11/29/1973, 10:30:54 PM" // for en_US.utf8 -Js.Date.toLocaleString(exampleDate) == "29.11.1973, 22:30:54" // for de_DE.utf8 -``` -*/ -@deprecated({ - reason: "Use `Date.toLocaleString` instead.", - migrate: Date.toLocaleString(), -}) -@send -external toLocaleString: t => string = "toLocaleString" - -/* TODO: has overloads with somewhat poor browser support */ - -/** -Returns the time of day for the given `Date` in the current locale format. See -[`Date.toLocaleTimeString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString) -on MDN. - -## Examples - -```rescript -Js.Date.toLocaleString(exampleDate) == "10:30:54 PM" // for en_US.utf8 -Js.Date.toLocaleString(exampleDate) == "22:30:54" // for de_DE.utf8 -``` -*/ -@deprecated({ - reason: "Use `Date.toLocaleTimeString` instead.", - migrate: Date.toLocaleTimeString(), -}) -@send -external toLocaleTimeString: t => string = "toLocaleTimeString" - -/* TODO: has overloads with somewhat poor browser support */ - -/** -Returns a string representing the date and time of day for the given `Date` in -the current locale and time zone. See -[`Date.toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toString) -on MDN. - -## Examples - -```rescript -Js.Date.toString( - exampleDate, -) == "Thu Nov 29 1973 22:30:54 GMT+0100 (Central European Standard Time)" -``` -*/ -@deprecated({ - reason: "Use `Date.toString` instead.", - migrate: Date.toString(), -}) -@send -external toString: t => string = "toString" - -/** -Returns a string representing the time of day for the given `Date` in the -current locale and time zone. See -[`Date.toTimeString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toTimeString) -on MDN. - -## Examples - -```rescript -Js.Date.toTimeString(exampleDate) == "22:30:54 GMT+0100 (Central European Standard Time)" -``` -*/ -@deprecated({ - reason: "Use `Date.toTimeString` instead.", - migrate: Date.toTimeString(), -}) -@send -external toTimeString: t => string = "toTimeString" - -/** -Returns a string representing the date and time of day for the given `Date` in -the current locale and UTC (GMT time zone). See -[`Date.toUTCString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString) -on MDN. - -## Examples - -```rescript -Js.Date.toUTCString(exampleDate) == "Thu, 29 Nov 1973 21:30:54 GMT" -``` -*/ -@deprecated({ - reason: "Use `Date.toUTCString` instead.", - migrate: Date.toUTCString(), -}) -@send -external toUTCString: t => string = "toUTCString" diff --git a/packages/@rescript/runtime/Js_dict.res b/packages/@rescript/runtime/Js_dict.res deleted file mode 100644 index 267d09222d8..00000000000 --- a/packages/@rescript/runtime/Js_dict.res +++ /dev/null @@ -1,106 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** Provides a simple key-value dictionary abstraction over native JavaScript objects */ - -/** The dict type */ -type t<'a> = dict<'a> - -/** The key type, an alias of string */ -type key = string - -/** - `unsafeGet dict key` returns the value associated with `key` in `dict` - - This function will return an invalid value (`undefined`) if `key` does not exist in `dict`. It - will not throw an error. -*/ -@get_index -external unsafeGet: (t<'a>, key) => 'a = "" -let \".!()" = unsafeGet - -/** `get dict key` returns the value associated with `key` in `dict` */ -let get = (type u, dict: t, k: key): option => - if %raw(`k in dict`) { - Some(\".!()"(dict, k)) - } else { - None - } - -/** `set dict key value` sets the value of `key` in `dict` to `value` */ -@set_index -external set: (t<'a>, key, 'a) => unit = "" - -/** `keys dict` returns an array of all the keys in `dict` */ -@val -external keys: t<'a> => array = "Object.keys" - -/** `empty ()` creates an empty dictionary */ -@obj -external empty: unit => t<'a> = "" - -let unsafeDeleteKey: (t, string) => unit = %raw(` function (dict,key){ - delete dict[key]; - } - `) - -@new external unsafeCreate: int => array<'a> = "Array" -/* external entries : 'a t -> (key * 'a) array = "Object.entries" [@@val] (* ES2017 *) */ -let entries = dict => { - let keys = keys(dict) - let l = Js_array2.length(keys) - let values = unsafeCreate(l) - for i in 0 to l - 1 { - let key = Js_array2.unsafe_get(keys, i) - Js_array2.unsafe_set(values, i, (key, \".!()"(dict, key))) - } - values -} - -/* external values : 'a t -> 'a array = "Object.values" [@@val] (* ES2017 *) */ -let values = dict => { - let keys = keys(dict) - let l = Js_array2.length(keys) - let values = unsafeCreate(l) - for i in 0 to l - 1 { - Js_array2.unsafe_set(values, i, \".!()"(dict, Js_array2.unsafe_get(keys, i))) - } - values -} - -let fromList = entries => { - let dict = empty() - let rec loop = x => - switch x { - | list{} => dict - | list{(key, value), ...rest} => - set(dict, key, value) - loop(rest) - } - - loop(entries) -} - -let fromArray = entries => { - let dict = empty() - let l = Js_array2.length(entries) - for i in 0 to l - 1 { - let (key, value) = Js_array2.unsafe_get(entries, i) - set(dict, key, value) - } - dict -} - -let map = (f, source) => { - let target = empty() - let keys = keys(source) - let l = Js_array2.length(keys) - for i in 0 to l - 1 { - let key = Js_array2.unsafe_get(keys, i) - set(target, key, f(unsafeGet(source, key))) - } - target -} diff --git a/packages/@rescript/runtime/Js_dict.resi b/packages/@rescript/runtime/Js_dict.resi deleted file mode 100644 index 9a1e17293f4..00000000000 --- a/packages/@rescript/runtime/Js_dict.resi +++ /dev/null @@ -1,206 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** -Provide utilities for JS dictionary object. - -**Note:** This module's examples will assume this predeclared dictionary: - -## Examples - -```rescript -let ages = Js.Dict.fromList(list{("Maria", 30), ("Vinh", 22), ("Fred", 49)}) -``` -*/ - -/* -Dictionary type (ie an '{ }' JS object). However it is restricted to hold a -single type; therefore values must have the same type. This Dictionary type is -mostly used with the Js_json.t type. -*/ -@deprecated({ - reason: "Use `dict` directly instead.", - migrate: %replace.type(: dict), -}) -type t<'a> = dict<'a> - -/** - The type for dictionary keys. This means that dictionaries *must* use `string`s as their keys. -*/ -@deprecated({ - reason: "Use `string` directly instead.", - migrate: %replace.type(: string), -}) -type key = string - -/** -`Js.Dict.get(key)` returns `None` if the key is not found in the dictionary, -`Some(value)` otherwise. - -## Examples - -```rescript -Js.Dict.get(ages, "Vinh") == Some(22) -Js.Dict.get(ages, "Paul") == None -``` -*/ -@deprecated({ - reason: "Use `Dict.get` instead.", - migrate: Dict.get(), -}) -let get: (t<'a>, key) => option<'a> - -/** -`Js.Dict.unsafeGet(key)` returns the value if the key exists, otherwise an `undefined` value is returned. Use this only when you are sure the key exists (i.e. when having used the `keys()` function to check that the key is valid). - -## Examples - -```rescript -Js.Dict.unsafeGet(ages, "Fred") == 49 -Js.Dict.unsafeGet(ages, "Paul") // returns undefined -``` -*/ -@deprecated({ - reason: "Use `Dict.getUnsafe` instead.", - migrate: Dict.getUnsafe(), -}) -@get_index -external unsafeGet: (t<'a>, key) => 'a = "" - -/** -`Js.Dict.set(dict, key, value)` sets the key/value in the dictionary `dict`. If -the key does not exist, and entry will be created for it. - -*This function modifies the original dictionary.* - -## Examples - -```rescript -Js.Dict.set(ages, "Maria", 31) -Js.log(ages == Js.Dict.fromList(list{("Maria", 31), ("Vinh", 22), ("Fred", 49)})) - -Js.Dict.set(ages, "David", 66) -Js.log(ages == Js.Dict.fromList(list{("Maria", 31), ("Vinh", 22), ("Fred", 49), ("David", 66)})) -``` -*/ -@deprecated({ - reason: "Use `Dict.set` instead.", - migrate: Dict.set(), -}) -@set_index -external set: (t<'a>, key, 'a) => unit = "" - -/** -Returns all the keys in the dictionary `dict`. - -## Examples - -```rescript -Js.Dict.keys(ages) == ["Maria", "Vinh", "Fred"] -``` -*/ -@deprecated({ - reason: "Use `Dict.keysToArray` instead.", - migrate: Dict.keysToArray(), -}) -@val -external keys: t<'a> => array = "Object.keys" - -/** Returns an empty dictionary. */ -@deprecated({ - reason: "Use `Dict.make` instead.", - migrate: Dict.make(), -}) -@obj -external empty: unit => t<'a> = "" - -/** Experimental internal function */ -@deprecated({ - reason: "Use `Dict.delete` instead.", - migrate: Dict.delete(), -}) -let unsafeDeleteKey: (t, string) => unit - -/** -Returns an array of key/value pairs in the given dictionary (ES2017). - -## Examples - -```rescript -Js.Dict.entries(ages) == [("Maria", 30), ("Vinh", 22), ("Fred", 49)] -``` -*/ -@deprecated({ - reason: "Use `Dict.toArray` instead.", - migrate: Dict.toArray(), -}) -let entries: t<'a> => array<(key, 'a)> - -/** -Returns the values in the given dictionary (ES2017). - -## Examples - -```rescript -Js.Dict.values(ages) == [30, 22, 49] -``` -*/ -@deprecated({ - reason: "Use `Dict.valuesToArray` instead.", - migrate: Dict.valuesToArray(), -}) -let values: t<'a> => array<'a> - -/** -Creates a new dictionary containing each (key, value) pair in its list -argument. - -## Examples - -```rescript -let capitals = Js.Dict.fromList(list{("Japan", "Tokyo"), ("France", "Paris"), ("Egypt", "Cairo")}) -``` -*/ -@deprecated("Use `Dict.fromArray(List.toArray(...))` instead.") -let fromList: list<(key, 'a)> => t<'a> - -/** -Creates a new dictionary containing each (key, value) pair in its array -argument. - -## Examples - -```rescript -let capitals2 = Js.Dict.fromArray([("Germany", "Berlin"), ("Burkina Faso", "Ouagadougou")]) -``` -*/ -@deprecated({ - reason: "Use `Dict.fromArray` instead.", - migrate: Dict.fromArray(), -}) -let fromArray: array<(key, 'a)> => t<'a> - -/** -`map(f, dict)` maps `dict` to a new dictionary with the same keys, using the -function `f` to map each value. - -## Examples - -```rescript -let prices = Js.Dict.fromList(list{("pen", 1.00), ("book", 5.00), ("stapler", 7.00)}) - -let discount = price => price *. 0.90 -let salePrices = Js.Dict.map(discount, prices) - -salePrices == Js.Dict.fromList(list{("pen", 0.90), ("book", 4.50), ("stapler", 6.30)}) -``` -*/ -@deprecated({ - reason: "Use `Dict.mapValues` instead.", - migrate: Dict.mapValues(%insert.unlabelledArgument(1), %insert.unlabelledArgument(0)), - migrateInPipeChain: Dict.mapValues(), -}) -let map: ('a => 'b, t<'a>) => t<'b> diff --git a/packages/@rescript/runtime/Js_extern.res b/packages/@rescript/runtime/Js_extern.res deleted file mode 100644 index baced59fa3d..00000000000 --- a/packages/@rescript/runtime/Js_extern.res +++ /dev/null @@ -1,23 +0,0 @@ -@deprecated({ - reason: "Use `Nullable.isNullable` instead.", - migrate: Nullable.isNullable(), -}) -external testAny: 'a => bool = "%is_nullable" - -@deprecated({ - reason: "Use `Nullable.null` instead.", - migrate: Nullable.null, -}) -external null: Primitive_js_extern.null<'a> = "%null" - -@deprecated({ - reason: "Use `Nullable.undefined` instead.", - migrate: Nullable.undefined, -}) -external undefined: Primitive_js_extern.null<'a> = "%undefined" - -@deprecated({ - reason: "Use `Type.typeof` instead.", - migrate: Type.typeof(), -}) -external typeof: 'a => string = "%typeof" diff --git a/packages/@rescript/runtime/Js_file.res b/packages/@rescript/runtime/Js_file.res deleted file mode 100644 index 9836effb014..00000000000 --- a/packages/@rescript/runtime/Js_file.res +++ /dev/null @@ -1,3 +0,0 @@ -/*** JavaScript File API */ - -type t diff --git a/packages/@rescript/runtime/Js_float.res b/packages/@rescript/runtime/Js_float.res deleted file mode 100644 index 68ace29372f..00000000000 --- a/packages/@rescript/runtime/Js_float.res +++ /dev/null @@ -1,304 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** -Provide utilities for JS float. -*/ - -/** -The special value "Not a Number". See [`NaN`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN) on MDN. -*/ -@deprecated({ - reason: "Use `Float.Constants.nan` instead.", - migrate: Float.Constants.nan, -}) -@val -external _NaN: float = "NaN" - -/** -Tests if the given value is `_NaN` - -Note that both `_NaN = _NaN` and `_NaN == _NaN` will return `false`. `isNaN` is -therefore necessary to test for `_NaN`. Return `true` if the given value is -`_NaN`, `false` otherwise. See [`isNaN`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN) on MDN. -*/ -@deprecated({ - reason: "Use `Float.isNaN` instead.", - migrate: Float.isNaN(), -}) -@val -@scope("Number") -external isNaN: float => bool = "isNaN" - -/** -Tests if the given value is finite. Return `true` if the given value is a finite -number, `false` otherwise. See [`isFinite`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite) on MDN. - -## Examples - -```rescript -/* returns [false] */ -Js.Float.isFinite(infinity) - -/* returns [false] */ -Js.Float.isFinite(neg_infinity) - -/* returns [false] */ -Js.Float.isFinite(Js.Float._NaN) - -/* returns [true] */ -Js.Float.isFinite(1234.) -``` -*/ -@deprecated({ - reason: "Use `Float.isFinite` instead.", - migrate: Float.isFinite(), -}) -@val -@scope("Number") -external isFinite: float => bool = "isFinite" - -/** -Formats a `float` using exponential (scientific) notation. Return a -`string` representing the given value in exponential notation. Throw -RangeError if digits is not in the range \[0, 20\] (inclusive). See [`toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential) on MDN. - -## Examples - -```rescript -/* prints "7.71234e+1" */ -Js.Float.toExponential(77.1234)->Js.log - -/* prints "7.7e+1" */ -Js.Float.toExponential(77.)->Js.log -``` -*/ -@deprecated({ - reason: "Use `Float.toExponential` instead.", - migrate: Float.toExponential(), -}) -@send -external toExponential: float => string = "toExponential" - -/** -Formats a `float` using exponential (scientific) notation. `digits` specifies -how many digits should appear after the decimal point. The value must be in -the range \[0, 20\] (inclusive). Return a `string` representing the given value -in exponential notation. The output will be rounded or padded with zeroes if -necessary. Throw RangeError if `digits` is not in the range \[0, 20\] (inclusive). -See [`toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential) on MDN. - -## Examples - -```rescript -/* prints "7.71e+1" */ -Js.Float.toExponentialWithPrecision(77.1234, ~digits=2)->Js.log -``` -*/ -@deprecated({ - reason: "Use `Float.toExponential` instead.", - migrate: Float.toExponential(~digits=%insert.labelledArgument("digits")), -}) -@send -external toExponentialWithPrecision: (float, ~digits: int) => string = "toExponential" - -/** -Formats a `float` using fixed point notation. Return a `string` representing the -given value in fixed-point notation (usually). Throw RangeError if digits is not -in the range \[0, 20\] (inclusive). See [`toFixed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed) on MDN. - -## Examples - -```rescript -/* prints "12346" (note the rounding) */ -Js.Float.toFixed(12345.6789)->Js.log - -/* print "1.2e+21" */ -Js.Float.toFixed(1.2e21)->Js.log -``` -*/ -@deprecated({ - reason: "Use `Float.toFixed` instead.", - migrate: Float.toFixed(), -}) -@send -external toFixed: float => string = "toFixed" - -/** -Formats a `float` using fixed point notation. `digits` specifies how many digits -should appear after the decimal point. The value must be in the range \[0, 20\] -(inclusive). Defaults to `0`. Return a `string` representing the given value in -fixed-point notation (usually). See [`toFixed`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toFixed) on MDN. - -The output will be rounded or padded with zeroes if necessary. - -Throw RangeError if digits is not in the range \[0, 20\] (inclusive) - -## Examples - -```rescript -/* prints "12345.7" (note the rounding) */ -Js.Float.toFixedWithPrecision(12345.6789, ~digits=1)->Js.log - -/* prints "0.00" (note the added zeroes) */ -Js.Float.toFixedWithPrecision(0., ~digits=2)->Js.log -``` -*/ -@deprecated({ - reason: "Use `Float.toFixed` instead.", - migrate: Float.toFixed(~digits=%insert.labelledArgument("digits")), -}) -@send -external toFixedWithPrecision: (float, ~digits: int) => string = "toFixed" - -/** -Formats a `float` using some fairly arbitrary rules. Return a `string` -representing the given value in fixed-point (usually). `toPrecision` differs -from `Js.Float.toFixed` in that the former will format the number with full -precision, while the latter will not output any digits after the decimal point. -See [`toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN. - -Throw RangeError if digits is not in the range accepted by this function (what do you mean "vague"?) - -## Examples - -```rescript -/* prints "12345.6789" */ -Js.Float.toPrecision(12345.6789)->Js.log - -/* print "1.2e+21" */ -Js.Float.toPrecision(1.2e21)->Js.log -``` -*/ -@deprecated({ - reason: "Use `Float.toPrecision` instead.", - migrate: Float.toPrecision(), -}) -@send -external toPrecision: float => string = "toPrecision" - -/* equivalent to `toString` I think */ - -/** -Formats a `float` using some fairly arbitrary rules. `digits` specifies how many -digits should appear in total. The value must between 0 and some arbitrary number -that's hopefully at least larger than 20 (for Node it's 21. Why? Who knows). -See [`toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN. - -Return a `string` representing the given value in fixed-point or scientific -notation. The output will be rounded or padded with zeroes if necessary. - -`toPrecisionWithPrecision` differs from `toFixedWithPrecision` in that the former -will count all digits against the precision, while the latter will count only -the digits after the decimal point. `toPrecisionWithPrecision` will also use -scientific notation if the specified precision is less than the number for digits -before the decimal point. - -Throw RangeError if digits is not in the range accepted by this function (what do you mean "vague"?) - -## Examples - -```rescript -/* prints "1e+4" */ -Js.Float.toPrecisionWithPrecision(12345.6789, ~digits=1)->Js.log - -/* prints "0.0" */ -Js.Float.toPrecisionWithPrecision(0., ~digits=2)->Js.log -``` -*/ -@deprecated({ - reason: "Use `Float.toPrecision` instead.", - migrate: Float.toPrecision(~digits=%insert.labelledArgument("digits")), -}) -@send -external toPrecisionWithPrecision: (float, ~digits: int) => string = "toPrecision" - -/** -Formats a `float` as a string. Return a `string` representing the given value in -fixed-point (usually). See [`toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString) on MDN. - -## Examples - -```rescript -/* prints "12345.6789" */ -Js.Float.toString(12345.6789)->Js.log -``` -*/ -@deprecated({ - reason: "Use `Float.toString` instead.", - migrate: Float.toString(), -}) -@send -external toString: float => string = "toString" - -/** -Formats a `float` as a string. `radix` specifies the radix base to use for the -formatted number. The value must be in the range \[2, 36\] (inclusive). Return a -`string` representing the given value in fixed-point (usually). See [`toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString) on MDN. - -Throw RangeError if radix is not in the range \[2, 36\] (inclusive) - -## Examples - -```rescript -/* prints "110" */ -Js.Float.toStringWithRadix(6., ~radix=2)->Js.log - -/* prints "11.001000111101011100001010001111010111000010100011111" */ -Js.Float.toStringWithRadix(3.14, ~radix=2)->Js.log - -/* prints "deadbeef" */ -Js.Float.toStringWithRadix(3735928559., ~radix=16)->Js.log - -/* prints "3f.gez4w97ry0a18ymf6qadcxr" */ -Js.Float.toStringWithRadix(123.456, ~radix=36)->Js.log -``` -*/ -@deprecated({ - reason: "Use `Float.toString` instead.", - migrate: Float.toString(~radix=%insert.labelledArgument("radix")), -}) -@send -external toStringWithRadix: (float, ~radix: int) => string = "toString" - -/** -Parses the given `string` into a `float` using JavaScript semantics. Return the -number as a `float` if successfully parsed, `_NaN` otherwise. - -## Examples - -```rescript -/* returns 123 */ -Js.Float.fromString("123") - -/* returns 12.3 */ -Js.Float.fromString("12.3") - -/* returns 0 */ -Js.Float.fromString("") - -/* returns 17 */ -Js.Float.fromString("0x11") - -/* returns 3 */ -Js.Float.fromString("0b11") - -/* returns 9 */ -Js.Float.fromString("0o11") - -/* returns [_NaN] */ -Js.Float.fromString("hello") - -/* returns [_NaN] */ -Js.Float.fromString("100a") -``` -*/ -@deprecated({ - reason: "Use `Float.parseFloat` instead.", - migrate: Float.parseFloat(), -}) -@val -external fromString: string => float = "Number" diff --git a/packages/@rescript/runtime/Js_global.res b/packages/@rescript/runtime/Js_global.res deleted file mode 100644 index e28b8041198..00000000000 --- a/packages/@rescript/runtime/Js_global.res +++ /dev/null @@ -1,226 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** -Contains functions available in the global scope (`window` in a browser context) -*/ - -/** Identify an interval started by `Js.Global.setInterval`. */ -@deprecated({ - reason: "Use `intervalId` directly instead.", - migrate: %replace.type(: intervalId), -}) -type intervalId = Stdlib_Global.intervalId - -/** Identify timeout started by `Js.Global.setTimeout`. */ -@deprecated({ - reason: "Use `timeoutId` directly instead.", - migrate: %replace.type(: timeoutId), -}) -type timeoutId = Stdlib_Global.timeoutId - -/** -Clear an interval started by `Js.Global.setInterval` - -## Examples - -```rescript -/* API for a somewhat aggressive snoozing alarm clock */ - -let punchSleepyGuy = () => Js.log("Punch") - -let interval = ref(Js.Nullable.null) - -let remind = () => { - Js.log("Wake Up!") - punchSleepyGuy() -} - -let snooze = mins => interval := Js.Nullable.return(Js.Global.setInterval(remind, mins * 60 * 1000)) - -let cancel = () => - Js.Nullable.iter(interval.contents, intervalId => Js.Global.clearInterval(intervalId)) -``` -*/ -@deprecated({ - reason: "Use `clearInterval` instead.", - migrate: clearInterval(), -}) -@val -external clearInterval: intervalId => unit = "clearInterval" - -/** -Clear a timeout started by `Js.Global.setTimeout`. - -## Examples - -```rescript -/* A simple model of a code monkey's brain */ - -let closeHackerNewsTab = () => Js.log("close") - -let timer = ref(Js.Nullable.null) - -let work = () => closeHackerNewsTab() - -let procrastinate = mins => { - Js.Nullable.iter(timer.contents, timer => Js.Global.clearTimeout(timer)) - timer := Js.Nullable.return(Js.Global.setTimeout(work, mins * 60 * 1000)) -} -``` -*/ -@deprecated({ - reason: "Use `clearTimeout` instead.", - migrate: clearTimeout(), -}) -@val -external clearTimeout: timeoutId => unit = "clearTimeout" - -/** -Repeatedly executes a callback with a specified interval (in milliseconds) -between calls. Returns a `Js.Global.intervalId` that can be passed to -`Js.Global.clearInterval` to cancel the timeout. - -## Examples - -```rescript -/* Will count up and print the count to the console every second */ - -let count = ref(0) - -let tick = () => { - count := count.contents + 1 - Js.log(Belt.Int.toString(count.contents)) -} - -Js.Global.setInterval(tick, 1000) -``` -*/ -@deprecated({ - reason: "Use `setInterval` instead.", - migrate: setInterval(), -}) -@val -external setInterval: (unit => unit, int) => intervalId = "setInterval" - -/** -Repeatedly executes a callback with a specified interval (in milliseconds) -between calls. Returns a `Js.Global.intervalId` that can be passed to -`Js.Global.clearInterval` to cancel the timeout. - -## Examples - -```rescript -/* Will count up and print the count to the console every second */ - -let count = ref(0) - -let tick = () => { - count := count.contents + 1 - Js.log(Belt.Int.toString(count.contents)) -} - -Js.Global.setIntervalFloat(tick, 1000.0) -``` -*/ -@deprecated({ - reason: "Use `setIntervalFloat` instead.", - migrate: setIntervalFloat(), -}) -@val -external setIntervalFloat: (unit => unit, float) => intervalId = "setInterval" - -/** -Execute a callback after a specified delay (in milliseconds). Returns a -`Js.Global.timeoutId` that can be passed to `Js.Global.clearTimeout` to cancel -the timeout. - -## Examples - -```rescript -/* Prints "Timed out!" in the console after one second */ - -let message = "Timed out!" - -Js.Global.setTimeout(() => Js.log(message), 1000) -``` -*/ -@deprecated({ - reason: "Use `setTimeout` instead.", - migrate: setTimeout(), -}) -@val -external setTimeout: (unit => unit, int) => timeoutId = "setTimeout" - -/** -Execute a callback after a specified delay (in milliseconds). Returns a -`Js.Global.timeoutId` that can be passed to `Js.Global.clearTimeout` to cancel -the timeout. - -## Examples - -```rescript -/* Prints "Timed out!" in the console after one second */ - -let message = "Timed out!" - -Js.Global.setTimeoutFloat(() => Js.log(message), 1000.0) -``` -*/ -@deprecated({ - reason: "Use `setTimeoutFloat` instead.", - migrate: setTimeoutFloat(), -}) -@val -external setTimeoutFloat: (unit => unit, float) => timeoutId = "setTimeout" - -/** -URL-encodes a string. - -See [`encodeURI`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI) on MDN. -*/ -@deprecated({ - reason: "Use `encodeURI` instead.", - migrate: encodeURI(), -}) -@val -external encodeURI: string => string = "encodeURI" - -/** -Decodes a URL-enmcoded string produced by `encodeURI` - -See [`decodeURI`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI) on MDN. -*/ -@deprecated({ - reason: "Use `decodeURI` instead.", - migrate: decodeURI(), -}) -@val -external decodeURI: string => string = "decodeURI" - -/** -URL-encodes a string, including characters with special meaning in a URI. - -See [`encodeURIComponent`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) on MDN. -*/ -@deprecated({ - reason: "Use `encodeURIComponent` instead.", - migrate: encodeURIComponent(), -}) -@val -external encodeURIComponent: string => string = "encodeURIComponent" - -/** -Decodes a URL-enmcoded string produced by `encodeURIComponent` - -See [`decodeURIComponent`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent) on MDN. -*/ -@deprecated({ - reason: "Use `decodeURIComponent` instead.", - migrate: decodeURIComponent(), -}) -@val -external decodeURIComponent: string => string = "decodeURIComponent" diff --git a/packages/@rescript/runtime/Js_int.res b/packages/@rescript/runtime/Js_int.res deleted file mode 100644 index a27ad6c9353..00000000000 --- a/packages/@rescript/runtime/Js_int.res +++ /dev/null @@ -1,185 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** -Provide utilities for handling `int`. -*/ - -/* -If we use number, we need coerce to int32 by adding `|0`, -otherwise `+0` can be wrong. -Most JS API is float oriented, it may overflow int32 or -comes with `NAN` -*/ - -/* + conversion */ - -/** -Formats an `int` using exponential (scientific) notation. -Returns a `string` representing the given value in exponential notation. -Throws `RangeError` if digits is not in the range \[0, 20\] (inclusive). - -See [`toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential) on MDN. - -## Examples - -```rescript -/* prints "7.7e+1" */ -Js.log(Js.Int.toExponential(77)) -``` -*/ -@deprecated({ - reason: "Use `Int.toExponential` instead.", - migrate: Int.toExponential(), -}) -@send -external toExponential: int => string = "toExponential" - -/** -Formats an `int` using exponential (scientific) notation. -`digits` specifies how many digits should appear after the decimal point. The value must be in the range \[0, 20\] (inclusive). - -Returns a `string` representing the given value in exponential notation. - -The output will be rounded or padded with zeroes if necessary. -Throws `RangeError` if `digits` is not in the range \[0, 20\] (inclusive). - -See [`toExponential`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toExponential) on MDN. - -## Examples - -```rescript -/* prints "7.70e+1" */ -Js.log(Js.Int.toExponentialWithPrecision(77, ~digits=2)) - -/* prints "5.68e+3" */ -Js.log(Js.Int.toExponentialWithPrecision(5678, ~digits=2)) -``` -*/ -@deprecated({ - reason: "Use `Int.toExponential` instead.", - migrate: Int.toExponential(~digits=%insert.labelledArgument("digits")), -}) -@send -external toExponentialWithPrecision: (int, ~digits: int) => string = "toExponential" - -/** -Formats an `int` using some fairly arbitrary rules. -Returns a `string` representing the given value in fixed-point (usually). - -`toPrecision` differs from `toFixed` in that the former will format the number with full precision, while the latter will not output any digits after the decimal point. -Throws `RangeError` if `digits` is not in the range accepted by this function. - -See [`toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN. - -## Examples - -```rescript -/* prints "123456789" */ -Js.log(Js.Int.toPrecision(123456789)) -``` -*/ -@deprecated({ - reason: "Use `Int.toPrecision` instead.", - migrate: Int.toPrecision(), -}) -@send -external toPrecision: int => string = "toPrecision" - -/** -Formats an `int` using some fairly arbitrary rules. -`digits` specifies how many digits should appear in total. The value must between 0 and some arbitrary number that's hopefully at least larger than 20 (for Node it's 21. Why? Who knows). - -Returns a `string` representing the given value in fixed-point or scientific notation. - -The output will be rounded or padded with zeroes if necessary. - -`toPrecisionWithPrecision` differs from `toFixedWithPrecision` in that the former will count all digits against the precision, while the latter will count only the digits after the decimal point. -`toPrecisionWithPrecision` will also use scientific notation if the specified precision is less than the number of digits before the decimal point. -Throws `RangeError` if `digits` is not in the range accepted by this function. - - -See [`toPrecision`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toPrecision) on MDN. - -## Examples - -```rescript -/* prints "1.2e+8" */ -Js.log(Js.Int.toPrecisionWithPrecision(123456789, ~digits=2)) - -/* prints "0.0" */ -Js.log(Js.Int.toPrecisionWithPrecision(0, ~digits=2)) -``` -*/ -@deprecated({ - reason: "Use `Int.toPrecision` instead.", - migrate: Int.toPrecision(~digits=%insert.labelledArgument("digits")), -}) -@send -external toPrecisionWithPrecision: (int, ~digits: int) => string = "toPrecision" - -/** -Formats an `int` as a `string`. Returns a `string` representing the given value -in fixed-point (usually). - -See [`toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString) on MDN. - -## Examples - -```rescript -/* prints "123456789" */ -Js.log(Js.Int.toString(123456789)) -``` -*/ -@deprecated({ - reason: "Use `Int.toString` instead.", - migrate: Int.toString(), -}) -@send -external toString: int => string = "toString" - -/** -Formats an `int` as a `string`. `radix` specifies the radix base to use for the -formatted number. The value must be in the range \[2, 36\] (inclusive). Returns -a `string` representing the given value in fixed-point (usually). Throws -`RangeError` if `radix` is not in the range \[2, 36\] (inclusive). - - -See [`toString`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString) on MDN. - -## Examples - -```rescript -/* prints "110" */ -Js.log(Js.Int.toStringWithRadix(6, ~radix=2)) - -/* prints "deadbeef" */ -Js.log(Js.Int.toStringWithRadix(3735928559, ~radix=16)) - -/* prints "2n9c" */ -Js.log(Js.Int.toStringWithRadix(123456, ~radix=36)) -``` -*/ -@deprecated({ - reason: "Use `Int.toString` instead.", - migrate: Int.toString(~radix=%insert.labelledArgument("radix")), -}) -@send -external toStringWithRadix: (int, ~radix: int) => string = "toString" - -@deprecated({ - reason: "Use `Int.toFloat` instead.", - migrate: Int.toFloat(), -}) -external toFloat: int => float = "%floatofint" - -@deprecated({ - reason: "Use `Int.equal` instead.", - migrate: Int.equal(), -}) -let equal = (x: int, y) => x == y -let max: int = 2147483647 -let min: int = -2147483648 diff --git a/packages/@rescript/runtime/Js_json.res b/packages/@rescript/runtime/Js_json.res deleted file mode 100644 index 7a000e18653..00000000000 --- a/packages/@rescript/runtime/Js_json.res +++ /dev/null @@ -1,199 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** Efficient JSON encoding using JavaScript API */ - -@unboxed -type rec t = Stdlib_JSON.t = - | Boolean(bool) - | @as(null) Null - | String(string) - | Number(float) - | Object(dict) - | Array(array) - -module Kind = { - type json = t - type rec t<_> = - | String: t - | Number: t - | Object: t> - | Array: t> - | Boolean: t - | Null: t -} - -type tagged_t = - | JSONFalse - | JSONTrue - | JSONNull - | JSONString(string) - | JSONNumber(float) - | JSONObject(dict) - | JSONArray(array) - -let classify = (x: t): tagged_t => { - let ty = Js_extern.typeof(x) - if ty == "string" { - JSONString(Obj.magic(x)) - } else if ty == "number" { - JSONNumber(Obj.magic(x)) - } else if ty == "boolean" { - if Obj.magic(x) == true { - JSONTrue - } else { - JSONFalse - } - } else if Obj.magic(x) === Js_extern.null { - JSONNull - } else if Js_array2.isArray(x) { - JSONArray(Obj.magic(x)) - } else { - JSONObject(Obj.magic(x)) - } -} - -let test = (type a, x: 'a, v: Kind.t): bool => - switch v { - | Kind.Number => Js_extern.typeof(x) == "number" - | Kind.Boolean => Js_extern.typeof(x) == "boolean" - | Kind.String => Js_extern.typeof(x) == "string" - | Kind.Null => Obj.magic(x) === Js_extern.null - | Kind.Array => Js_array2.isArray(x) - | Kind.Object => - Obj.magic(x) !== Js_extern.null && (Js_extern.typeof(x) == "object" && !Js_array2.isArray(x)) - } - -let decodeString = json => - if Js_extern.typeof(json) == "string" { - Some((Obj.magic((json: t)): string)) - } else { - None - } - -let decodeNumber = json => - if Js_extern.typeof(json) == "number" { - Some((Obj.magic((json: t)): float)) - } else { - None - } - -let decodeObject = json => - if ( - Js_extern.typeof(json) == "object" && - (!Js_array2.isArray(json) && - !((Obj.magic(json): Js_null.t<'a>) === Js_extern.null)) - ) { - Some((Obj.magic((json: t)): dict)) - } else { - None - } - -let decodeArray = json => - if Js_array2.isArray(json) { - Some((Obj.magic((json: t)): array)) - } else { - None - } - -let decodeBoolean = (json: t) => - if Js_extern.typeof(json) == "boolean" { - Some((Obj.magic((json: t)): bool)) - } else { - None - } - -let decodeNull = (json): option> => - if (Obj.magic(json): Js_null.t<'a>) === Js_extern.null { - Some(Js_extern.null) - } else { - None - } - -/* external parse : string -> t = "parse" - [@@val][@@scope "JSON"] */ - -@val @scope("JSON") external parseExn: string => t = "parse" - -@val @scope("JSON") external stringifyAny: 'a => option = "stringify" -/* TODO: more docs when parse error happens or stringify non-stringfy value */ - -@val external null: t = "null" -external string: string => t = "%identity" -external number: float => t = "%identity" -external boolean: bool => t = "%identity" -external object_: dict => t = "%identity" - -/* external array_ : t array -> t = "%identity" */ - -external array: array => t = "%identity" -external stringArray: array => t = "%identity" -external numberArray: array => t = "%identity" -external booleanArray: array => t = "%identity" -external objectArray: array> => t = "%identity" -@val @scope("JSON") external stringify: t => string = "stringify" -@val @scope("JSON") external stringifyWithSpace: (t, @as(json`null`) _, int) => string = "stringify" - -/* in memory modification does not work until your root is - actually None, so we need wrap it as ``v`` and - return the first element instead */ - -let patch: _ => _ = %raw(`function (json) { - var x = [json]; - var q = [{ kind: 0, i: 0, parent: x }]; - while (q.length !== 0) { - // begin pop the stack - var cur = q[q.length - 1]; - if (cur.kind === 0) { - cur.val = cur.parent[cur.i]; // patch the undefined value for array - if (++cur.i === cur.parent.length) { - q.pop(); - } - } else { - q.pop(); - } - // finish - var task = cur.val; - if (typeof task === "object") { - if (Array.isArray(task) && task.length !== 0) { - q.push({ kind: 0, i: 0, parent: task, val: undefined }); - } else { - for (var k in task) { - if (k === "RE_PRIVATE_NONE") { - if (cur.kind === 0) { - cur.parent[cur.i - 1] = undefined; - } else { - cur.parent[cur.i] = undefined; - } - continue; - } - q.push({ kind: 1, i: k, parent: task, val: task[k] }); - } - } - } - } - return x[0]; -} -`) - -let serializeExn = (type t, x: t): string => - %raw(` function(obj){ - var output= JSON.stringify(obj,function(_,value){ - if(value===undefined){ - return {RE_PRIVATE_NONE : true} - } - return value - }); - - if(output === undefined){ - // JSON.stringify will throw TypeError when it detects cylic objects - throw new TypeError("output is undefined") - } - return output - } -`)(x) - -let deserializeUnsafe = (s: string): 'a => patch(parseExn(s)) diff --git a/packages/@rescript/runtime/Js_json.resi b/packages/@rescript/runtime/Js_json.resi deleted file mode 100644 index bcd55d913e3..00000000000 --- a/packages/@rescript/runtime/Js_json.resi +++ /dev/null @@ -1,351 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** -Efficient JSON encoding using JavaScript API - -**see** [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON) -*/ - -/* ## Types */ - -/** The JSON data structure */ -@deprecated({ - reason: "Use `JSON.t` instead.", - migrate: %replace.type(: JSON.t), -}) -@unboxed -type rec t = Stdlib_JSON.t = - | Boolean(bool) - | @as(null) Null - | String(string) - | Number(float) - | Object(dict) - | Array(array) - -@deprecated("This functionality has been deprecated and will be removed in v13.") -module Kind: { - type json = t - /** Underlying type of a JSON value */ - type rec t<_> = - | String: t - | Number: t - | Object: t> - | Array: t> - | Boolean: t - | Null: t -} - -@deprecated("This functionality has been deprecated and will be removed in v13.") -type tagged_t = - | JSONFalse - | JSONTrue - | JSONNull - | JSONString(string) - | JSONNumber(float) - | JSONObject(dict) - | JSONArray(array) - -/* ## Accessors */ - -@deprecated("This functionality has been deprecated and will be removed in v13.") -let classify: t => tagged_t - -/** -`test(v, kind)` returns `true` if `v` is of `kind`. -*/ -@deprecated("This functionality has been deprecated and will be removed in v13.") -let test: ('a, Kind.t<'b>) => bool - -/** -`decodeString(json)` returns `Some(s)` if `json` is a `string`, `None` otherwise. -*/ -@deprecated({ - reason: "Use `JSON.Decode.string` instead.", - migrate: JSON.Decode.string(), -}) -let decodeString: t => option - -/** -`decodeNumber(json)` returns `Some(n)` if `json` is a `number`, `None` otherwise. -*/ -@deprecated({ - reason: "Use `JSON.Decode.float` instead.", - migrate: JSON.Decode.float(), -}) -let decodeNumber: t => option - -/** -`decodeObject(json)` returns `Some(o)` if `json` is an `object`, `None` otherwise. -*/ -@deprecated({ - reason: "Use `JSON.Decode.object` instead.", - migrate: JSON.Decode.object(), -}) -let decodeObject: t => option> - -/** -`decodeArray(json)` returns `Some(a)` if `json` is an `array`, `None` otherwise. -*/ -@deprecated({ - reason: "Use `JSON.Decode.array` instead.", - migrate: JSON.Decode.array(), -}) -let decodeArray: t => option> - -/** -`decodeBoolean(json)` returns `Some(b)` if `json` is a `boolean`, `None` otherwise. -*/ -@deprecated({ - reason: "Use `JSON.Decode.bool` instead.", - migrate: JSON.Decode.bool(), -}) -let decodeBoolean: t => option - -/** -`decodeNull(json)` returns `Some(null)` if `json` is a `null`, `None` otherwise. -*/ -@deprecated({ - reason: "Use JSON.Decode.null instead.", - migrate: JSON.Decode.null(), -}) -let decodeNull: t => option> - -/* ## Constructors */ - -/* - Those functions allows the construction of an arbitrary complex - JSON values. -*/ - -/** `null` is the singleton null JSON value. */ -@deprecated({ - reason: "Use `JSON.Encode.null` instead.", - migrate: JSON.Encode.null, -}) -@val -external null: t = "null" - -/** `string(s)` makes a JSON string of the `string` `s`. */ -@deprecated({ - reason: "Use `JSON.Encode.string` instead.", - migrate: JSON.Encode.string(), -}) -external string: string => t = "%identity" - -/** `number(n)` makes a JSON number of the `float` `n`. */ -@deprecated({ - reason: "Use `JSON.Encode.float` instead.", - migrate: JSON.Encode.float(), -}) -external number: float => t = "%identity" - -/** `boolean(b)` makes a JSON boolean of the `bool` `b`. */ -@deprecated({ - reason: "Use `JSON.Encode.bool` instead.", - migrate: JSON.Encode.bool(), -}) -external boolean: bool => t = "%identity" - -/** `object_(dict)` makes a JSON object of the `dict`. */ -@deprecated({ - reason: "Use `JSON.Encode.object` instead.", - migrate: JSON.Encode.object(), -}) -external object_: dict => t = "%identity" - -/** `array_(a)` makes a JSON array of the `Js.Json.t` array `a`. */ -@deprecated({ - reason: "Use `JSON.Encode.array` instead.", - migrate: JSON.Encode.array(), -}) -external array: array => t = "%identity" - -/* - The functions below are specialized for specific array type which - happened to be already JSON object in the ReScript runtime. Therefore - they are more efficient (constant time rather than linear conversion). -*/ - -/** `stringArray(a)` makes a JSON array of the `string` array `a`. */ -@deprecated({ - reason: "Use `JSON.Encode.stringArray` instead.", - migrate: JSON.Encode.stringArray(), -}) -external stringArray: array => t = "%identity" - -/** `numberArray(a)` makes a JSON array of the `float` array `a`. */ -@deprecated({ - reason: "Use `JSON.Encode.floatArray` instead.", - migrate: JSON.Encode.floatArray(), -}) -external numberArray: array => t = "%identity" - -/** `booleanArray(a)` makes a JSON array of the `bool` array `a`. */ -@deprecated({ - reason: "Use `JSON.Encode.boolArray` instead.", - migrate: JSON.Encode.boolArray(), -}) -external booleanArray: array => t = "%identity" - -/** `objectArray(a) makes a JSON array of the `JsDict.t` array `a`. */ -@deprecated({ - reason: "Use `JSON.Encode.objectArray` instead.", - migrate: JSON.Encode.objectArray(), -}) -external objectArray: array> => t = "%identity" - -/* ## String conversion */ - -/** -`parseExn(s)` parses the `string` `s` into a JSON data structure. -Returns a JSON data structure. -Throws `SyntaxError` if the given string is not a valid JSON. Note: `SyntaxError` is a JavaScript exception. - -See [`parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) on MDN. - -## Examples - -```rescript -/* parse a simple JSON string */ - -let json = try Js.Json.parseExn(` "hello" `) catch { -| _ => failwith("Error parsing JSON string") -} - -switch Js.Json.classify(json) { -| Js.Json.JSONString(value) => Js.log(value) -| _ => failwith("Expected a string") -} -``` - -```rescript -/* parse a complex JSON string */ - -let getIds = s => { - let json = try Js.Json.parseExn(s) catch { - | _ => failwith("Error parsing JSON string") - } - - switch Js.Json.classify(json) { - | Js.Json.JSONObject(value) => - /* In this branch, compiler infer value : Js.Json.t dict */ - switch Js.Dict.get(value, "ids") { - | Some(ids) => - switch Js.Json.classify(ids) { - | Js.Json.JSONArray(ids) => /* In this branch compiler infer ids : Js.Json.t array */ - ids - | _ => failwith("Expected an array") - } - | None => failwith("Expected an `ids` property") - } - | _ => failwith("Expected an object") - } -} - -/* prints `1, 2, 3` */ -Js.log(getIds(` { "ids" : [1, 2, 3 ] } `)) -``` -*/ -@deprecated({ - reason: "Use `JSON.parseOrThrow` instead.", - migrate: JSON.parseOrThrow(), -}) -@val -@scope("JSON") -external parseExn: string => t = "parse" - -/** -`stringify(json)` formats the JSON data structure as a `string`. -Returns the string representation of a given JSON data structure. - -See [`stringify`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) on MDN. - -## Examples - -```rescript -/* Creates and stringifies a simple JS object */ - -let dict = Js.Dict.empty() -Js.Dict.set(dict, "name", Js.Json.string("John Doe")) -Js.Dict.set(dict, "age", Js.Json.number(30.0)) -Js.Dict.set(dict, "likes", Js.Json.stringArray(["ReScript", "ocaml", "js"])) - -Js.log(Js.Json.stringify(Js.Json.object_(dict))) -``` -*/ -@deprecated({ - reason: "Use `JSON.stringify` instead.", - migrate: JSON.stringify(), -}) -@val -@scope("JSON") -external stringify: t => string = "stringify" - -/** -`stringifyWithSpace(json)` formats the JSON data structure as a `string`. -Returns the string representation of a given JSON data structure with spacing. - -See [`stringify`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) on MDN. - -## Examples - -```rescript -/* Creates and stringifies a simple JS object with spacing */ - -let dict = Js.Dict.empty() -Js.Dict.set(dict, "name", Js.Json.string("John Doe")) -Js.Dict.set(dict, "age", Js.Json.number(30.0)) -Js.Dict.set(dict, "likes", Js.Json.stringArray(["ReScript", "ocaml", "js"])) - -Js.log(Js.Json.stringifyWithSpace(Js.Json.object_(dict), 2)) -``` -*/ -@deprecated({ - reason: "Use `JSON.stringify` with optional `~space` instead.", - migrate: JSON.stringify(~space=%insert.unlabelledArgument(2)), -}) -@val -@scope("JSON") -external stringifyWithSpace: (t, @as(json`null`) _, int) => string = "stringify" - -/** -`stringifyAny(value)` formats any value into a JSON string. - -## Examples - -```rescript -/* prints `["hello", "world"]` */ -Js.log(Js.Json.stringifyAny(["hello", "world"])) -``` -*/ -@deprecated({ - reason: "Use `JSON.stringifyAny` instead.", - migrate: JSON.stringifyAny(), -}) -@val -@scope("JSON") -external stringifyAny: 'a => option = "stringify" - -/** -Best-effort serialization, it tries to seralize as -many objects as possible and deserialize it back - -It is unsafe in two aspects -- It may throw during parsing -- when you cast it to a specific type, it may have a type mismatch -*/ -@deprecated("This functionality has been deprecated and will be removed in v13.") -let deserializeUnsafe: string => 'a - -/** -It will throw in such situations: -- The object can not be serlialized to a JSON -- There are cycles -- Some JS engines can not stringify deeply nested json objects -*/ -@deprecated("This functionality has been deprecated and will be removed in v13.") -let serializeExn: 'a => string diff --git a/packages/@rescript/runtime/Js_map.res b/packages/@rescript/runtime/Js_map.res deleted file mode 100644 index 827c66b9abb..00000000000 --- a/packages/@rescript/runtime/Js_map.res +++ /dev/null @@ -1,7 +0,0 @@ -/*** ES6 Map API */ - -@deprecated({ - reason: "Use `Map.t` instead.", - migrate: %replace.type(: Map.t), -}) -type t<'k, 'v> = Stdlib_Map.t<'k, 'v> diff --git a/packages/@rescript/runtime/Js_math.res b/packages/@rescript/runtime/Js_math.res deleted file mode 100644 index 2e1bb48ab53..00000000000 --- a/packages/@rescript/runtime/Js_math.res +++ /dev/null @@ -1,1016 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** -Provide utilities for JS Math. Note: The constants `_E`, `_LN10`, `_LN2`, -`_LOG10E`, `_LOG2E`, `_PI`, `_SQRT1_2`, and `_SQRT2` begin with an underscore -because ReScript variable names cannot begin with a capital letter. (Module -names begin with upper case.) -*/ - -/** -Euler's number; ≈ 2.718281828459045. See -[`Math.E`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/E) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.Constants.e` instead.", - migrate: Math.Constants.e, -}) -@val -@scope("Math") -external _E: float = "E" - -/** -Natural logarithm of 2; ≈ 0.6931471805599453. See -[`Math.LN2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LN2) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.Constants.ln2` instead.", - migrate: Math.Constants.ln2, -}) -@val -@scope("Math") -external _LN2: float = "LN2" - -/** -Natural logarithm of 10; ≈ 2.302585092994046. See -[`Math.LN10`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LN10) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.Constants.ln10` instead.", - migrate: Math.Constants.ln10, -}) -@val -@scope("Math") -external _LN10: float = "LN10" - -/** -Base 2 logarithm of E; ≈ 1.4426950408889634. See -[`Math.LOG2E`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG2E) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.Constants.log2e` instead.", - migrate: Math.Constants.log2e, -}) -@val -@scope("Math") -external _LOG2E: float = "LOG2E" - -/** -Base 10 logarithm of E; ≈ 0.4342944819032518. See -[`Math.LOG10E`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG10E) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.Constants.log10e` instead.", - migrate: Math.Constants.log10e, -}) -@val -@scope("Math") -external _LOG10E: float = "LOG10E" - -/** -Pi - ratio of the circumference to the diameter of a circle; ≈ 3.141592653589793. See -[`Math.PI`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/PI) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.Constants.pi` instead.", - migrate: Math.Constants.pi, -}) -@val -@scope("Math") -external _PI: float = "PI" - -/** -Square root of 1/2; ≈ 0.7071067811865476. See -[`Math.SQRT1_2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT1_2) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.Constants.sqrt1_2` instead.", - migrate: Math.Constants.sqrt1_2, -}) -@val -@scope("Math") -external _SQRT1_2: float = "SQRT1_2" - -/** -Square root of 2; ≈ 1.4142135623730951. See -[`Math.SQRT2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT2) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.Constants.sqrt2` instead.", - migrate: Math.Constants.sqrt2, -}) -@val -@scope("Math") -external _SQRT2: float = "SQRT2" - -/** -Absolute value for integer argument. See -[`Math.abs`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.Int.abs` instead.", - migrate: Math.Int.abs(), -}) -@val -@scope("Math") -external abs_int: int => int = "abs" - -/** -Absolute value for float argument. See -[`Math.abs`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.abs` instead.", - migrate: Math.abs(), -}) -@val -@scope("Math") -external abs_float: float => float = "abs" - -/** -Arccosine (in radians) of argument; returns `NaN` if the argument is outside -the range [-1.0, 1.0]. See -[`Math.acos`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acos) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.acos` instead.", - migrate: Math.acos(), -}) -@val -@scope("Math") -external acos: float => float = "acos" - -/** -Hyperbolic arccosine (in radians) of argument; returns `NaN` if the argument -is less than 1.0. See -[`Math.acosh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.acosh` instead.", - migrate: Math.acosh(), -}) -@val -@scope("Math") -external acosh: float => float = "acosh" - -/** -Arcsine (in radians) of argument; returns `NaN` if the argument is outside -the range [-1.0, 1.0]. See -[`Math.asin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asin) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.asin` instead.", - migrate: Math.asin(), -}) -@val -@scope("Math") -external asin: float => float = "asin" - -/** -Hyperbolic arcsine (in radians) of argument. See -[`Math.asinh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asinh) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.asinh` instead.", - migrate: Math.asinh(), -}) -@val -@scope("Math") -external asinh: float => float = "asinh" - -/** -Arctangent (in radians) of argument. See -[`Math.atan`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.atan` instead.", - migrate: Math.atan(), -}) -@val -@scope("Math") -external atan: float => float = "atan" - -/** -Hyperbolic arctangent (in radians) of argument; returns `NaN` if the argument -is is outside the range [-1.0, 1.0]. Returns `-Infinity` and `Infinity` for -arguments -1.0 and 1.0. See -[`Math.atanh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atanh) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.atanh` instead.", - migrate: Math.atanh(), -}) -@val -@scope("Math") -external atanh: float => float = "atanh" - -/** -Returns the angle (in radians) of the quotient `y /. x`. It is also the angle -between the *x*\-axis and point (*x*, *y*). See -[`Math.atan2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2) -on MDN. - -## Examples - -```rescript -Js.Math.atan2(~y=0.0, ~x=10.0, ()) == 0.0 -Js.Math.atan2(~x=5.0, ~y=5.0, ()) == Js.Math._PI /. 4.0 -Js.Math.atan2(~x=-5.0, ~y=5.0, ()) -Js.Math.atan2(~x=-5.0, ~y=5.0, ()) == 3.0 *. Js.Math._PI /. 4.0 -Js.Math.atan2(~x=-0.0, ~y=-5.0, ()) == -.Js.Math._PI /. 2.0 -``` -*/ -@deprecated({ - reason: "Use `Math.atan2` instead.", - migrate: @apply.transforms(["dropUnitArgumentsInApply"]) - Math.atan2(~y=%insert.labelledArgument("y"), ~x=%insert.labelledArgument("x")), -}) -@val -@scope("Math") -external atan2: (~y: float, ~x: float, unit) => float = "atan2" - -/** -Cube root. See -[`Math.cbrt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt) -on MDN -*/ -@deprecated({ - reason: "Use `Math.cbrt` instead.", - migrate: Math.cbrt(), -}) -@val -@scope("Math") -external cbrt: float => float = "cbrt" - -/** -Returns the smallest integer greater than or equal to the argument. This -function may return values not representable by `int`, whose range is -\-2147483648 to 2147483647. This is because, in JavaScript, there are only -64-bit floating point numbers, which can represent integers in the range -±(253\-1) exactly. See -[`Math.ceil`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil) -on MDN. - -## Examples - -```rescript -Js.Math.unsafe_ceil_int(3.1) == 4 -Js.Math.unsafe_ceil_int(3.0) == 3 -Js.Math.unsafe_ceil_int(-3.1) == -3 -Js.Math.unsafe_ceil_int(1.0e15) // result is outside range of int datatype -``` -*/ -@deprecated({ - reason: "Use `Math.Int.ceil` instead.", - migrate: Math.Int.ceil(), -}) -@val -@scope("Math") -external unsafe_ceil_int: float => int = "ceil" - -@deprecated({ - reason: "Use `Math.Int.ceil` instead.", - migrate: Math.Int.ceil(), -}) -let unsafe_ceil = unsafe_ceil_int - -/** -Returns the smallest `int` greater than or equal to the argument; the result -is pinned to the range of the `int` data type: -2147483648 to 2147483647. See -[`Math.ceil`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil) -on MDN. - -## Examples - -```rescript -Js.Math.ceil_int(3.1) == 4 -Js.Math.ceil_int(3.0) == 3 -Js.Math.ceil_int(-3.1) == -3 -Js.Math.ceil_int(-1.0e15) == -2147483648 -Js.Math.ceil_int(1.0e15) == 2147483647 -``` -*/ -@deprecated({ - reason: "Use `Math.Int.ceil` instead.", - migrate: Math.Int.ceil(), -}) -let ceil_int = (f: float): int => - if f > Js_int.toFloat(Js_int.max) { - Js_int.max - } else if f < Js_int.toFloat(Js_int.min) { - Js_int.min - } else { - unsafe_ceil_int(f) - } - -@deprecated({ - reason: "Use `Math.Int.ceil` instead.", - migrate: Math.Int.ceil(), -}) -let ceil = ceil_int - -/** -Returns the smallest integral value greater than or equal to the argument. -The result is a `float` and is not restricted to the `int` data type range. -See -[`Math.ceil`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil) -on MDN. - -## Examples - -```rescript -Js.Math.ceil_float(3.1) == 4.0 -Js.Math.ceil_float(3.0) == 3.0 -Js.Math.ceil_float(-3.1) == -3.0 -Js.Math.ceil_float(2_150_000_000.3) == 2_150_000_001.0 -``` -*/ -@deprecated({ - reason: "Use `Math.ceil` instead.", - migrate: Math.ceil(), -}) -@val -@scope("Math") -external ceil_float: float => float = "ceil" - -/** -Number of leading zero bits of the argument's 32 bit int representation. See -[`Math.clz32`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32) -on MDN. - -## Examples - -```rescript -Js.Math.clz32(0) == 32 -Js.Math.clz32(-1) == 0 -Js.Math.clz32(255) == 24 -``` -*/ -@deprecated({ - reason: "Use `Math.Int.clz32` instead.", - migrate: Math.Int.clz32(), -}) -@val -@scope("Math") -external clz32: int => int = "clz32" - -/** -Cosine of argument, which must be specified in radians. See -[`Math.cos`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cos) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.cos` instead.", - migrate: Math.cos(), -}) -@val -@scope("Math") -external cos: float => float = "cos" - -/** -Hyperbolic cosine of argument, which must be specified in radians. See -[`Math.cosh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.cosh` instead.", - migrate: Math.cosh(), -}) -@val -@scope("Math") -external cosh: float => float = "cosh" - -/** -Natural exponentional; returns *e* (the base of natural logarithms) to the -power of the given argument. See -[`Math.exp`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/exp) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.exp` instead.", - migrate: Math.exp(), -}) -@val -@scope("Math") -external exp: float => float = "exp" - -/** -Returns *e* (the base of natural logarithms) to the power of the given -argument minus 1. See -[`Math.expm1`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/expm1) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.expm1` instead.", - migrate: Math.expm1(), -}) -@val -@scope("Math") -external expm1: float => float = "expm1" - -/** -Returns the largest integer less than or equal to the argument. This function -may return values not representable by `int`, whose range is -2147483648 to -2147483647. This is because, in JavaScript, there are only 64-bit floating -point numbers, which can represent integers in the range -±(253\-1) exactly. See -[`Math.floor`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor) -on MDN. - -## Examples - -```rescript -Js.Math.unsafe_floor_int(3.7) == 3 -Js.Math.unsafe_floor_int(3.0) == 3 -Js.Math.unsafe_floor_int(-3.7) == -4 -Js.Math.unsafe_floor_int(1.0e15) // result is outside range of int datatype -``` -*/ -@deprecated({ - reason: "Use `Math.Int.floor` instead.", - migrate: Math.Int.floor(), -}) -@val -@scope("Math") -external unsafe_floor_int: float => int = "floor" - -@deprecated({ - reason: "Use `Math.Int.floor` instead.", - migrate: Math.Int.floor(), -}) -let unsafe_floor = unsafe_floor_int - -/** -Returns the largest `int` less than or equal to the argument; the result is -pinned to the range of the `int` data type: -2147483648 to 2147483647. See -[`Math.floor`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor) -on MDN. - -## Examples - -```rescript -Js.Math.floor_int(3.7) == 3 -Js.Math.floor_int(3.0) == 3 -Js.Math.floor_int(-3.1) == -4 -Js.Math.floor_int(-1.0e15) == -2147483648 -Js.Math.floor_int(1.0e15) == 2147483647 -``` -*/ -@deprecated({ - reason: "Use `Math.Int.floor` instead.", - migrate: Math.Int.floor(), -}) -let floor_int = f => - if f > Js_int.toFloat(Js_int.max) { - Js_int.max - } else if f < Js_int.toFloat(Js_int.min) { - Js_int.min - } else { - unsafe_floor(f) - } - -@deprecated({ - reason: "Use `Math.Int.floor` instead.", - migrate: Math.Int.floor(), -}) -let floor = floor_int - -/** -Returns the largest integral value less than or equal to the argument. The -result is a `float` and is not restricted to the `int` data type range. See -[`Math.floor`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor) -on MDN. - -## Examples - -```rescript -Js.Math.floor_float(3.7) == 3.0 -Js.Math.floor_float(3.0) == 3.0 -Js.Math.floor_float(-3.1) == -4.0 -Js.Math.floor_float(2_150_000_000.3) == 2_150_000_000.0 -``` -*/ -@deprecated({ - reason: "Use `Math.floor` instead.", - migrate: Math.floor(), -}) -@val -@scope("Math") -external floor_float: float => float = "floor" - -/** -Round to nearest single precision float. See -[`Math.fround`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround) -on MDN. - -## Examples - -```rescript -Js.Math.fround(5.5) == 5.5 -Js.Math.fround(5.05) == 5.050000190734863 -``` -*/ -@deprecated({ - reason: "Use `Math.fround` instead.", - migrate: Math.fround(), -}) -@val -@scope("Math") -external fround: float => float = "fround" - -/** -Returns the square root of the sum of squares of its two arguments (the -Pythagorean formula). See -[`Math.hypot`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.hypot` instead.", - migrate: Math.hypot(), -}) -@val -@scope("Math") -external hypot: (float, float) => float = "hypot" - -/** -Returns the square root of the sum of squares of the numbers in the array -argument (generalized Pythagorean equation). Using an array allows you to -have more than two items. See -[`Math.hypot`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot) -on MDN. - -## Examples - -```rescript -Js.Math.hypotMany([3.0, 4.0, 12.0]) == 13.0 -``` -*/ -@deprecated({ - reason: "Use `Math.hypotMany` instead.", - migrate: Math.hypotMany(), -}) -@val -@variadic -@scope("Math") -external hypotMany: array => float = "hypot" - -/** -32-bit integer multiplication. Use this only when you need to optimize -performance of multiplication of numbers stored as 32-bit integers. See -[`Math.imul`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.Int.imul` instead.", - migrate: Math.Int.imul(), -}) -@val -@scope("Math") -external imul: (int, int) => int = "imul" - -/** -Returns the natural logarithm of its argument; this is the number *x* such -that *e**x* equals the argument. Returns `NaN` for negative -arguments. See -[`Math.log`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log) -on MDN. - -## Examples - -```rescript -Js.Math.log(Js.Math._E) == 1.0 -Js.Math.log(100.0) == 4.605170185988092 -``` -*/ -@deprecated({ - reason: "Use `Math.log` instead.", - migrate: Math.log(), -}) -@val -@scope("Math") -external log: float => float = "log" - -/** -Returns the natural logarithm of one plus the argument. Returns `NaN` for -arguments less than -1. See -[`Math.log1p`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p) -on MDN. - -## Examples - -```rescript -Js.Math.log1p(Js.Math._E -. 1.0) == 1.0 -Js.Math.log1p(99.0) == 4.605170185988092 -``` -*/ -@deprecated({ - reason: "Use `Math.log1p` instead.", - migrate: Math.log1p(), -}) -@val -@scope("Math") -external log1p: float => float = "log1p" - -/** -Returns the base 10 logarithm of its argument. Returns `NaN` for negative -arguments. See -[`Math.log10`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log10) -on MDN. - -## Examples - -```rescript -Js.Math.log10(1000.0) == 3.0 -Js.Math.log10(0.01) == -2.0 -Js.Math.log10(Js.Math.sqrt(10.0)) == 0.5 -``` -*/ -@deprecated({ - reason: "Use `Math.log10` instead.", - migrate: Math.log10(), -}) -@val -@scope("Math") -external log10: float => float = "log10" - -/** -Returns the base 2 logarithm of its argument. Returns `NaN` for negative -arguments. See -[`Math.log2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2) -on MDN. - -## Examples - -```rescript -Js.Math.log2(512.0) == 9.0 -Js.Math.log2(0.125) == -3.0 -Js.Math.log2(Js.Math._SQRT2) == 0.5000000000000001 // due to precision -``` -*/ -@deprecated({ - reason: "Use `Math.log2` instead.", - migrate: Math.log2(), -}) -@val -@scope("Math") -external log2: float => float = "log2" - -/** -Returns the maximum of its two integer arguments. See -[`Math.max`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.Int.max` instead.", - migrate: Math.Int.max(), -}) -@val -@scope("Math") -external max_int: (int, int) => int = "max" - -/** -Returns the maximum of the integers in the given array. See -[`Math.max`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.Int.maxMany` instead.", - migrate: Math.Int.maxMany(), -}) -@val -@variadic -@scope("Math") -external maxMany_int: array => int = "max" - -/** -Returns the maximum of its two floating point arguments. See -[`Math.max`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.max` instead.", - migrate: Math.max(), -}) -@val -@scope("Math") -external max_float: (float, float) => float = "max" - -/** -Returns the maximum of the floating point values in the given array. See -[`Math.max`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.maxMany` instead.", - migrate: Math.maxMany(), -}) -@val -@variadic -@scope("Math") -external maxMany_float: array => float = "max" - -/** -Returns the minimum of its two integer arguments. See -[`Math.min`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.Int.min` instead.", - migrate: Math.Int.min(), -}) -@val -@scope("Math") -external min_int: (int, int) => int = "min" - -/** -Returns the minimum of the integers in the given array. See -[`Math.min`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.Int.minMany` instead.", - migrate: Math.Int.minMany(), -}) -@val -@variadic -@scope("Math") -external minMany_int: array => int = "min" - -/** -Returns the minimum of its two floating point arguments. See -[`Math.min`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.min` instead.", - migrate: Math.min(), -}) -@val -@scope("Math") -external min_float: (float, float) => float = "min" - -/** -Returns the minimum of the floating point values in the given array. See -[`Math.min`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.minMany` instead.", - migrate: Math.minMany(), -}) -@val -@variadic -@scope("Math") -external minMany_float: array => float = "min" - -/** -Throws the given base to the given exponent. (Arguments and result are -integers.) See -[`Math.pow`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow) -on MDN. - -## Examples - -```rescript -Js.Math.pow_int(~base=3, ~exp=4) == 81 -``` -*/ -@deprecated({ - reason: "Use `Math.Int.pow` instead.", - migrate: Math.Int.pow(%insert.labelledArgument("base"), ~exp=%insert.labelledArgument("exp")), -}) -@val -@scope("Math") -external pow_int: (~base: int, ~exp: int) => int = "pow" - -/** -Throws the given base to the given exponent. (Arguments and result are -floats.) Returns `NaN` if the result would be imaginary. See -[`Math.pow`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow) -on MDN. - -## Examples - -```rescript -Js.Math.pow_float(~base=3.0, ~exp=4.0) == 81.0 -Js.Math.pow_float(~base=4.0, ~exp=-2.0) == 0.0625 -Js.Math.pow_float(~base=625.0, ~exp=0.5) == 25.0 -Js.Math.pow_float(~base=625.0, ~exp=-0.5) == 0.04 -Js.Float.isNaN(Js.Math.pow_float(~base=-2.0, ~exp=0.5)) == true -``` -*/ -@deprecated({ - reason: "Use `Math.pow` instead.", - migrate: Math.pow(%insert.labelledArgument("base"), ~exp=%insert.labelledArgument("exp")), -}) -@val -@scope("Math") -external pow_float: (~base: float, ~exp: float) => float = "pow" - -/** -Returns a random number in the half-closed interval [0,1). See -[`Math.random`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.random` instead.", - migrate: Math.random(), -}) -@val -@scope("Math") -external random: unit => float = "random" - -/** -A call to `random_int(minVal, maxVal)` returns a random number in the -half-closed interval [minVal, maxVal). See -[`Math.random`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.Int.random` instead.", - migrate: Math.Int.random(), -}) -let random_int = (min, max) => floor(random() *. Js_int.toFloat(max - min)) + min - -/** -Rounds its argument to nearest integer. For numbers with a fractional portion -of exactly 0.5, the argument is rounded to the next integer in the direction -of positive infinity. This function may return values not representable by -`int`, whose range is -2147483648 to 2147483647. This is because, in -JavaScript, there are only 64-bit floating point numbers, which can represent -integers in the range ±(253\-1) exactly. See -[`Math.round`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round) -on MDN. - -## Examples - -```rescript -Js.Math.unsafe_round(3.7) == 4 -Js.Math.unsafe_round(-3.5) == -3 -Js.Math.unsafe_round(2_150_000_000_000.3) // out of range for int -``` -*/ -@deprecated({ - reason: "Use `Float.toInt(Math.round(_))` instead.", - migrate: Float.toInt(Math.round(%insert.unlabelledArgument(0))), -}) -@val -@scope("Math") -external unsafe_round: float => int = "round" - -/** -Rounds to nearest integral value (expressed as a float). See -[`Math.round`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.round` instead.", - migrate: Math.round(), -}) -@val -@scope("Math") -external round: float => float = "round" - -/** -Returns the sign of its integer argument: -1 if negative, 0 if zero, 1 if -positive. See -[`Math.sign`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.Int.sign` instead.", - migrate: Math.Int.sign(), -}) -@val -@scope("Math") -external sign_int: int => int = "sign" - -/** -Returns the sign of its float argument: -1.0 if negative, 0.0 if zero, 1.0 if -positive. See -[`Math.sign`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.sign` instead.", - migrate: Math.sign(), -}) -@val -@scope("Math") -external sign_float: float => float = "sign" - -/** -Sine of argument, which must be specified in radians. See -[`Math.sin`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sin) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.sin` instead.", - migrate: Math.sin(), -}) -@val -@scope("Math") -external sin: float => float = "sin" - -/** -Hyperbolic sine of argument, which must be specified in radians. See -[`Math.sinh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sinh) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.sinh` instead.", - migrate: Math.sinh(), -}) -@val -@scope("Math") -external sinh: float => float = "sinh" - -/** -Square root. If the argument is negative, this function returns `NaN`. See -[`Math.sqrt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.sqrt` instead.", - migrate: Math.sqrt(), -}) -@val -@scope("Math") -external sqrt: float => float = "sqrt" - -/** -Tangent of argument, which must be specified in radians. Returns `NaN` if the -argument is positive infinity or negative infinity. See -[`Math.cos`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cos) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.tan` instead.", - migrate: Math.tan(), -}) -@val -@scope("Math") -external tan: float => float = "tan" - -/** -Hyperbolic tangent of argument, which must be specified in radians. See -[`Math.tanh`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tanh) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.tanh` instead.", - migrate: Math.tanh(), -}) -@val -@scope("Math") -external tanh: float => float = "tanh" - -/** -Truncates its argument; i.e., removes fractional digits. This function may -return values not representable by `int`, whose range is -2147483648 to -2147483647. This is because, in JavaScript, there are only 64-bit floating -point numbers, which can represent integers in the range ±(253-1) -exactly. See -[`Math.trunc`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc) -on MDN. -*/ -@deprecated({ - reason: "Use `Float.toInt(Math.trunc(_))` instead.", - migrate: Float.toInt(Math.trunc(%insert.unlabelledArgument(0))), -}) -@val -@scope("Math") -external unsafe_trunc: float => int = "trunc" - -/** -Truncates its argument; i.e., removes fractional digits. See -[`Math.trunc`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc) -on MDN. -*/ -@deprecated({ - reason: "Use `Math.trunc` instead.", - migrate: Math.trunc(), -}) -@val -@scope("Math") -external trunc: float => float = "trunc" diff --git a/packages/@rescript/runtime/Js_null.res b/packages/@rescript/runtime/Js_null.res deleted file mode 100644 index 0229044197f..00000000000 --- a/packages/@rescript/runtime/Js_null.res +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** Provides functionality for dealing with the `'a Js.null` type */ - -@unboxed -type t<+'a> = Primitive_js_extern.null<'a> = Value('a) | @as(null) Null - -external to_opt: t<'a> => option<'a> = "%null_to_opt" -external toOption: t<'a> => option<'a> = "%null_to_opt" -external return: 'a => t<'a> = "%identity" -let test: t<'a> => bool = x => x == Js_extern.null -external empty: t<'a> = "%null" -external getUnsafe: t<'a> => 'a = "%identity" - -let getExn = f => - switch toOption(f) { - | None => Stdlib_Exn.raiseError("Js.Null.getExn") - | Some(x) => x - } - -let bind = (x, f) => - switch toOption(x) { - | None => empty - | Some(x) => return(f(x)) - } - -let iter = (x, f) => - switch toOption(x) { - | None => () - | Some(x) => f(x) - } - -let fromOption = x => - switch x { - | None => empty - | Some(x) => return(x) - } - -let from_opt = fromOption diff --git a/packages/@rescript/runtime/Js_null.resi b/packages/@rescript/runtime/Js_null.resi deleted file mode 100644 index 8dcc5e52956..00000000000 --- a/packages/@rescript/runtime/Js_null.resi +++ /dev/null @@ -1,119 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** Provides functionality for dealing with the `Js.null<'a>` type */ - -@deprecated({ - reason: "Use `Null.t` instead.", - migrate: %replace.type(: Null.t), -}) -@unboxed -type t<+'a> = Primitive_js_extern.null<'a> = Value('a) | @as(null) Null - -/** Constructs a value of `Js.null<'a>` containing a value of `'a`. */ -@deprecated({ - reason: "Use `Null.make` instead.", - migrate: Null.make(), -}) -external return: 'a => t<'a> = "%identity" - -/** Returns `true` if the given value is empty (`null`), `false` otherwise. */ -@deprecated({ - reason: "Use `== Js.null` directly.", - migrate: %insert.unlabelledArgument(0) === Null.null, - migrateInPipeChain: Null.equal(Null, (a, b) => a === b), -}) -let test: t<'a> => bool - -/** The empty value, `null` */ -@deprecated({ - reason: "Use `Null.null` instead.", - migrate: Null.null, -}) -external empty: t<'a> = "%null" - -@deprecated({ - reason: "Use `Null.getUnsafe` instead.", - migrate: Null.getUnsafe(), -}) -external getUnsafe: t<'a> => 'a = "%identity" - -@deprecated({ - reason: "Use `Null.getOrThrow` instead.", - migrate: Null.getOrThrow(), -}) -let getExn: t<'a> => 'a - -/** -Maps the contained value using the given function. - -If `Js.null<'a>` contains a value, that value is unwrapped, mapped to a `'b` -using the given function `'a => 'b`, then wrapped back up and returned as -`Js.null<'b>`. - -## Examples - -```rescript -let maybeGreetWorld = (maybeGreeting: Js.null) => - Js.Null.bind(maybeGreeting, greeting => greeting ++ " world!") -``` -*/ -@deprecated({ - reason: "Use `Null.map` instead.", - migrate: Null.map(), -}) -let bind: (t<'a>, 'a => 'b) => t<'b> - -/** -Iterates over the contained value with the given function. -If `Js.null<'a>` contains a value, that value is unwrapped and applied to the given function. - -## Examples - -```rescript -let maybeSay = (maybeMessage: Js.null) => - Js.Null.iter(maybeMessage, message => Js.log(message)) -``` -*/ -@deprecated({ - reason: "Use `Null.forEach` instead.", - migrate: Null.forEach(), -}) -let iter: (t<'a>, 'a => unit) => unit - -/** -Maps `option<'a>` to `Js.null<'a>`. -`Some(a)` => `a` -`None` => `empty` -*/ -@deprecated({ - reason: "Use `Null.fromOption` instead.", - migrate: Null.fromOption(), -}) -let fromOption: option<'a> => t<'a> - -@deprecated({ - reason: "Use `Null.fromOption` instead.", - migrate: Null.fromOption(), -}) -let from_opt: option<'a> => t<'a> - -/** -Maps `Js.null<'a>` to `option<'a>`. -`a` => `Some(a)` -`empty` => `None` -*/ -@deprecated({ - reason: "Use `Null.toOption` instead.", - migrate: Null.toOption(), -}) -external toOption: t<'a> => option<'a> = "%null_to_opt" - -@deprecated({ - reason: "Use `Null.toOption` instead.", - migrate: Null.toOption(), -}) -external to_opt: t<'a> => option<'a> = "%null_to_opt" diff --git a/packages/@rescript/runtime/Js_null_undefined.res b/packages/@rescript/runtime/Js_null_undefined.res deleted file mode 100644 index 1099e69dfe9..00000000000 --- a/packages/@rescript/runtime/Js_null_undefined.res +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** Contains functionality for dealing with values that can be both `null` and `undefined` */ - -@unboxed -type t<+'a> = Primitive_js_extern.nullable<'a> = - Value('a) | @as(null) Null | @as(undefined) Undefined - -external toOption: t<'a> => option<'a> = "%nullable_to_opt" -external to_opt: t<'a> => option<'a> = "%nullable_to_opt" -external return: 'a => t<'a> = "%identity" -external isNullable: t<'a> => bool = "%is_nullable" -external null: t<'a> = "%null" -external undefined: t<'a> = "%undefined" - -let bind = (x, f) => - switch to_opt(x) { - | None => (Obj.magic((x: t<'a>)): t<'b>) - | Some(x) => return(f(x)) - } - -let iter = (x, f) => - switch to_opt(x) { - | None => () - | Some(x) => f(x) - } - -let fromOption = x => - switch x { - | None => undefined - | Some(x) => return(x) - } - -let from_opt = fromOption diff --git a/packages/@rescript/runtime/Js_null_undefined.resi b/packages/@rescript/runtime/Js_null_undefined.resi deleted file mode 100644 index 72dae441aa4..00000000000 --- a/packages/@rescript/runtime/Js_null_undefined.resi +++ /dev/null @@ -1,117 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** -Contains functionality for dealing with values that can be both `null` and `undefined` -*/ - -@deprecated({ - reason: "Use `Nullable.t` instead.", - migrate: %replace.type(: Nullable.t), -}) -@unboxed -type t<+'a> = Primitive_js_extern.nullable<'a> = - Value('a) | @as(null) Null | @as(undefined) Undefined - -/** Constructs a value of `Js.null_undefined<'a>` containing a value of `'a`. */ -@deprecated({ - reason: "Use `Nullable.make` instead.", - migrate: Nullable.make(), -}) -external return: 'a => t<'a> = "%identity" - -/** Returns `true` if the given value is null or undefined, `false` otherwise. */ -@deprecated({ - reason: "Use `Nullable.isNullable` instead.", - migrate: Nullable.isNullable(), -}) -external isNullable: t<'a> => bool = "%is_nullable" - -/** The null value of type `Js.null_undefined<'a>`. */ -@deprecated({ - reason: "Use `Nullable.null` instead.", - migrate: Nullable.null, -}) -external null: t<'a> = "%null" - -/** The undefined value of type `Js.null_undefined<'a>`. */ -@deprecated({ - reason: "Use `Nullable.undefined` instead.", - migrate: Nullable.undefined, -}) -external undefined: t<'a> = "%undefined" - -/** -Maps the contained value using the given function. - -If `Js.null_undefined<'a>` contains a value, that value is unwrapped, mapped to -a `'b` using the given function `a' => 'b`, then wrapped back up and returned -as `Js.null_undefined<'b>`. - -## Examples - -```rescript -let maybeGreetWorld = (maybeGreeting: Js.null_undefined) => - Js.Null_undefined.bind(maybeGreeting, greeting => greeting ++ " world!") -``` -*/ -@deprecated({ - reason: "Use `Nullable.map` instead.", - migrate: Nullable.map(), -}) -let bind: (t<'a>, 'a => 'b) => t<'b> - -/** -Iterates over the contained value with the given function. -If `Js.null_undefined<'a>` contains a value, that value is unwrapped and applied to the given function. - -## Examples - -```rescript -let maybeSay = (maybeMessage: Js.null_undefined) => - Js.Null_undefined.iter(maybeMessage, message => Js.log(message)) -``` -*/ -@deprecated({ - reason: "Use `Nullable.forEach` instead.", - migrate: Nullable.forEach(), -}) -let iter: (t<'a>, 'a => unit) => unit - -/** -Maps `option<'a>` to `Js.null_undefined<'a>`. -`Some(a)` => `a` -`None` => `undefined` -*/ -@deprecated({ - reason: "Use `Nullable.fromOption` instead.", - migrate: Nullable.fromOption(), -}) -let fromOption: option<'a> => t<'a> - -@deprecated({ - reason: "Use `Nullable.fromOption` instead.", - migrate: Nullable.fromOption(), -}) -let from_opt: option<'a> => t<'a> - -/** -Maps `Js.null_undefined<'a>` to `option<'a>`. -`a` => `Some(a)` -`undefined` => `None` -`null` => `None` -*/ -@deprecated({ - reason: "Use `Nullable.toOption` instead.", - migrate: Nullable.toOption(), -}) -external toOption: t<'a> => option<'a> = "%nullable_to_opt" - -@deprecated({ - reason: "Use `Nullable.toOption` instead.", - migrate: Nullable.toOption(), -}) -external to_opt: t<'a> => option<'a> = "%nullable_to_opt" diff --git a/packages/@rescript/runtime/Js_obj.res b/packages/@rescript/runtime/Js_obj.res deleted file mode 100644 index 7c8e6e0b0b8..00000000000 --- a/packages/@rescript/runtime/Js_obj.res +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** -Provides functions for inspecting and manipulating native JavaScript objects -*/ - -/** `empty()` returns the empty object `{}` */ -@deprecated({ - reason: "Use `Object.make` instead.", - migrate: Object.make(), -}) -@obj -external empty: unit => {..} = "" - -/** -`assign(target, source)` copies properties from source to target. -Properties in `target` will be overwritten by properties in `source` if they have the same key. -Returns `target`. - -**See** [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) - -## Examples - -```rescript -/* Copy an object */ - -let obj = {"a": 1} - -let copy = Js.Obj.assign(Js.Obj.empty(), obj) - -/* prints "{ a: 1 }" */ -Js.log(copy) - -/* Merge objects with same properties */ - -let target = {"a": 1, "b": 1} -let source = {"b": 2} - -let obj = Js.Obj.assign(target, source) - -/* prints "{ a: 1, b: 2 }" */ -Js.log(obj) - -/* prints "{ a: 1, b: 2 }", target is modified */ -Js.log(target) -``` -*/ -@deprecated({ - reason: "Use `Object.assign` instead.", - migrate: Object.assign(), -}) -@val -external assign: ({..}, {..}) => {..} = "Object.assign" - -/* TODO: - - Should we map this API as directly as possible, provide some abstractions, or deliberately nerf it? - - "static": - - Object.create - - Object.defineProperty - - Object.defineProperties - - Object.entries - experimental - - Object.getOwnPropertyDescriptor - - Object.getOwnPropertyDescriptors - - Object.getOwnPropertyNames - - Object.getOwnPropertySymbols - - Object.getPrototypeOf - - Object.isExtensible - - Object.isFrozen - - Object.isSealed - - Object.preventExtension - - Object.seal - - Object.setPrototypeOf - - Object.values - experimental - - send: - - hasOwnProperty - - isPrototypeOf - - propertyIsEnumerable - - toLocaleString - - toString - - Put directly on Js? - - Object.is -*/ - -/** `keys(obj)` returns an `array` of the keys of `obj`'s own enumerable properties. */ -@deprecated({ - reason: "Use `Object.keysToArray` instead.", - migrate: Object.keysToArray(), -}) -@val -external keys: {..} => array = "Object.keys" diff --git a/packages/@rescript/runtime/Js_option.res b/packages/@rescript/runtime/Js_option.res deleted file mode 100644 index 944885fd19e..00000000000 --- a/packages/@rescript/runtime/Js_option.res +++ /dev/null @@ -1,214 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** Provide utilities for handling `option`. */ - -/** -`Js.Option.t` is an alias for `option` -*/ -type t<'a> = option<'a> - -/** -Wraps the given value in `Some()` - -## Examples - -```rescript -Js.Option.some(1066) == Some(1066) -``` -*/ -let some = x => Some(x) - -/** -Returns `true` if the argument is `Some(value)`; `false` if the argument is -`None`. -*/ -let isSome = x => - switch x { - | None => false - | Some(_) => true - } - -/** -The first argument to `isSomeValue` is an uncurried function `eq()` that -takes two arguments and returns `true` if they are considered to be equal. It -is used to compare a plain value `v1`(the second argument) with an `option` -value. If the `option` value is `None`, `isSomeValue()` returns `false`; if -the third argument is `Some(v2)`, `isSomeValue()` returns the result of -calling `eq(v1, v2)`. - -## Examples - -```rescript -let clockEqual = (a, b) => mod(a, 12) == mod(b, 12) -Js.Option.isSomeValue(clockEqual, 3, Some(15)) == true -Js.Option.isSomeValue(clockEqual, 3, Some(4)) == false -Js.Option.isSomeValue(clockEqual, 3, None) == false -``` -*/ -let isSomeValue = (eq, v, x) => - switch x { - | None => false - | Some(x) => eq(v, x) - } - -/** Returns `true` if the argument is `None`; `false` otherwise. */ -let isNone = x => - switch x { - | None => true - | Some(_) => false - } - -/** -If the argument to `getExn()` is of the form `Some(value)`, returns `value`. -If given `None`, it throws a `getExn` exception. -*/ -let getExn = x => - switch x { - | None => Stdlib_Exn.raiseError("getExn") - | Some(x) => x - } - -/** -The first argument to `equal` is an uncurried function `eq()` that takes two -arguments and returns `true` if they are considered to be equal. The second -and third arguments are `option` values. - -If the second and third arguments are of the form: - -* `Some(v1)` and `Some(v2)`: returns `eq(v1, v2)` -* `Some(v1)` and `None`: returns `false` -* `None` and `Some(v2)`: returns `false` -* `None` and `None`: returns `true` - -## Examples - -```rescript -let clockEqual = (a, b) => mod(a, 12) == mod(b, 12) -Js.Option.equal(clockEqual, Some(3), Some(15)) == true -Js.Option.equal(clockEqual, Some(3), Some(16)) == false -Js.Option.equal(clockEqual, Some(3), None) == false -Js.Option.equal(clockEqual, None, Some(15)) == false -Js.Option.equal(clockEqual, None, None) == true -``` -*/ -let equal = (eq, a, b) => - switch a { - | None => b == None - | Some(x) => - switch b { - | None => false - | Some(y) => eq(x, y) - } - } - -/** -The first argument to `andThen()` is an uncurried function `f()` that takes a -plain value and returns an `option` result. The second argument is an -`option` value. If the second argument is `None`, the return value is `None`. -If the second argument is `Some(v)`, the return value is `f(v)`. - -## Examples - -```rescript -let reciprocal = x => x == 0 ? None : Some(1.0 /. Belt.Int.toFloat(x)) -Js.Option.andThen(reciprocal, Some(5)) == Some(0.2) -Js.Option.andThen(reciprocal, Some(0)) == None -Js.Option.andThen(reciprocal, None) == None -``` -*/ -let andThen = (f, x) => - switch x { - | None => None - | Some(x) => f(x) - } - -/** -The first argument to `map()` is an uncurried function `f()` that takes a -plain value and returns a plain result. The second argument is an `option` -value. If it is of the form `Some(v)`, `map()` returns `Some(f(v))`; if it is -`None`, the return value is `None`, and function `f()` is not called. - -## Examples - -```rescript -let square = x => x * x -Js.Option.map(square, Some(3)) == Some(9) -Js.Option.map(square, None) == None -``` -*/ -let map = (f, x) => - switch x { - | None => None - | Some(x) => Some(f(x)) - } - -/** -The first argument to `getWithDefault()` is a default value. If the second -argument is of the form `Some(v)`, `getWithDefault()` returns `v`; if the -second argument is `None`, the return value is the default value. - -## Examples - -```rescript -Js.Option.getWithDefault(1066, Some(15)) == 15 -Js.Option.getWithDefault(1066, None) == 1066 -``` -*/ -let getWithDefault = (a, x) => - switch x { - | None => a - | Some(x) => x - } - -/** **See:** [getWithDefault](#getWithDefault) */ -let default = getWithDefault - -/** -The first argument to `filter()` is an uncurried function that takes a plain -value and returns a boolean. The second argument is an `option` value. - -If the second argument is of the form `Some(v)` and `f(v)` is `true`, -the return value is `Some(v)`. Otherwise, the return value is `None`. - -## Examples - -```rescript -let isEven = x => mod(x, 2) == 0 -Js.Option.filter(isEven, Some(2)) == Some(2) -Js.Option.filter(isEven, Some(3)) == None -Js.Option.filter(isEven, None) == None -``` -*/ -let filter = (f, x) => - switch x { - | None => None - | Some(x) => - if f(x) { - Some(x) - } else { - None - } - } - -/** -The `firstSome()` function takes two `option` values; if the first is of the form `Some(v1)`, that is the return value. Otherwise, `firstSome()` returns the second value. - -## Examples - -```rescript -Js.Option.firstSome(Some("one"), Some("two")) == Some("one") -Js.Option.firstSome(Some("one"), None) == Some("one") -Js.Option.firstSome(None, Some("two")) == Some("two") -Js.Option.firstSome(None, None) == None -``` -*/ -let firstSome = (a, b) => - switch (a, b) { - | (Some(_), _) => a - | (None, Some(_)) => b - | (None, None) => None - } diff --git a/packages/@rescript/runtime/Js_option.resi b/packages/@rescript/runtime/Js_option.resi deleted file mode 100644 index f60b80307c7..00000000000 --- a/packages/@rescript/runtime/Js_option.resi +++ /dev/null @@ -1,91 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -@deprecated({ - reason: "Use `option` directly instead.", - migrate: %replace.type(: option), -}) -type t<'a> = option<'a> - -@deprecated({ - reason: "Use `Some()` directly instead.", - migrate: Some(), -}) -let some: 'a => option<'a> - -@deprecated({ - reason: "Use `Option.isSome` instead.", - migrate: Option.isSome(), -}) -let isSome: option<'a> => bool - -// Skipping automatic migration because this is a rather weird function that is probably not that much used. -@deprecated("Use `Option.equal` instead.") -let isSomeValue: (('a, 'a) => bool, 'a, option<'a>) => bool - -@deprecated({ - reason: "Use `Option.isNone` instead.", - migrate: Option.isNone(), -}) -let isNone: option<'a> => bool - -@deprecated({ - reason: "Use `Option.getOrThrow` instead.", - migrate: Option.getOrThrow(), -}) -let getExn: option<'a> => 'a - -@deprecated({ - reason: "Use `Option.equal` instead.", - migrate: Option.equal( - %insert.unlabelledArgument(1), - %insert.unlabelledArgument(2), - %insert.unlabelledArgument(0), - ), -}) -let equal: (('a, 'b) => bool, option<'a>, option<'b>) => bool - -@deprecated({ - reason: "Use `Option.flatMap` instead.", - migrate: Option.flatMap(%insert.unlabelledArgument(1), %insert.unlabelledArgument(0)), - migrateInPipeChain: Option.flatMap(%insert.unlabelledArgument(0)), -}) -let andThen: ('a => option<'b>, option<'a>) => option<'b> - -@deprecated({ - reason: "Use `Option.map` instead.", - migrate: Option.map(%insert.unlabelledArgument(1), %insert.unlabelledArgument(0)), - migrateInPipeChain: Option.map(%insert.unlabelledArgument(0)), -}) -let map: ('a => 'b, option<'a>) => option<'b> - -@deprecated({ - reason: "Use `Option.getOr` instead.", - migrate: Option.getOr(%insert.unlabelledArgument(1), %insert.unlabelledArgument(0)), - migrateInPipeChain: Option.getOr(%insert.unlabelledArgument(0)), -}) -let getWithDefault: ('a, option<'a>) => 'a - -@deprecated({ - reason: "Use `Option.getOr` instead. Note: `default` has special meaning in ES modules.", - migrate: Option.getOr(%insert.unlabelledArgument(1), %insert.unlabelledArgument(0)), - migrateInPipeChain: Option.getOr(%insert.unlabelledArgument(0)), -}) -let default: ('a, option<'a>) => 'a - -@deprecated({ - reason: "Use `Option.filter` instead.", - migrate: Option.filter(%insert.unlabelledArgument(1), %insert.unlabelledArgument(0)), - migrateInPipeChain: Option.filter(%insert.unlabelledArgument(0)), -}) -let filter: ('a => bool, option<'a>) => option<'a> - -@deprecated({ - reason: "Use `Option.orElse` instead.", - migrate: Option.orElse(), - migrateInPipeChain: Option.orElse(%insert.unlabelledArgument(0)), -}) -let firstSome: (option<'a>, option<'a>) => option<'a> diff --git a/packages/@rescript/runtime/Js_promise.res b/packages/@rescript/runtime/Js_promise.res deleted file mode 100644 index 5636e3fb80f..00000000000 --- a/packages/@rescript/runtime/Js_promise.res +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** -Deprecation note: These bindings are pretty outdated and cannot be used properly -with the `->` operator. - -More details on proper Promise usage can be found here: -https://rescript-lang.org/docs/manual/latest/promise#promise-legacy -*/ - -@@warning("-103") - -type t<+'a> = promise<'a> - -type error = Js_promise2.error - -/* -## Examples - -```rescript -type error -``` -*/ - -@new -external make: ((~resolve: 'a => unit, ~reject: exn => unit) => unit) => promise<'a> = "Promise" - -/* `make (fun resolve reject -> .. )` */ -@val @scope("Promise") -external resolve: 'a => promise<'a> = "resolve" -@val @scope("Promise") -external reject: exn => promise<'a> = "reject" - -@val @scope("Promise") -external all: array> => promise> = "all" - -@val @scope("Promise") -external all2: ((promise<'a0>, promise<'a1>)) => promise<('a0, 'a1)> = "all" - -@val @scope("Promise") -external all3: ((promise<'a0>, promise<'a1>, promise<'a2>)) => promise<('a0, 'a1, 'a2)> = "all" - -@val @scope("Promise") -external all4: ((promise<'a0>, promise<'a1>, promise<'a2>, promise<'a3>)) => promise<( - 'a0, - 'a1, - 'a2, - 'a3, -)> = "all" - -@val @scope("Promise") -external all5: ((promise<'a0>, promise<'a1>, promise<'a2>, promise<'a3>, promise<'a4>)) => promise<( - 'a0, - 'a1, - 'a2, - 'a3, - 'a4, -)> = "all" - -@val @scope("Promise") -external all6: ( - (promise<'a0>, promise<'a1>, promise<'a2>, promise<'a3>, promise<'a4>, promise<'a5>) -) => promise<('a0, 'a1, 'a2, 'a3, 'a4, 'a5)> = "all" - -@val @scope("Promise") -external race: array> => promise<'a> = "race" - -@send -external then_: (promise<'a>, 'a => promise<'b>) => promise<'b> = "then" -let then_ = (arg1, obj) => then_(obj, arg1) - -@send -external catch: (promise<'a>, error => promise<'a>) => promise<'a> = "catch" -let catch = (arg1, obj) => catch(obj, arg1) -/* ` p|> catch handler` - Note in JS the returned promise type is actually runtime dependent, - if promise is rejected, it will pick the `handler` otherwise the original promise, - to make it strict we enforce reject handler - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch -*/ - -/* -let errorAsExn (x : error) (e : (exn ->'a option))= - if Caml_exceptions.isCamlExceptionOrOpenVariant (Obj.magic x ) then - e (Obj.magic x) - else None -[%bs.error? ] -*/ diff --git a/packages/@rescript/runtime/Js_promise.resi b/packages/@rescript/runtime/Js_promise.resi deleted file mode 100644 index 56847a3bf87..00000000000 --- a/packages/@rescript/runtime/Js_promise.resi +++ /dev/null @@ -1,162 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** -Deprecation note: These bindings are pretty outdated and cannot be used properly -with the `->` operator. - -More details on proper Promise usage can be found here: -https://rescript-lang.org/docs/manual/latest/promise#promise-legacy -*/ - -@@warning("-103") - -@deprecated({ - reason: "Use `promise` directly instead.", - migrate: %replace.type(: promise), -}) -type t<+'a> = promise<'a> - -@deprecated({ - reason: "Use `exn` directly instead.", - migrate: %replace.type(: exn), -}) -type error = Js_promise2.error - -/* -## Examples - -```rescript -type error -``` -*/ - -@deprecated({ - reason: "Use `Promise.make` instead.", - migrate: Promise.make( - @apply.transforms(["labelledToUnlabelledArgumentsInFnDefinition"]) - %insert.unlabelledArgument(0), - ), -}) -@new -external make: ((~resolve: 'a => unit, ~reject: exn => unit) => unit) => promise<'a> = "Promise" - -/* `make (fun resolve reject -> .. )` */ -@deprecated({ - reason: "Use `Promise.resolve` instead.", - migrate: Promise.resolve(), -}) -@val -@scope("Promise") -external resolve: 'a => promise<'a> = "resolve" -@deprecated({ - reason: "Use `Promise.reject` instead.", - migrate: Promise.reject(), -}) -@val -@scope("Promise") -external reject: exn => promise<'a> = "reject" - -@deprecated({ - reason: "Use `Promise.all` instead.", - migrate: Promise.all(), -}) -@val -@scope("Promise") -external all: array> => promise> = "all" - -@deprecated({ - reason: "Use `Promise.all2` instead.", - migrate: Promise.all2(), -}) -@val -@scope("Promise") -external all2: ((promise<'a0>, promise<'a1>)) => promise<('a0, 'a1)> = "all" - -@deprecated({ - reason: "Use `Promise.all3` instead.", - migrate: Promise.all3(), -}) -@val -@scope("Promise") -external all3: ((promise<'a0>, promise<'a1>, promise<'a2>)) => promise<('a0, 'a1, 'a2)> = "all" - -@deprecated({ - reason: "Use `Promise.all4` instead.", - migrate: Promise.all4(), -}) -@val -@scope("Promise") -external all4: ((promise<'a0>, promise<'a1>, promise<'a2>, promise<'a3>)) => promise<( - 'a0, - 'a1, - 'a2, - 'a3, -)> = "all" - -@deprecated({ - reason: "Use `Promise.all5` instead.", - migrate: Promise.all5(), -}) -@val -@scope("Promise") -external all5: ((promise<'a0>, promise<'a1>, promise<'a2>, promise<'a3>, promise<'a4>)) => promise<( - 'a0, - 'a1, - 'a2, - 'a3, - 'a4, -)> = "all" - -@deprecated({ - reason: "Use `Promise.all6` instead.", - migrate: Promise.all6(), -}) -@val -@scope("Promise") -external all6: ( - (promise<'a0>, promise<'a1>, promise<'a2>, promise<'a3>, promise<'a4>, promise<'a5>) -) => promise<('a0, 'a1, 'a2, 'a3, 'a4, 'a5)> = "all" - -@deprecated({ - reason: "Use `Promise.race` instead.", - migrate: Promise.race(), -}) -@val -@scope("Promise") -external race: array> => promise<'a> = "race" - -@deprecated({ - reason: "Use `Promise.then` instead.", - migrate: Promise.then(), -}) -@deprecated({ - reason: "Use `Promise.then` instead.", - migrate: Promise.then(%insert.unlabelledArgument(1), %insert.unlabelledArgument(0)), - migrateInPipeChain: Promise.then(%insert.unlabelledArgument(0)), -}) -let then_: ('a => promise<'b>, promise<'a>) => promise<'b> - -@deprecated({ - reason: "Use `Promise.catch` instead.", - migrate: Promise.catch(%insert.unlabelledArgument(1), %insert.unlabelledArgument(0)), - migrateInPipeChain: Promise.catch(%insert.unlabelledArgument(0)), -}) -let catch: (error => promise<'a>, promise<'a>) => promise<'a> -/* ` p|> catch handler` - Note in JS the returned promise type is actually runtime dependent, - if promise is rejected, it will pick the `handler` otherwise the original promise, - to make it strict we enforce reject handler - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch -*/ - -/* -let errorAsExn (x : error) (e : (exn ->'a option))= - if Caml_exceptions.isCamlExceptionOrOpenVariant (Obj.magic x ) then - e (Obj.magic x) - else None -[%bs.error? ] -*/ diff --git a/packages/@rescript/runtime/Js_promise2.res b/packages/@rescript/runtime/Js_promise2.res deleted file mode 100644 index 2d3768600a7..00000000000 --- a/packages/@rescript/runtime/Js_promise2.res +++ /dev/null @@ -1,62 +0,0 @@ -type t<+'a> = promise<'a> -type error - -/** Type-safe t-first then */ -let then: (promise<'a>, 'a => promise<'b>) => promise<'b> = %raw(` - function(p, cont) { - return Promise.resolve(p).then(cont) - } - `) - -/** Type-safe t-first catch */ -let catch: (promise<'a>, error => promise<'a>) => promise<'a> = %raw(` - function(p, cont) { - return Promise.resolve(p).catch(cont) - } - `) - -@new -external make: ((~resolve: 'a => unit, ~reject: exn => unit) => unit) => promise<'a> = "Promise" - -@val @scope("Promise") -external resolve: 'a => promise<'a> = "resolve" - -@val @scope("Promise") -external reject: exn => promise<'a> = "reject" - -@val @scope("Promise") -external all: array> => promise> = "all" - -@val @scope("Promise") -external all2: ((promise<'a0>, promise<'a1>)) => promise<('a0, 'a1)> = "all" - -@val @scope("Promise") -external all3: ((promise<'a0>, promise<'a1>, promise<'a2>)) => promise<('a0, 'a1, 'a2)> = "all" - -@val @scope("Promise") -external all4: ((promise<'a0>, promise<'a1>, promise<'a2>, promise<'a3>)) => promise<( - 'a0, - 'a1, - 'a2, - 'a3, -)> = "all" - -@val @scope("Promise") -external all5: ((promise<'a0>, promise<'a1>, promise<'a2>, promise<'a3>, promise<'a4>)) => promise<( - 'a0, - 'a1, - 'a2, - 'a3, - 'a4, -)> = "all" - -@val @scope("Promise") -external all6: ( - (promise<'a0>, promise<'a1>, promise<'a2>, promise<'a3>, promise<'a4>, promise<'a5>) -) => promise<('a0, 'a1, 'a2, 'a3, 'a4, 'a5)> = "all" - -@val @scope("Promise") -external race: array> => promise<'a> = "race" - -external unsafe_async: 'a => promise<'a> = "%identity" -external unsafe_await: promise<'a> => 'a = "%await" diff --git a/packages/@rescript/runtime/Js_promise2.resi b/packages/@rescript/runtime/Js_promise2.resi deleted file mode 100644 index 9be0adb6cd5..00000000000 --- a/packages/@rescript/runtime/Js_promise2.resi +++ /dev/null @@ -1,117 +0,0 @@ -@deprecated({ - reason: "Use `promise` directly instead.", - migrate: %replace.type(: promise), -}) -type t<+'a> = promise<'a> -type error - -/** Type-safe t-first then */ -@deprecated({ - reason: "Use `Promise.then` instead.", - migrate: Promise.then(), -}) -let then: (promise<'a>, 'a => promise<'b>) => promise<'b> - -/** Type-safe t-first catch */ -@deprecated({ - reason: "Use `Promise.catch` instead.", - migrate: Promise.catch(), -}) -let catch: (promise<'a>, error => promise<'a>) => promise<'a> - -@deprecated({ - reason: "Use `Promise.make` instead.", - migrate: Promise.make( - @apply.transforms(["labelledToUnlabelledArgumentsInFnDefinition"]) - %insert.unlabelledArgument(0), - ), -}) -@new -external make: ((~resolve: 'a => unit, ~reject: exn => unit) => unit) => promise<'a> = "Promise" - -@deprecated({ - reason: "Use `Promise.resolve` instead.", - migrate: Promise.resolve(), -}) -@val -@scope("Promise") -external resolve: 'a => promise<'a> = "resolve" -@deprecated({ - reason: "Use `Promise.reject` instead.", - migrate: Promise.reject(), -}) -@val -@scope("Promise") -external reject: exn => promise<'a> = "reject" - -@deprecated({ - reason: "Use `Promise.all` instead.", - migrate: Promise.all(), -}) -@val -@scope("Promise") -external all: array> => promise> = "all" - -@deprecated({ - reason: "Use `Promise.all2` instead.", - migrate: Promise.all2(), -}) -@val -@scope("Promise") -external all2: ((promise<'a0>, promise<'a1>)) => promise<('a0, 'a1)> = "all" - -@deprecated({ - reason: "Use `Promise.all3` instead.", - migrate: Promise.all3(), -}) -@val -@scope("Promise") -external all3: ((promise<'a0>, promise<'a1>, promise<'a2>)) => promise<('a0, 'a1, 'a2)> = "all" - -@deprecated({ - reason: "Use `Promise.all4` instead.", - migrate: Promise.all4(), -}) -@val -@scope("Promise") -external all4: ((promise<'a0>, promise<'a1>, promise<'a2>, promise<'a3>)) => promise<( - 'a0, - 'a1, - 'a2, - 'a3, -)> = "all" - -@deprecated({ - reason: "Use `Promise.all5` instead.", - migrate: Promise.all5(), -}) -@val -@scope("Promise") -external all5: ((promise<'a0>, promise<'a1>, promise<'a2>, promise<'a3>, promise<'a4>)) => promise<( - 'a0, - 'a1, - 'a2, - 'a3, - 'a4, -)> = "all" - -@deprecated({ - reason: "Use `Promise.all6` instead.", - migrate: Promise.all6(), -}) -@val -@scope("Promise") -external all6: ( - (promise<'a0>, promise<'a1>, promise<'a2>, promise<'a3>, promise<'a4>, promise<'a5>) -) => promise<('a0, 'a1, 'a2, 'a3, 'a4, 'a5)> = "all" - -@deprecated({ - reason: "Use `Promise.race` instead.", - migrate: Promise.race(), -}) -@val -@scope("Promise") -external race: array> => promise<'a> = "race" - -external unsafe_async: 'a => promise<'a> = "%identity" -external unsafe_await: promise<'a> => 'a = "%await" diff --git a/packages/@rescript/runtime/Js_re.res b/packages/@rescript/runtime/Js_re.res deleted file mode 100644 index 03da41c8cdb..00000000000 --- a/packages/@rescript/runtime/Js_re.res +++ /dev/null @@ -1,254 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** -Provide bindings to JS regular expressions (RegExp). - -**Note:** This is not an immutable API. A RegExp object with the `global` ("g") -flag set will modify the [`lastIndex`]() property when the RegExp object is used, -and subsequent uses will continue the search from the previous [`lastIndex`](). -*/ - -/** The RegExp object. */ -@deprecated({ - reason: "Use `RegExp.t` instead.", - migrate: %replace.type(: RegExp.t), -}) -type t = Stdlib_RegExp.t - -/** The result of a executing a RegExp on a string. */ -type result - -/** -An `array` of the match and captures, the first is the full match and the -remaining are the substring captures. -*/ -@deprecated({ - reason: "Use `RegExp.Result.matches` instead.", - migrate: RegExp.Result.matches(), -}) -external captures: result => array> = "%identity" - -@deprecated({ - reason: "Use `RegExp.Result.matches` instead.", - migrate: RegExp.Result.matches(), -}) -external matches: result => array = "%identity" - -/** 0-based index of the match in the input string. */ -@deprecated({ - reason: "Use `RegExp.Result.index` instead.", - migrate: RegExp.Result.index(), -}) -@get -external index: result => int = "index" - -/** The original input string. */ -@deprecated({ - reason: "Use `RegExp.Result.input` instead.", - migrate: RegExp.Result.input(), -}) -@get -external input: result => string = "input" - -/** -Constructs a RegExp object (Js.Re.t) from a `string`. -Regex literals `/.../` should generally be preferred, but `fromString` -is useful when you need to dynamically construct a regex using strings, -exactly like when you do so in JavaScript. - -## Examples - -```rescript -let firstReScriptFileExtension = (filename, content) => { - let result = Js.Re.fromString(filename ++ "\.(res|resi)")->Js.Re.exec_(content) - switch result { - | Some(r) => Js.Nullable.toOption(Js.Re.captures(r)[1]) - | None => None - } -} - -// outputs "res" -firstReScriptFileExtension("School", "School.res School.resi Main.js School.bs.js") -``` -*/ -@deprecated({ - reason: "Use `RegExp.fromString` instead.", - migrate: RegExp.fromString(), -}) -@new -external fromString: string => t = "RegExp" - -/** -Constructs a RegExp object (`Js.Re.t`) from a string with the given flags. -See `Js.Re.fromString`. - -Valid flags: - -- **g** global -- **i** ignore case -- **m** multiline -- **u** unicode (es2015) -- **y** sticky (es2015) -*/ -@deprecated({ - reason: "Use `RegExp.fromString` instead.", - migrate: RegExp.fromString(), -}) -@new -external fromStringWithFlags: (string, ~flags: string) => t = "RegExp" - -/** Returns the enabled flags as a string. */ -@deprecated({ - reason: "Use `RegExp.flags` instead.", - migrate: RegExp.flags(), -}) -@get -external flags: t => string = "flags" - -/** Returns a `bool` indicating whether the global flag is set. */ -@deprecated({ - reason: "Use `RegExp.global` instead.", - migrate: RegExp.global(), -}) -@get -external global: t => bool = "global" - -/** Returns a `bool` indicating whether the ignoreCase flag is set. */ -@deprecated({ - reason: "Use `RegExp.ignoreCase` instead.", - migrate: RegExp.ignoreCase(), -}) -@get -external ignoreCase: t => bool = "ignoreCase" - -/** -Returns the index where the next match will start its search. This property -will be modified when the RegExp object is used, if the global ("g") flag is -set. - -## Examples - -```rescript -let re = /ab*TODO/g -let str = "abbcdefabh" - -let break_ = ref(false) -while !break_.contents { - switch Js.Re.exec_(re, str) { - | Some(result) => - Js.Nullable.iter(Js.Re.captures(result)[0], match_ => { - let next = Belt.Int.toString(Js.Re.lastIndex(re)) - Js.log("Found " ++ (match_ ++ (". Next match starts at " ++ next))) - }) - | None => break_ := true - } -} -``` - -See -[`RegExp: lastIndex`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex) -on MDN. -*/ -@deprecated({ - reason: "Use `RegExp.lastIndex` instead.", - migrate: RegExp.lastIndex(), -}) -@get -external lastIndex: t => int = "lastIndex" - -/** Sets the index at which the next match will start its search from. */ -@deprecated({ - reason: "Use `RegExp.setLastIndex` instead.", - migrate: RegExp.setLastIndex(), -}) -@set -external setLastIndex: (t, int) => unit = "lastIndex" - -/** Returns a `bool` indicating whether the multiline flag is set. */ -@deprecated({ - reason: "Use `RegExp.multiline` instead.", - migrate: RegExp.multiline(), -}) -@get -external multiline: t => bool = "multiline" - -/** Returns the pattern as a `string`. */ -@deprecated({ - reason: "Use `RegExp.source` instead.", - migrate: RegExp.source(), -}) -@get -external source: t => string = "source" - -/** Returns a `bool` indicating whether the sticky flag is set. */ -@deprecated({ - reason: "Use `RegExp.sticky` instead.", - migrate: RegExp.sticky(), -}) -@get -external sticky: t => bool = "sticky" - -/** Returns a `bool` indicating whether the unicode flag is set. */ -@deprecated({ - reason: "Use `RegExp.unicode` instead.", - migrate: RegExp.unicode(), -}) -@get -external unicode: t => bool = "unicode" - -/** -Executes a search on a given string using the given RegExp object. -Returns `Some(Js.Re.result)` if a match is found, `None` otherwise. - -## Examples - -```rescript -/* Match "quick brown" followed by "jumps", ignoring characters in between - * Remember "brown" and "jumps" - * Ignore case - */ - -let re = /quick\s(brown).+?(jumps)/ig -let result = Js.Re.exec_(re, "The Quick Brown Fox Jumps Over The Lazy Dog") -``` - -See [`RegExp.prototype.exec()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec) -on MDN. -*/ -@deprecated({ - reason: "Use `RegExp.exec` instead.", - migrate: RegExp.exec(), -}) -@send -@return(null_to_opt) -external exec_: (t, string) => option = "exec" - -/** -Tests whether the given RegExp object will match a given `string`. -Returns true if a match is found, false otherwise. - -## Examples - -```rescript -/* A simple implementation of Js.String.startsWith */ - -let str = "hello world!" - -let startsWith = (target, substring) => Js.Re.fromString("^" ++ substring)->Js.Re.test_(target) - -Js.log(str->startsWith("hello")) /* prints "true" */ -``` - -See [`RegExp.prototype.test()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/test) -on MDN. -*/ -@deprecated({ - reason: "Use `RegExp.test` instead.", - migrate: RegExp.test(), -}) -@send -external test_: (t, string) => bool = "test" diff --git a/packages/@rescript/runtime/Js_result.res b/packages/@rescript/runtime/Js_result.res deleted file mode 100644 index 56dd7e7f127..00000000000 --- a/packages/@rescript/runtime/Js_result.res +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -@deprecated({ - reason: "Use `result` directly instead", - migrate: %replace.type(: result), -}) -type t<+'good, +'bad> = - | Ok('good) - | Error('bad) diff --git a/packages/@rescript/runtime/Js_result.resi b/packages/@rescript/runtime/Js_result.resi deleted file mode 100644 index f072d001699..00000000000 --- a/packages/@rescript/runtime/Js_result.resi +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -@deprecated({ - reason: "Use `result` directly instead.", - migrate: %replace.type(: result), -}) -type t<+'good, +'bad> = - | Ok('good) - | Error('bad) diff --git a/packages/@rescript/runtime/Js_set.res b/packages/@rescript/runtime/Js_set.res deleted file mode 100644 index 80d89dbb814..00000000000 --- a/packages/@rescript/runtime/Js_set.res +++ /dev/null @@ -1,7 +0,0 @@ -/*** ES6 Set API */ - -@deprecated({ - reason: "Use `Set.t` instead.", - migrate: %replace.type(: Set.t), -}) -type t<'a> = Stdlib_Set.t<'a> diff --git a/packages/@rescript/runtime/Js_string.res b/packages/@rescript/runtime/Js_string.res deleted file mode 100644 index ef8964768bf..00000000000 --- a/packages/@rescript/runtime/Js_string.res +++ /dev/null @@ -1,1083 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** JavaScript String API */ - -@@warning("-103") - -@deprecated({ - reason: "Use `string` directly instead.", - migrate: %replace.type(: string), -}) -type t = string - -/** -`make(value)` converts the given value to a `string`. - -## Examples - -```rescript -Js.String2.make(3.5) == "3.5" -Js.String2.make([1, 2, 3]) == "1,2,3" -``` -*/ -@deprecated({ - reason: "Use `String.make` instead.", - migrate: String.make(), -}) -@val -external make: 'a => t = "String" - -/** -`fromCharCode(n)` creates a `string` containing the character corresponding to that number; `n` ranges from 0 to 65535. -If out of range, the lower 16 bits of the value are used. Thus, `fromCharCode(0x1F63A)` gives the same result as `fromCharCode(0xF63A)`. See [`String.fromCharCode`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode) on MDN. - -## Examples - -```rescript -Js.String2.fromCharCode(65) == "A" -Js.String2.fromCharCode(0x3c8) == `ψ` -Js.String2.fromCharCode(0xd55c) == `한` -Js.String2.fromCharCode(-64568) == `ψ` -``` -*/ -@deprecated({ - reason: "Use `String.fromCharCode` instead.", - migrate: String.fromCharCode(), -}) -@val -external fromCharCode: int => t = "String.fromCharCode" - -/** -`fromCharCodeMany([n1, n2, n3])` creates a `string` from the characters -corresponding to the given numbers, using the same rules as `fromCharCode`. See -[`String.fromCharCode`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode) -on MDN. -*/ -@deprecated({ - reason: "Use `String.fromCharCodeMany` instead.", - migrate: String.fromCharCodeMany(), -}) -@val -@variadic -external fromCharCodeMany: array => t = "String.fromCharCode" - -/** -`fromCodePoint(n)` creates a `string` containing the character corresponding to -that numeric code point. If the number is not a valid code point, it throws -`RangeError`.Thus, `fromCodePoint(0x1F63A)` will produce a correct value, -unlike `fromCharCode(0x1F63A)`, and `fromCodePoint(-5)` will throw a -`RangeError`. - -See [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint) -on MDN. - -## Examples - -```rescript -Js.String2.fromCodePoint(65) == "A" -Js.String2.fromCodePoint(0x3c8) == `ψ` -Js.String2.fromCodePoint(0xd55c) == `한` -Js.String2.fromCodePoint(0x1f63a) == `😺` -``` -*/ -@deprecated({ - reason: "Use `String.fromCodePoint` instead.", - migrate: String.fromCodePoint(), -}) -@val -external fromCodePoint: int => t = "String.fromCodePoint" - -/** -`fromCodePointMany([n1, n2, n3])` creates a `string` from the characters -corresponding to the given code point numbers, using the same rules as -`fromCodePoint`. - -See [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint) -on MDN. - -## Examples - -```rescript -Js.String2.fromCodePointMany([0xd55c, 0xae00, 0x1f63a]) == `한글😺` -``` -*/ -@deprecated({ - reason: "Use `String.fromCodePointMany` instead.", - migrate: String.fromCodePointMany(), -}) -@val -@variadic -external fromCodePointMany: array => t = "String.fromCodePoint" - -/* String.raw: ES2015, meant to be used with template strings, not directly */ - -/** -`length(s)` returns the length of the given `string`. See -[`String.length`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length) -on MDN. - -## Examples - -```rescript -Js.String2.length("abcd") == 4 -``` -*/ -@deprecated({ - reason: "Use `String.length` instead.", - migrate: String.length(), -}) -@get -external length: t => int = "length" - -/** -`get(s, n)` returns as a `string` the character at the given index number. If -`n` is out of range, this function returns `undefined`, so at some point this -function may be modified to return `option`. - -## Examples - -```rescript -Js.String2.get("Reason", 0) == "R" -Js.String2.get("Reason", 4) == "o" -Js.String2.get(`Rẽasöń`, 5) == `Å„` -``` -*/ -@deprecated({ - reason: "Use `String.get` instead.", - migrate: String.get(), -}) -@get_index -external get: (t, int) => t = "" - -/** -`charAt(n, s)` gets the character at index `n` within string `s`. If `n` is -negative or greater than the length of `s`, it returns the empty string. If the -string contains characters outside the range \\u0000-\\uffff, it will return the -first 16-bit value at that position in the string. - -See [`String.charAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt) -on MDN. - -## Examples - -```rescript -Js.String.charAt(0, "Reason") == "R" -Js.String.charAt(12, "Reason") == "" -Js.String.charAt(5, `Rẽasöń`) == `Å„` -``` -*/ -@send -external charAt: (t, int) => t = "charAt" -let charAt = (arg1, obj) => charAt(obj, arg1) - -/** -`charCodeAt(n, s)` returns the character code at position `n` in string `s`; -the result is in the range 0-65535, unlke `codePointAt`, so it will not work -correctly for characters with code points greater than or equal to 0x10000. The -return type is `float` because this function returns NaN if `n` is less than -zero or greater than the length of the string. - -See [`String.charCodeAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt) -on MDN. - -## Examples - -```rescript -Js.String.charCodeAt(0, `😺`) == 0xd83d->Belt.Int.toFloat -Js.String.codePointAt(0, `😺`) == Some(0x1f63a) -``` -*/ -@send -external charCodeAt: (t, int) => float = "charCodeAt" -let charCodeAt = (arg1, obj) => charCodeAt(obj, arg1) - -/** -`codePointAt(n, s)` returns the code point at position `n` within string `s` as -a `Some(value)`. The return value handles code points greater than or equal to -0x10000. If there is no code point at the given position, the function returns -`None`. - -See [`String.codePointAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt) -on MDN. - -## Examples - -```rescript -Js.String.codePointAt(1, `¿😺?`) == Some(0x1f63a) -Js.String.codePointAt(5, "abc") == None -``` -*/ -@send -external codePointAt: (t, int) => option = "codePointAt" -let codePointAt = (arg1, obj) => codePointAt(obj, arg1) - -/** -`concat(append, original)` returns a new `string` with `append` added after -`original`. - -See [`String.concat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat) -on MDN. - -## Examples - -```rescript -Js.String.concat("bell", "cow") == "cowbell" -``` -*/ -@send -external concat: (t, t) => t = "concat" -let concat = (arg1, obj) => concat(obj, arg1) - -/** -`concat(arr, original)` returns a new `string` consisting of each item of an -array of strings added to the `original` string. - -See [`String.concat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat) -on MDN. - -## Examples - -```rescript -Js.String.concatMany(["2nd", "3rd", "4th"], "1st") == "1st2nd3rd4th" -``` -*/ -@send @variadic -external concatMany: (t, array) => t = "concat" -let concatMany = (arg1, obj) => concatMany(obj, arg1) - -/** -ES2015: `endsWith(substr, str)` returns `true` if the `str` ends with `substr`, -`false` otherwise. - -See [`String.endsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith) -on MDN. - -## Examples - -```rescript -Js.String.endsWith("Script", "ReScript") == true -Js.String.endsWith("Script", "C++") == false -``` -*/ -@send -external endsWith: (t, t) => bool = "endsWith" -let endsWith = (arg1, obj) => endsWith(obj, arg1) - -/** -`endsWithFrom(ending, len, str)` returns `true` if the first len characters of -`str` end with `ending`, `false` otherwise. If `len` is greater than or equal -to the length of `str`, then it works like `endsWith`. (Honestly, this should -have been named endsWithAt, but oh well.) - -See [`String.endsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith) -on MDN. - -## Examples - -```rescript -Js.String.endsWithFrom("cd", 4, "abcd") == true -Js.String.endsWithFrom("cd", 3, "abcde") == false -Js.String.endsWithFrom("cde", 99, "abcde") == true -Js.String.endsWithFrom("ple", 7, "example.dat") == true -``` -*/ -@send -external endsWithFrom: (t, t, int) => bool = "endsWith" -let endsWithFrom = (arg1, arg2, obj) => endsWithFrom(obj, arg1, arg2) - -/** -ES2015: `includes(searchValue, str)` returns `true` if `searchValue` is found -anywhere within `str`, false otherwise. - -See [`String.includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) -on MDN. - -## Examples - -```rescript -Js.String.includes("gram", "programmer") == true -Js.String.includes("er", "programmer") == true -Js.String.includes("pro", "programmer") == true -Js.String.includes("xyz", "programmer.dat") == false -``` -*/ -@send -external includes: (t, t) => bool = "includes" -let includes = (arg1, obj) => includes(obj, arg1) - -/** -ES2015: `includes(searchValue start, str)` returns `true` if `searchValue` is -found anywhere within `str` starting at character number `start` (where 0 is -the first character), `false` otherwise. - -See [`String.includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) -on MDN. - -## Examples - -```rescript -Js.String.includesFrom("gram", 1, "programmer") == true -Js.String.includesFrom("gram", 4, "programmer") == false -Js.String.includesFrom(`한`, 1, `대한민국`) == true -``` -*/ -@send -external includesFrom: (t, t, int) => bool = "includes" -let includesFrom = (arg1, arg2, obj) => includesFrom(obj, arg1, arg2) - -/** -ES2015: `indexOf(searchValue, str)` returns the position at which `searchValue` -was first found within `str`, or -1 if `searchValue` is not in `str`. - -See [`String.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf) -on MDN. - -## Examples - -```rescript -Js.String.indexOf("ok", "bookseller") == 2 -Js.String.indexOf("sell", "bookseller") == 4 -Js.String.indexOf("ee", "beekeeper") == 1 -Js.String.indexOf("xyz", "bookseller") == -1 -``` -*/ -@send -external indexOf: (t, t) => int = "indexOf" -let indexOf = (arg1, obj) => indexOf(obj, arg1) - -/** -`indexOfFrom(searchValue, start, str)` returns the position at which -`searchValue` was found within `str` starting at character position `start`, or -\-1 if `searchValue` is not found in that portion of `str`. The return value is -relative to the beginning of the string, no matter where the search started -from. - -See [`String.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf) -on MDN. - -## Examples - -```rescript -Js.String.indexOfFrom("ok", 1, "bookseller") == 2 -Js.String.indexOfFrom("sell", 2, "bookseller") == 4 -Js.String.indexOfFrom("sell", 5, "bookseller") == -1 -``` -*/ -@send -external indexOfFrom: (t, t, int) => int = "indexOf" -let indexOfFrom = (arg1, arg2, obj) => indexOfFrom(obj, arg1, arg2) - -/** -`lastIndexOf(searchValue, str)` returns the position of the last occurrence of -`searchValue` within `str`, searching backwards from the end of the string. -Returns -1 if `searchValue` is not in `str`. The return value is always -relative to the beginning of the string. - -See [`String.lastIndexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf) -on MDN. - -## Examples - -```rescript -Js.String.lastIndexOf("ok", "bookseller") == 2 -Js.String.lastIndexOf("ee", "beekeeper") == 4 -Js.String.lastIndexOf("xyz", "abcdefg") == -1 -``` -*/ -@send -external lastIndexOf: (t, t) => int = "lastIndexOf" -let lastIndexOf = (arg1, obj) => lastIndexOf(obj, arg1) - -/** -`lastIndexOfFrom(searchValue, start, str)` returns the position of the last -occurrence of `searchValue` within `str`, searching backwards from the given -start position. Returns -1 if `searchValue` is not in `str`. The return value -is always relative to the beginning of the string. - -See [`String.lastIndexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf) -on MDN. - -## Examples - -```rescript -Js.String.lastIndexOfFrom("ok", 6, "bookseller") == 2 -Js.String.lastIndexOfFrom("ee", 8, "beekeeper") == 4 -Js.String.lastIndexOfFrom("ee", 3, "beekeeper") == 1 -Js.String.lastIndexOfFrom("xyz", 4, "abcdefg") == -1 -``` -*/ -@send -external lastIndexOfFrom: (t, t, int) => int = "lastIndexOf" -let lastIndexOfFrom = (arg1, arg2, obj) => lastIndexOfFrom(obj, arg1, arg2) - -/* extended by ECMA-402 */ - -/** -`localeCompare(comparison, reference)` returns -- a negative value if reference comes before comparison in sort order -- zero if reference and comparison have the same sort order -- a positive value if reference comes after comparison in sort order - -See [`String.localeCompare`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare) on MDN. - -## Examples - -```rescript -Js.String.localeCompare("ant", "zebra") > 0.0 -Js.String.localeCompare("zebra", "ant") < 0.0 -Js.String.localeCompare("cat", "cat") == 0.0 -Js.String.localeCompare("cat", "CAT") > 0.0 -``` -*/ -@send -external localeCompare: (t, t) => float = "localeCompare" -let localeCompare = (arg1, obj) => localeCompare(obj, arg1) - -/** -`match(regexp, str)` matches a `string` against the given `regexp`. If there is -no match, it returns `None`. For regular expressions without the g modifier, if -there is a match, the return value is `Some(array)` where the array contains: -- The entire matched string -- Any capture groups if the regexp had parentheses - -For regular expressions with the g modifier, a matched expression returns -`Some(array)` with all the matched substrings and no capture groups. - -See [`String.match`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match) -on MDN. - -## Examples - -```rescript -Js.String.match_(/b[aeiou]t/, "The better bats") == Some(["bet"]) -Js.String.match_(/b[aeiou]t/g, "The better bats") == Some(["bet", "bat"]) -Js.String.match_(/(\d+)-(\d+)-(\d+)/, "Today is 2018-04-05.") == - Some(["2018-04-05", "2018", "04", "05"]) -Js.String.match_(/b[aeiou]g/, "The large container.") == None -``` -*/ -@send @return(null_to_opt) -external match_: (t, Js_re.t) => option>> = "match" -let match_ = (arg1, obj) => match_(obj, arg1) - -/** -`normalize(str)` returns the normalized Unicode string using Normalization Form -Canonical (NFC) Composition. Consider the character ã, which can be represented -as the single codepoint \u00e3 or the combination of a lower case letter A -\u0061 and a combining tilde \u0303. Normalization ensures that both can be -stored in an equivalent binary representation. - -See [`String.normalize`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize) -on MDN. - -See also [Unicode technical report #15](https://unicode.org/reports/tr15/) for -details. -*/ -@deprecated({ - reason: "Use `String.normalize` instead.", - migrate: String.normalize(), -}) -@send -external normalize: t => t = "normalize" - -/** -ES2015: `normalize(form, str)` returns the normalized Unicode string using the specified form of normalization, which may be one of: -- "NFC" — Normalization Form Canonical Composition. -- "NFD" — Normalization Form Canonical Decomposition. -- "NFKC" — Normalization Form Compatibility Composition. -- "NFKD" — Normalization Form Compatibility Decomposition. - -See [`String.normalize`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize) on MDN. - -See also [Unicode technical report #15](https://unicode.org/reports/tr15/) for details. -*/ -@send -external normalizeByForm: (t, t) => t = "normalize" -let normalizeByForm = (arg1, obj) => normalizeByForm(obj, arg1) - -/** -`repeat(n, str)` returns a `string` that consists of `n` repetitions of `str`. -Throws `RangeError` if `n` is negative. - -See [`String.repeat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat) -on MDN. - -## Examples - -```rescript -Js.String.repeat(3, "ha") == "hahaha" -Js.String.repeat(0, "empty") == "" -``` -*/ -@send -external repeat: (t, int) => t = "repeat" -let repeat = (arg1, obj) => repeat(obj, arg1) - -/** -ES2015: `replace(substr, newSubstr, str)` returns a new `string` which is -identical to `str` except with the first matching instance of `substr` replaced -by `newSubstr`. `substr` is treated as a verbatim string to match, not a -regular expression. - -See [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) -on MDN. - -## Examples - -```rescript -Js.String.replace("old", "new", "old string") == "new string" -Js.String.replace("the", "this", "the cat and the dog") == "this cat and the dog" -``` -*/ -@send -external replace: (t, t, t) => t = "replace" -let replace = (arg1, arg2, obj) => replace(obj, arg1, arg2) - -/** -`replaceByRe(regex, replacement, str)` returns a new `string` where occurrences -matching regex have been replaced by `replacement`. - -See [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) -on MDN. - -## Examples - -```rescript -Js.String.replaceByRe(/[aeiou]/g, "x", "vowels be gone") == "vxwxls bx gxnx" -Js.String.replaceByRe(/(\w+) (\w+)/, "$2, $1", "Juan Fulano") == "Fulano, Juan" -``` -*/ -@send -external replaceByRe: (t, Js_re.t, t) => t = "replace" -let replaceByRe = (arg1, arg2, obj) => replaceByRe(obj, arg1, arg2) - -/** -Returns a new `string` with some or all matches of a pattern with no capturing -parentheses replaced by the value returned from the given function. The -function receives as its parameters the matched string, the offset at which the -match begins, and the whole string being matched. - -See [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) -on MDN. - -## Examples - -```rescript -let str = "beautiful vowels" -let re = /[aeiou]/g -let matchFn = (matchPart, _offset, _wholeString) => Js.String.toUpperCase(matchPart) - -Js.String.unsafeReplaceBy0(re, matchFn, str) == "bEAUtIfUl vOwEls" -``` -*/ -@send -external unsafeReplaceBy0: (t, Js_re.t, (t, int, t) => t) => t = "replace" -let unsafeReplaceBy0 = (arg1, arg2, obj) => unsafeReplaceBy0(obj, arg1, arg2) - -/** -Returns a new `string` with some or all matches of a pattern with one set of -capturing parentheses replaced by the value returned from the given function. -The function receives as its parameters the matched string, the captured -string, the offset at which the match begins, and the whole string being -matched. - -See [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) -on MDN. - -## Examples - -```rescript -let str = "Jony is 40" -let re = /(Jony is )\d+/g -let matchFn = (_match, part1, _offset, _wholeString) => { - part1 ++ "41" -} - -Js.String.unsafeReplaceBy1(re, matchFn, str) == "Jony is 41" -``` -*/ -@send -external unsafeReplaceBy1: (t, Js_re.t, (t, t, int, t) => t) => t = "replace" -let unsafeReplaceBy1 = (arg1, arg2, obj) => unsafeReplaceBy1(obj, arg1, arg2) - -/** -Returns a new `string` with some or all matches of a pattern with two sets of -capturing parentheses replaced by the value returned from the given function. -The function receives as its parameters the matched string, the captured -strings, the offset at which the match begins, and the whole string being -matched. - -See [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) -on MDN. - -## Examples - -```rescript -let str = "7 times 6" -let re = /(\d+) times (\d+)/ -let matchFn = (_match, p1, p2, _offset, _wholeString) => { - switch (Belt.Int.fromString(p1), Belt.Int.fromString(p2)) { - | (Some(x), Some(y)) => Belt.Int.toString(x * y) - | _ => "???" - } -} - -Js.String.unsafeReplaceBy2(re, matchFn, str) == "42" -``` -*/ -@send -external unsafeReplaceBy2: (t, Js_re.t, (t, t, t, int, t) => t) => t = "replace" -let unsafeReplaceBy2 = (arg1, arg2, obj) => unsafeReplaceBy2(obj, arg1, arg2) - -/** -Returns a new `string` with some or all matches of a pattern with three sets of -capturing parentheses replaced by the value returned from the given function. -The function receives as its parameters the matched string, the captured -strings, the offset at which the match begins, and the whole string being -matched. - -See [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) -on MDN. -*/ -@send -external unsafeReplaceBy3: (t, Js_re.t, (t, t, t, t, int, t) => t) => t = "replace" -let unsafeReplaceBy3 = (arg1, arg2, obj) => unsafeReplaceBy3(obj, arg1, arg2) - -/** -`search(regexp, str)` returns the starting position of the first match of -`regexp` in the given `str`, or -1 if there is no match. - -See [`String.search`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search) -on MDN. - -## Examples - -```rescript -Js.String.search(/\d+/, "testing 1 2 3") == 8 -Js.String.search(/\d+/, "no numbers") == -1 -``` -*/ -@send -external search: (t, Js_re.t) => int = "search" -let search = (arg1, obj) => search(obj, arg1) - -/** -`slice(from:n1, to_:n2, str)` returns the substring of `str` starting at -character `n1` up to but not including `n2`. -- If either `n1` or `n2` is negative, then it is evaluated as `length(str - n1)` or `length(str - n2)`. -- If `n2` is greater than the length of `str`, then it is treated as `length(str)`. -- If `n1` is greater than `n2`, slice returns the empty string. - -See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN. - -## Examples - -```rescript -Js.String.slice(~from=2, ~to_=5, "abcdefg") == "cde" -Js.String.slice(~from=2, ~to_=9, "abcdefg") == "cdefg" -Js.String.slice(~from=-4, ~to_=-2, "abcdefg") == "de" -Js.String.slice(~from=5, ~to_=1, "abcdefg") == "" -``` -*/ -@send -external slice: (t, ~from: int, ~to_: int) => t = "slice" -let slice = (~from, ~to_, obj) => slice(obj, ~from, ~to_) - -/** -`sliceToEnd(str, from:n)` returns the substring of `str` starting at character -`n` to the end of the string. -- If `n` is negative, then it is evaluated as `length(str - n)`. -- If `n` is greater than the length of `str`, then sliceToEnd returns the empty string. - -See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN. - -## Examples - -```rescript -Js.String.sliceToEnd(~from=4, "abcdefg") == "efg" -Js.String.sliceToEnd(~from=-2, "abcdefg") == "fg" -Js.String.sliceToEnd(~from=7, "abcdefg") == "" -``` -*/ -@send -external sliceToEnd: (t, ~from: int) => t = "slice" -let sliceToEnd = (~from, obj) => sliceToEnd(obj, ~from) - -/** -`split(delimiter, str)` splits the given `str` at every occurrence of -`delimiter` and returns an array of the resulting substrings. - -See [`String.split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split) -on MDN. - -## Examples - -```rescript -Js.String.split("-", "2018-01-02") == ["2018", "01", "02"] -Js.String.split(",", "a,b,,c") == ["a", "b", "", "c"] -Js.String.split("::", "good::bad as great::awful") == ["good", "bad as great", "awful"] -Js.String.split(";", "has-no-delimiter") == ["has-no-delimiter"] -``` -*/ -@send -external split: (t, t) => array = "split" -let split = (arg1, obj) => split(obj, arg1) - -/** -`splitAtMost(delimiter, ~limit:n, str)` splits the given `str` at every -occurrence of `delimiter` and returns an array of the first `n` resulting -substrings. If `n` is negative or greater than the number of substrings, the -array will contain all the substrings. - -See [`String.split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split) -on MDN. - -## Examples - -```rescript -Js.String.splitAtMost("/", ~limit=3, "ant/bee/cat/dog/elk") == ["ant", "bee", "cat"] -Js.String.splitAtMost("/", ~limit=0, "ant/bee/cat/dog/elk") == [] -Js.String.splitAtMost("/", ~limit=9, "ant/bee/cat/dog/elk") == ["ant", "bee", "cat", "dog", "elk"] -``` -*/ -@send -external splitAtMost: (t, t, ~limit: int) => array = "split" -let splitAtMost = (arg1, ~limit, obj) => splitAtMost(obj, ~limit, arg1) - -/** -`splitByRe(regex, str)` splits the given `str` at every occurrence of `regex` -and returns an array of the resulting substrings. - -See [`String.split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split) -on MDN. - -## Examples - -```rescript -Js.String.splitByRe(/\s*[,;]\s*TODO/, "art; bed , cog ;dad") == [ - Some("art"), - Some("bed"), - Some("cog"), - Some("dad"), - ] -``` -*/ -@send -external splitByRe: (t, Js_re.t) => array> = "split" -let splitByRe = (arg1, obj) => splitByRe(obj, arg1) - -/** -`splitByReAtMost(regex, ~limit:n, str)` splits the given `str` at every -occurrence of `regex` and returns an array of the first `n` resulting -substrings. If `n` is negative or greater than the number of substrings, the -array will contain all the substrings. - -See [`String.split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split) -on MDN. - -## Examples - -```rescript -Js.String.splitByReAtMost(/\s*[,;]\s*TODO/, ~limit=3, "one: two: three: four") == [ - Some("one"), - Some("two"), - Some("three"), - ] - -Js.String.splitByReAtMost(/\s*[,;]\s*TODO/, ~limit=0, "one: two: three: four") == [] - -Js.String.splitByReAtMost(/\s*[,;]\s*TODO/, ~limit=8, "one: two: three: four") == [ - Some("one"), - Some("two"), - Some("three"), - Some("four"), - ] -``` -*/ -@send -external splitByReAtMost: (t, Js_re.t, ~limit: int) => array> = "split" -let splitByReAtMost = (arg1, ~limit, obj) => splitByReAtMost(obj, arg1, ~limit) - -/** -ES2015: `startsWith(substr, str)` returns `true` if the `str` starts with -`substr`, `false` otherwise. - -See [`String.startsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith) -on MDN. - -## Examples - -```rescript -Js.String.startsWith("Re", "ReScript") == true -Js.String.startsWith("", "ReScript") == true -Js.String.startsWith("Re", "JavaScript") == false -``` -*/ -@send -external startsWith: (t, t) => bool = "startsWith" -let startsWith = (arg1, obj) => startsWith(obj, arg1) - -/** -ES2015: `startsWithFrom(substr, n, str)` returns `true` if the `str` starts -with `substr` starting at position `n`, false otherwise. If `n` is negative, -the search starts at the beginning of `str`. - -See [`String.startsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith) -on MDN. - -## Examples - -```rescript -Js.String.startsWithFrom("Scri", 2, "ReScript") == true -Js.String.startsWithFrom("", 2, "ReScript") == true -Js.String.startsWithFrom("Scri", 2, "JavaScript") == false -``` -*/ -@send -external startsWithFrom: (t, t, int) => bool = "startsWith" -let startsWithFrom = (arg1, arg2, obj) => startsWithFrom(obj, arg1, arg2) - -/** -`substr(~from:n, str)` returns the substring of `str` from position `n` to the -end of the string. -- If `n` is less than zero, the starting position is the length of `str - n`. -- If `n` is greater than or equal to the length of `str`, returns the empty string. - -JavaScript’s `String.substr()` is a legacy function. When possible, use -`substring()` instead. - -See [`String.substr`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) -on MDN. - -## Examples - -```rescript -Js.String.substr(~from=3, "abcdefghij") == "defghij" -Js.String.substr(~from=-3, "abcdefghij") == "hij" -Js.String.substr(~from=12, "abcdefghij") == "" -``` -*/ -@send -external substr: (t, ~from: int) => t = "substr" -let substr = (~from, obj) => substr(obj, ~from) - -/** -`substrAtMost(~from: pos, ~length: n, str)` returns the substring of `str` of -length `n` starting at position `pos`. -- If `pos` is less than zero, the starting position is the length of `str - pos`. -- If `pos` is greater than or equal to the length of `str`, returns the empty string. -- If `n` is less than or equal to zero, returns the empty string. - -JavaScript’s `String.substr()` is a legacy function. When possible, use -`substring()` instead. - -See [`String.substr`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) -on MDN. - -## Examples - -```rescript -Js.String.substrAtMost(~from=3, ~length=4, "abcdefghij") == "defg" -Js.String.substrAtMost(~from=-3, ~length=4, "abcdefghij") == "hij" -Js.String.substrAtMost(~from=12, ~length=2, "abcdefghij") == "" -``` -*/ -@send -external substrAtMost: (t, ~from: int, ~length: int) => t = "substr" -let substrAtMost = (~from, ~length, obj) => substrAtMost(obj, ~from, ~length) - -/** -`substring(~from: start, ~to_: finish, str)` returns characters `start` up to -but not including finish from `str`. -- If `start` is less than zero, it is treated as zero. -- If `finish` is zero or negative, the empty string is returned. -- If `start` is greater than `finish`, the `start` and `finish` points are swapped. - -See [`String.substring`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring) on MDN. - -## Examples - -```rescript -Js.String.substring(~from=3, ~to_=6, "playground") == "ygr" -Js.String.substring(~from=6, ~to_=3, "playground") == "ygr" -Js.String.substring(~from=4, ~to_=12, "playground") == "ground" -``` -*/ -@send -external substring: (t, ~from: int, ~to_: int) => t = "substring" -let substring = (~from, ~to_, obj) => substring(obj, ~from, ~to_) - -/** -`substringToEnd(~from: start, str)` returns the substring of `str` from -position `start` to the end. -- If `start` is less than or equal to zero, the entire string is returned. -- If `start` is greater than or equal to the length of `str`, the empty string is returned. - -See [`String.substring`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring) on MDN. - -## Examples - -```rescript -Js.String.substringToEnd(~from=4, "playground") == "ground" -Js.String.substringToEnd(~from=-3, "playground") == "playground" -Js.String.substringToEnd(~from=12, "playground") == "" -``` -*/ -@send -external substringToEnd: (t, ~from: int) => t = "substring" -let substringToEnd = (~from, obj) => substringToEnd(obj, ~from) - -/** -`toLowerCase(str)` converts `str` to lower case using the locale-insensitive -case mappings in the Unicode Character Database. Notice that the conversion can -give different results depending upon context, for example with the Greek -letter sigma, which has two different lower case forms; one when it is the last -character in a string and another when it is not. - -See [`String.toLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase) -on MDN. - -## Examples - -```rescript -Js.String.toLowerCase("ABC") == "abc" -Js.String.toLowerCase(`ΣΠ`) == `σπ` -Js.String.toLowerCase(`ΠΣ`) == `πς` -``` -*/ -@deprecated({ - reason: "Use `String.toLowerCase` instead.", - migrate: String.toLowerCase(), -}) -@send -external toLowerCase: t => t = "toLowerCase" - -/** -`toLocaleLowerCase(str)` converts `str` to lower case using the current locale. - -See [`String.toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase) -on MDN. -*/ -@deprecated({ - reason: "Use `String.toLocaleLowerCase` instead.", - migrate: String.toLocaleLowerCase(), -}) -@send -external toLocaleLowerCase: t => t = "toLocaleLowerCase" - -/** -`toUpperCase(str)` converts `str` to upper case using the locale-insensitive -case mappings in the Unicode Character Database. Notice that the conversion can -expand the number of letters in the result; for example the German ß -capitalizes to two Ses in a row. - -See [`String.toUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase) -on MDN. - -## Examples - -```rescript -Js.String.toUpperCase("abc") == "ABC" -Js.String.toUpperCase(`Straße`) == `STRASSE` -Js.String.toUpperCase(`πς`) == `ΠΣ` -``` -*/ -@deprecated({ - reason: "Use `String.toUpperCase` instead.", - migrate: String.toUpperCase(), -}) -@send -external toUpperCase: t => t = "toUpperCase" - -/** -`toLocaleUpperCase(str)` converts `str` to upper case using the current locale. - -See [`String.to:LocaleUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase) -on MDN. -*/ -@deprecated({ - reason: "Use `String.toLocaleUpperCase` instead.", - migrate: String.toLocaleUpperCase(), -}) -@send -external toLocaleUpperCase: t => t = "toLocaleUpperCase" - -/** -`trim(str)` returns a string that is `str` with whitespace stripped from both -ends. Internal whitespace is not removed. - -See [`String.trim`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim) -on MDN. - -## Examples - -```rescript -Js.String.trim(" abc def ") == "abc def" -Js.String.trim("\n\r\t abc def \n\n\t\r ") == "abc def" -``` -*/ -@deprecated({ - reason: "Use `String.trim` instead.", - migrate: String.trim(), -}) -@send -external trim: t => t = "trim" - -/* HTML wrappers */ - -/** -`anchor(anchorName, anchorText)` creates a string with an HTML `` element -with name attribute of `anchorName` and `anchorText` as its content. Please do -not use this method, as it has been removed from the relevant web standards. - -See [`String.anchor`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/anchor) -on MDN. - -## Examples - -```rescript -Js.String.anchor("page1", "Page One") == "Page One" -``` -*/ -@send -external anchor: (t, t) => t = "anchor" -let anchor = (arg1, obj) => anchor(obj, arg1) - -/** -ES2015: `link(urlText, linkText)` creates a string with an HTML `` element -with href attribute of `urlText` and `linkText` as its content. Please do not -use this method, as it has been removed from the relevant web standards. - -See [`String.link`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/link) -on MDN. - -## Examples - -```rescript -Js.String.link("page2.html", "Go to page two") == "Go to page two" -``` -*/ -@send -external link: (t, t) => t = "link" -let link = (arg1, obj) => link(obj, arg1) - -/** -Casts its argument to an `array_like` entity that can be processed by functions -such as `Js.Array2.fromMap()` - -## Examples - -```rescript -let s = "abcde" -let arr = Js.Array2.fromMap(Js.String.castToArrayLike(s), x => x) -arr == ["a", "b", "c", "d", "e"] -``` -*/ -@deprecated( - "This has been deprecated and will be removed in v13. Use functions from the `String` module instead." -) -external castToArrayLike: t => Js_array2.array_like = "%identity" diff --git a/packages/@rescript/runtime/Js_string2.res b/packages/@rescript/runtime/Js_string2.res deleted file mode 100644 index 9b97ce91d90..00000000000 --- a/packages/@rescript/runtime/Js_string2.res +++ /dev/null @@ -1,1185 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** Provide bindings to JS string. Optimized for pipe-first. */ - -@deprecated({ - reason: "Use `string` directly instead.", - migrate: %replace.type(: string), -}) -type t = string - -/** -`make(value)` converts the given value to a `string`. - -## Examples - -```rescript -Js.String2.make(3.5) == "3.5" -Js.String2.make([1, 2, 3]) == "1,2,3" -``` -*/ -@deprecated({ - reason: "Use `String.make` instead", - migrate: String.make(), -}) -@val -external make: 'a => t = "String" - -/** -`fromCharCode(n)` creates a `string` containing the character corresponding to -that number; `n` ranges from 0 to 65535.If out of range, the lower 16 bits of -the value are used. Thus, `fromCharCode(0x1F63A)` gives the same result as -`fromCharCode(0xF63A)`. - -See [`String.fromCharCode`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode) -on MDN. - -## Examples - -```rescript -Js.String2.fromCharCode(65) == "A" -Js.String2.fromCharCode(0x3c8) == `ψ` -Js.String2.fromCharCode(0xd55c) == `한` -Js.String2.fromCharCode(-64568) == `ψ` -``` -*/ -@deprecated({ - reason: "Use `String.fromCharCode` instead", - migrate: String.fromCharCode(), -}) -@val -external fromCharCode: int => t = "String.fromCharCode" - -/** -`fromCharCodeMany([n1, n2, n3])` creates a `string` from the characters -corresponding to the given numbers, using the same rules as `fromCharCode`. - -See [`String.fromCharCode`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode) -on MDN. -*/ -@deprecated({ - reason: "Use `String.fromCharCodeMany` instead", - migrate: String.fromCharCodeMany(), -}) -@val -@variadic -external fromCharCodeMany: array => t = "String.fromCharCode" - -/** -`fromCodePoint(n)` creates a `string` containing the character corresponding to -that numeric code point. If the number is not a valid code point, it throws -`RangeError`. Thus, `fromCodePoint(0x1F63A)` will produce a correct value, -unlike `fromCharCode(0x1F63A)`, and `fromCodePoint(-5)` will throw a -`RangeError`. - -See [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint) -on MDN. - -## Examples - -```rescript -Js.String2.fromCodePoint(65) == "A" -Js.String2.fromCodePoint(0x3c8) == `ψ` -Js.String2.fromCodePoint(0xd55c) == `한` -Js.String2.fromCodePoint(0x1f63a) == `😺` -``` -*/ -@deprecated({ - reason: "Use `String.fromCodePoint` instead", - migrate: String.fromCodePoint(), -}) -@val -external fromCodePoint: int => t = "String.fromCodePoint" - -/** -`fromCodePointMany([n1, n2, n3])` creates a `string` from the characters -corresponding to the given code point numbers, using the same rules as -`fromCodePoint`. - -See [`String.fromCodePoint`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCodePoint) -on MDN. - -## Examples - -```rescript -Js.String2.fromCodePointMany([0xd55c, 0xae00, 0x1f63a]) == `한글😺` -``` -*/ -@deprecated({ - reason: "Use `String.fromCodePointMany` instead", - migrate: String.fromCodePointMany(), -}) -@val -@variadic -external fromCodePointMany: array => t = "String.fromCodePoint" - -/* String.raw: ES2015, meant to be used with template strings, not directly */ - -/** -`length(s)` returns the length of the given `string`. - -See [`String.length`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length) -on MDN. - -## Examples - -```rescript -Js.String2.length("abcd") == 4 -``` -*/ -@deprecated({ - reason: "Use `String.length` instead", - migrate: String.length(), -}) -@get -external length: t => int = "length" - -/** -`get(s, n)` returns as a `string` the character at the given index number. If -`n` is out of range, this function returns `undefined`,so at some point this -function may be modified to return `option`. - -## Examples - -```rescript -Js.String2.get("Reason", 0) == "R" -Js.String2.get("Reason", 4) == "o" -Js.String2.get(`Rẽasöń`, 5) == `Å„` -``` -*/ -@deprecated({ - reason: "Use `String.getUnsafe` instead. Or use `String.get` for a safe version that returns an option.", - migrate: String.getUnsafe(), -}) -@get_index -external get: (t, int) => t = "" - -/** -`charAt(s, n)` gets the character at index `n` within string `s`. If `n` is -negative or greater than the length of `s`, it returns the empty string. If the -string contains characters outside the range \\u0000-\\uffff, it will return the -first 16-bit value at that position in the string. - -See [`String.charAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt) -on MDN. - -## Examples - -```rescript -Js.String2.charAt("Reason", 0) == "R" -Js.String2.charAt("Reason", 12) == "" -Js.String2.charAt(`Rẽasöń`, 5) == `Å„` -``` -*/ -@deprecated({ - reason: "Use `String.charAt` instead", - migrate: String.charAt(), -}) -@send -external charAt: (t, int) => t = "charAt" - -/** -`charCodeAt(s, n)` returns the character code at position `n` in string `s`; -the result is in the range 0-65535, unlke `codePointAt`, so it will not work -correctly for characters with code points greater than or equal to 0x10000. The -return type is `float` because this function returns NaN if `n` is less than -zero or greater than the length of the string. - -See [`String.charCodeAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt) -on MDN. - -## Examples - -```rescript -Js.String2.charCodeAt(`😺`, 0) == 0xd83d->Belt.Int.toFloat -Js.String2.codePointAt(`😺`, 0) == Some(0x1f63a) -``` -*/ -@deprecated({ - reason: "Use `String.charCodeAt` instead", - migrate: String.charCodeAt(), -}) -@send -external charCodeAt: (t, int) => float = "charCodeAt" - -/** -`codePointAt(s, n)` returns the code point at position `n` within string `s` as -a `Some(value)`. The return value handles code points greater than or equal to -0x10000. If there is no code point at the given position, the function returns -`None`. - -See [`String.codePointAt`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt) -on MDN. - -## Examples - -```rescript -Js.String2.codePointAt(`¿😺?`, 1) == Some(0x1f63a) -Js.String2.codePointAt("abc", 5) == None -``` -*/ -@deprecated({ - reason: "Use `String.codePointAt` instead", - migrate: String.codePointAt(), -}) -@send -external codePointAt: (t, int) => option = "codePointAt" - -/** -`concat(original, append)` returns a new `string` with `append` added after -`original`. - -See [`String.concat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat) -on MDN. - -## Examples - -```rescript -Js.String2.concat("cow", "bell") == "cowbell" -``` -*/ -@deprecated({ - reason: "Use `String.concat` instead", - migrate: String.concat(), -}) -@send -external concat: (t, t) => t = "concat" - -/** -`concatMany(original, arr)` returns a new `string` consisting of each item of an -array of strings added to the `original` string. - -See [`String.concat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat) -on MDN. - -## Examples - -```rescript -Js.String2.concatMany("1st", ["2nd", "3rd", "4th"]) == "1st2nd3rd4th" -``` -*/ -@deprecated({ - reason: "Use `String.concatMany` instead", - migrate: String.concatMany(), -}) -@send -@variadic -external concatMany: (t, array) => t = "concat" - -/** -ES2015: `endsWith(str, substr)` returns `true` if the `str` ends with `substr`, -`false` otherwise. - -See [`String.endsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith) -on MDN. - -## Examples - -```rescript -Js.String2.endsWith("ReScript", "Script") == true -Js.String2.endsWith("C++", "Script") == false -``` -*/ -@deprecated({ - reason: "Use `String.endsWith` instead", - migrate: String.endsWith(), -}) -@send -external endsWith: (t, t) => bool = "endsWith" - -/** -`endsWithFrom(str, ending, len)` returns `true` if the first len characters of -`str` end with `ending`, `false` otherwise. If `len` is greater than or equal -to the length of `str`, then it works like `endsWith`. (Honestly, this should -have been named endsWithAt, but oh well). - -See [`String.endsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith) -on MDN. - -## Examples - -```rescript -Js.String2.endsWithFrom("abcd", "cd", 4) == true -Js.String2.endsWithFrom("abcde", "cd", 3) == false -Js.String2.endsWithFrom("abcde", "cde", 99) == true -Js.String2.endsWithFrom("example.dat", "ple", 7) == true -``` -*/ -@deprecated({ - reason: "Use `String.endsWithFrom` instead", - migrate: String.endsWithFrom(), -}) -@send -external endsWithFrom: (t, t, int) => bool = "endsWith" - -/** -ES2015: `includes(str, searchValue)` returns `true` if `searchValue` is found -anywhere within `str`, false otherwise. - -See [`String.includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) -on MDN. - -## Examples - -```rescript -Js.String2.includes("programmer", "gram") == true -Js.String2.includes("programmer", "er") == true -Js.String2.includes("programmer", "pro") == true -Js.String2.includes("programmer.dat", "xyz") == false -``` -*/ -@deprecated({ - reason: "Use `String.includes` instead", - migrate: String.includes(), -}) -@send -external includes: (t, t) => bool = "includes" - -/** -ES2015: `includes(str, searchValue start)` returns `true` if `searchValue` is -found anywhere within `str` starting at character number `start` (where 0 is -the first character), `false` otherwise. - -See [`String.includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes) -on MDN. - -## Examples - -```rescript -Js.String2.includesFrom("programmer", "gram", 1) == true -Js.String2.includesFrom("programmer", "gram", 4) == false -Js.String2.includesFrom(`대한민국`, `한`, 1) == true -``` -*/ -@deprecated({ - reason: "Use `String.includesFrom` instead", - migrate: String.includesFrom(), -}) -@send -external includesFrom: (t, t, int) => bool = "includes" - -/** -ES2015: `indexOf(str, searchValue)` returns the position at which `searchValue` -was first found within `str`, or -1 if `searchValue` is not in `str`. - -See [`String.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf) -on MDN. - -## Examples - -```rescript -Js.String2.indexOf("bookseller", "ok") == 2 -Js.String2.indexOf("bookseller", "sell") == 4 -Js.String2.indexOf("beekeeper", "ee") == 1 -Js.String2.indexOf("bookseller", "xyz") == -1 -``` -*/ -@deprecated({ - reason: "Use `String.indexOf` instead", - migrate: String.indexOf(), -}) -@send -external indexOf: (t, t) => int = "indexOf" - -/** -`indexOfFrom(str, searchValue, start)` returns the position at which -`searchValue` was found within `str` starting at character position `start`, or -\-1 if `searchValue` is not found in that portion of `str`. The return value is -relative to the beginning of the string, no matter where the search started -from. - -See [`String.indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf) -on MDN. - -## Examples - -```rescript -Js.String2.indexOfFrom("bookseller", "ok", 1) == 2 -Js.String2.indexOfFrom("bookseller", "sell", 2) == 4 -Js.String2.indexOfFrom("bookseller", "sell", 5) == -1 -``` -*/ -@deprecated({ - reason: "Use `String.indexOfFrom` instead", - migrate: String.indexOfFrom(), -}) -@send -external indexOfFrom: (t, t, int) => int = "indexOf" - -/** -`lastIndexOf(str, searchValue)` returns the position of the last occurrence of -`searchValue` within `str`, searching backwards from the end of the string. -Returns -1 if `searchValue` is not in `str`. The return value is always -relative to the beginning of the string. - -See [`String.lastIndexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf) -on MDN. - -## Examples - -```rescript -Js.String2.lastIndexOf("bookseller", "ok") == 2 -Js.String2.lastIndexOf("beekeeper", "ee") == 4 -Js.String2.lastIndexOf("abcdefg", "xyz") == -1 -``` -*/ -@deprecated({ - reason: "Use `String.lastIndexOf` instead", - migrate: String.lastIndexOf(), -}) -@send -external lastIndexOf: (t, t) => int = "lastIndexOf" - -/** -`lastIndexOfFrom(str, searchValue, start)` returns the position of the last -occurrence of `searchValue` within `str`, searching backwards from the given -start position. Returns -1 if `searchValue` is not in `str`. The return value -is always relative to the beginning of the string. - -See [`String.lastIndexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf) -on MDN. - -## Examples - -```rescript -Js.String2.lastIndexOfFrom("bookseller", "ok", 6) == 2 -Js.String2.lastIndexOfFrom("beekeeper", "ee", 8) == 4 -Js.String2.lastIndexOfFrom("beekeeper", "ee", 3) == 1 -Js.String2.lastIndexOfFrom("abcdefg", "xyz", 4) == -1 -``` -*/ -@deprecated({ - reason: "Use `String.lastIndexOfFrom` instead", - migrate: String.lastIndexOfFrom(), -}) -@send -external lastIndexOfFrom: (t, t, int) => int = "lastIndexOf" - -/* extended by ECMA-402 */ - -/** -`localeCompare(reference, comparison)` returns -- a negative value if reference comes before comparison in sort order -- zero if reference and comparison have the same sort order -- a positive value if reference comes after comparison in sort order - -See [`String.localeCompare`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare) on MDN. - -## Examples - -```rescript -Js.String2.localeCompare("zebra", "ant") > 0.0 -Js.String2.localeCompare("ant", "zebra") < 0.0 -Js.String2.localeCompare("cat", "cat") == 0.0 -Js.String2.localeCompare("CAT", "cat") > 0.0 -``` -*/ -@deprecated({ - reason: "Use `String.localeCompare` instead", - migrate: String.localeCompare(), -}) -@send -external localeCompare: (t, t) => float = "localeCompare" - -/** -`match(str, regexp)` matches a `string` against the given `regexp`. If there is -no match, it returns `None`. For regular expressions without the g modifier, if -there is a match, the return value is `Some(array)` where the array contains: -- The entire matched string -- Any capture groups if the regexp had parentheses - For regular expressions with the g modifier, a matched expression returns - `Some(array)` with all the matched substrings and no capture groups. - -See [`String.match`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match) -on MDN. - -## Examples - -```rescript -Js.String2.match_("The better bats", /b[aeiou]t/) == Some(["bet"]) -Js.String2.match_("The better bats", /b[aeiou]t/g) == Some(["bet", "bat"]) -Js.String2.match_("Today is 2018-04-05.", /(\d+)-(\d+)-(\d+)/) == - Some(["2018-04-05", "2018", "04", "05"]) -Js.String2.match_("The large container.", /b[aeiou]g/) == None -``` -*/ -@deprecated({ - reason: "Use `String.match` instead", - migrate: String.match(), -}) -@send -@return({null_to_opt: null_to_opt}) -external match_: (t, Js_re.t) => option>> = "match" - -/** -`normalize(str)` returns the normalized Unicode string using Normalization Form -Canonical (NFC) Composition. Consider the character ã, which can be represented -as the single codepoint \u00e3 or the combination of a lower case letter A -\u0061 and a combining tilde \u0303. Normalization ensures that both can be -stored in an equivalent binary representation. - -See [`String.normalize`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize) -on MDN. See also [Unicode technical report -#15](https://unicode.org/reports/tr15/) for details. -*/ -@deprecated({ - reason: "Use `String.normalize` instead", - migrate: String.normalize(), -}) -@send -external normalize: t => t = "normalize" - -/** -ES2015: `normalize(str, form)` returns the normalized Unicode string using the -specified form of normalization, which may be one of: -- "NFC" — Normalization Form Canonical Composition. -- "NFD" — Normalization Form Canonical Decomposition. -- "NFKC" — Normalization Form Compatibility Composition. -- "NFKD" — Normalization Form Compatibility Decomposition. - -See [`String.normalize`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize) on MDN. -See also [Unicode technical report #15](https://unicode.org/reports/tr15/) for details. -*/ -@deprecated({ - reason: "Use `String.normalizeByForm` instead", - migrate: String.normalizeByForm(), -}) -@send -external normalizeByForm: (t, t) => t = "normalize" - -/** -`repeat(str, n)` returns a `string` that consists of `n` repetitions of `str`. -Throws `RangeError` if `n` is negative. - -See [`String.repeat`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat) -on MDN. - -## Examples - -```rescript -Js.String2.repeat("ha", 3) == "hahaha" -Js.String2.repeat("empty", 0) == "" -``` -*/ -@deprecated({ - reason: "Use `String.repeat` instead", - migrate: String.repeat(), -}) -@send -external repeat: (t, int) => t = "repeat" - -/** -ES2015: `replace(str, substr, newSubstr)` returns a new `string` which is -identical to `str` except with the first matching instance of `substr` replaced -by `newSubstr`. `substr` is treated as a verbatim string to match, not a -regular expression. - -See [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) -on MDN. - -## Examples - -```rescript -Js.String2.replace("old string", "old", "new") == "new string" -Js.String2.replace("the cat and the dog", "the", "this") == "this cat and the dog" -``` -*/ -@deprecated({ - reason: "Use `String.replace` instead", - migrate: String.replace(), -}) -@send -external replace: (t, t, t) => t = "replace" - -/** -`replaceByRe(str, regex, replacement)` returns a new `string` where occurrences -matching regex have been replaced by `replacement`. - -See [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) -on MDN. - -## Examples - -```rescript -Js.String2.replaceByRe("vowels be gone", /[aeiou]/g, "x") == "vxwxls bx gxnx" -Js.String2.replaceByRe("Juan Fulano", /(\w+) (\w+)/, "$2, $1") == "Fulano, Juan" -``` -*/ -@deprecated({ - reason: "Use `String.replaceRegExp` instead", - migrate: String.replaceRegExp(), -}) -@send -external replaceByRe: (t, Js_re.t, t) => t = "replace" - -/** -Returns a new `string` with some or all matches of a pattern with no capturing -parentheses replaced by the value returned from the given function. The -function receives as its parameters the matched string, the offset at which the -match begins, and the whole string being matched. - -See [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) -on MDN. - -## Examples - -```rescript -let str = "beautiful vowels" -let re = /[aeiou]/g -let matchFn = (matchPart, _offset, _wholeString) => Js.String2.toUpperCase(matchPart) - -Js.String2.unsafeReplaceBy0(str, re, matchFn) == "bEAUtIfUl vOwEls" -``` -*/ -@deprecated({ - reason: "Use `String.replaceRegExpBy0Unsafe` instead", - migrate: String.replaceRegExpBy0Unsafe(), -}) -@send -external unsafeReplaceBy0: (t, Js_re.t, (t, int, t) => t) => t = "replace" - -/** -Returns a new `string` with some or all matches of a pattern with one set of -capturing parentheses replaced by the value returned from the given function. -The function receives as its parameters the matched string, the captured -string, the offset at which the match begins, and the whole string being -matched. - -See [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) -on MDN. - -## Examples - -```rescript -let str = "Jony is 40" -let re = /(Jony is )\d+/g -let matchFn = (_match, part1, _offset, _wholeString) => { - part1 ++ "41" -} - -Js.String2.unsafeReplaceBy1(str, re, matchFn) == "Jony is 41" -``` -*/ -@deprecated({ - reason: "Use `String.replaceRegExpBy1Unsafe` instead", - migrate: String.replaceRegExpBy1Unsafe(), -}) -@send -external unsafeReplaceBy1: (t, Js_re.t, (t, t, int, t) => t) => t = "replace" - -/** -Returns a new `string` with some or all matches of a pattern with two sets of -capturing parentheses replaced by the value returned from the given function. -The function receives as its parameters the matched string, the captured -strings, the offset at which the match begins, and the whole string being -matched. - -See [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) -on MDN. - -## Examples - -```rescript -let str = "7 times 6" -let re = /(\d+) times (\d+)/ -let matchFn = (_match, p1, p2, _offset, _wholeString) => { - switch (Belt.Int.fromString(p1), Belt.Int.fromString(p2)) { - | (Some(x), Some(y)) => Belt.Int.toString(x * y) - | _ => "???" - } -} - -Js.String2.unsafeReplaceBy2(str, re, matchFn) == "42" -``` -*/ -@deprecated({ - reason: "Use `String.replaceRegExpBy2Unsafe` instead", - migrate: String.replaceRegExpBy2Unsafe(), -}) -@send -external unsafeReplaceBy2: (t, Js_re.t, (t, t, t, int, t) => t) => t = "replace" - -/** -Returns a new `string` with some or all matches of a pattern with three sets of -capturing parentheses replaced by the value returned from the given function. -The function receives as its parameters the matched string, the captured -strings, the offset at which the match begins, and the whole string being -matched. - -See [`String.replace`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) -on MDN. -*/ -@deprecated({ - reason: "Use `String.replaceRegExpBy3Unsafe` instead", - migrate: String.replaceRegExpBy3Unsafe(), -}) -@send -external unsafeReplaceBy3: (t, Js_re.t, (t, t, t, t, int, t) => t) => t = "replace" - -/** -`search(str, regexp)` returns the starting position of the first match of -`regexp` in the given `str`, or -1 if there is no match. - -See [`String.search`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search) -on MDN. - -## Examples - -```rescript -Js.String2.search("testing 1 2 3", /\d+/) == 8 -Js.String2.search("no numbers", /\d+/) == -1 -``` -*/ -@deprecated({ - reason: "Use `String.search` instead", - migrate: String.search(), -}) -@send -external search: (t, Js_re.t) => int = "search" - -/** -`slice(str, from:n1, to_:n2)` returns the substring of `str` starting at -character `n1` up to but not including `n2`. -- If either `n1` or `n2` is negative, then it is evaluated as `length(str - n1)` or `length(str - n2)`. -- If `n2` is greater than the length of `str`, then it is treated as `length(str)`. -- If `n1` is greater than `n2`, slice returns the empty string. - -See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN. - -## Examples - -```rescript -Js.String2.slice("abcdefg", ~from=2, ~to_=5) == "cde" -Js.String2.slice("abcdefg", ~from=2, ~to_=9) == "cdefg" -Js.String2.slice("abcdefg", ~from=-4, ~to_=-2) == "de" -Js.String2.slice("abcdefg", ~from=5, ~to_=1) == "" -``` -*/ -@deprecated({ - reason: "Use `String.slice` instead", - migrate: String.slice( - ~start=%insert.labelledArgument("from"), - ~end=%insert.labelledArgument("to_"), - ), -}) -@send -external slice: (t, ~from: int, ~to_: int) => t = "slice" - -/** -`sliceToEnd(str, from:n)` returns the substring of `str` starting at character -`n` to the end of the string. -- If `n` is negative, then it is evaluated as `length(str - n)`. -- If `n` is greater than the length of `str`, then sliceToEnd returns the empty string. - -See [`String.slice`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice) on MDN. - -## Examples - -```rescript -Js.String2.sliceToEnd("abcdefg", ~from=4) == "efg" -Js.String2.sliceToEnd("abcdefg", ~from=-2) == "fg" -Js.String2.sliceToEnd("abcdefg", ~from=7) == "" -``` -*/ -@deprecated({ - reason: "Use `String.slice` instead", - migrate: String.slice(~start=%insert.labelledArgument("from")), -}) -@send -external sliceToEnd: (t, ~from: int) => t = "slice" - -/** -`split(str, delimiter)` splits the given `str` at every occurrence of -`delimiter` and returns an array of the resulting substrings. - -See [`String.split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split) -on MDN. - -## Examples - -```rescript -Js.String2.split("2018-01-02", "-") == ["2018", "01", "02"] -Js.String2.split("a,b,,c", ",") == ["a", "b", "", "c"] -Js.String2.split("good::bad as great::awful", "::") == ["good", "bad as great", "awful"] -Js.String2.split("has-no-delimiter", ";") == ["has-no-delimiter"] -``` -*/ -@deprecated({ - reason: "Use `String.split` instead", - migrate: String.split(), -}) -@send -external split: (t, t) => array = "split" - -/** -`splitAtMost delimiter ~limit: n str` splits the given `str` at every occurrence of `delimiter` and returns an array of the first `n` resulting substrings. If `n` is negative or greater than the number of substrings, the array will contain all the substrings. - -``` -splitAtMost "ant/bee/cat/dog/elk" "/" ~limit: 3 = [|"ant"; "bee"; "cat"|];; -splitAtMost "ant/bee/cat/dog/elk" "/" ~limit: 0 = [| |];; -splitAtMost "ant/bee/cat/dog/elk" "/" ~limit: 9 = [|"ant"; "bee"; "cat"; "dog"; "elk"|];; -``` -*/ -@deprecated({ - reason: "Use `String.splitAtMost` instead", - migrate: String.splitAtMost(), -}) -@send -external splitAtMost: (t, t, ~limit: int) => array = "split" - -/** -`splitByRe(str, regex)` splits the given `str` at every occurrence of `regex` -and returns an array of the resulting substrings. - -See [`String.split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split) -on MDN. - -## Examples - -```rescript -Js.String2.splitByRe("art; bed , cog ;dad", /\s*[,;]\s*TODO/) == [ - Some("art"), - Some("bed"), - Some("cog"), - Some("dad"), - ] -``` -*/ -@deprecated({ - reason: "Use `String.splitByRegExp` instead", - migrate: String.splitByRegExp(), -}) -@send -external splitByRe: (t, Js_re.t) => array> = "split" - -/** -`splitByReAtMost(str, regex, ~limit:n)` splits the given `str` at every -occurrence of `regex` and returns an array of the first `n` resulting -substrings. If `n` is negative or greater than the number of substrings, the -array will contain all the substrings. - -See [`String.split`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split) -on MDN. - -## Examples - -```rescript -Js.String2.splitByReAtMost("one: two: three: four", /\s*:\s*TODO/, ~limit=3) == [ - Some("one"), - Some("two"), - Some("three"), - ] - -Js.String2.splitByReAtMost("one: two: three: four", /\s*:\s*TODO/, ~limit=0) == [] - -Js.String2.splitByReAtMost("one: two: three: four", /\s*:\s*TODO/, ~limit=8) == [ - Some("one"), - Some("two"), - Some("three"), - Some("four"), - ] -``` -*/ -@deprecated({ - reason: "Use `String.splitByRegExpAtMost` instead", - migrate: String.splitByRegExpAtMost(), -}) -@send -external splitByReAtMost: (t, Js_re.t, ~limit: int) => array> = "split" - -/** -ES2015: `startsWith(str, substr)` returns `true` if the `str` starts with -`substr`, `false` otherwise. - -See [`String.startsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith) -on MDN. - -## Examples - -```rescript -Js.String2.startsWith("ReScript", "Re") == true -Js.String2.startsWith("ReScript", "") == true -Js.String2.startsWith("JavaScript", "Re") == false -``` -*/ -@deprecated({ - reason: "Use `String.startsWith` instead", - migrate: String.startsWith(), -}) -@send -external startsWith: (t, t) => bool = "startsWith" - -/** -ES2015: `startsWithFrom(str, substr, n)` returns `true` if the `str` starts -with `substr` starting at position `n`, false otherwise. If `n` is negative, -the search starts at the beginning of `str`. - -See [`String.startsWith`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith) -on MDN. - -## Examples - -```rescript -Js.String2.startsWithFrom("ReScript", "Scri", 2) == true -Js.String2.startsWithFrom("ReScript", "", 2) == true -Js.String2.startsWithFrom("JavaScript", "Scri", 2) == false -``` -*/ -@deprecated({ - reason: "Use `String.startsWithFrom` instead", - migrate: String.startsWithFrom(), -}) -@send -external startsWithFrom: (t, t, int) => bool = "startsWith" - -/** -`substr(str, ~from:n)` returns the substring of `str` from position `n` to the -end of the string. -- If `n` is less than zero, the starting position is the length of `str - n`. -- If `n` is greater than or equal to the length of `str`, returns the empty string. - -JavaScript’s `String.substr()` is a legacy function. When possible, use -`substring()` instead. - -See [`String.substr`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) -on MDN. - -## Examples - -```rescript -Js.String2.substr("abcdefghij", ~from=3) == "defghij" -Js.String2.substr("abcdefghij", ~from=-3) == "hij" -Js.String2.substr("abcdefghij", ~from=12) == "" -``` -*/ -@deprecated("Use `String.substring` instead") @send -external substr: (t, ~from: int) => t = "substr" - -/** -`substrAtMost(str, ~from: pos, ~length: n)` returns the substring of `str` of -length `n` starting at position `pos`. -- If `pos` is less than zero, the starting position is the length of `str - pos`. -- If `pos` is greater than or equal to the length of `str`, returns the empty string. -- If `n` is less than or equal to zero, returns the empty string. - -JavaScript’s `String.substr()` is a legacy function. When possible, use -`substring()` instead. - -See [`String.substr`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) -on MDN. - -## Examples - -```rescript -Js.String2.substrAtMost("abcdefghij", ~from=3, ~length=4) == "defg" -Js.String2.substrAtMost("abcdefghij", ~from=-3, ~length=4) == "hij" -Js.String2.substrAtMost("abcdefghij", ~from=12, ~length=2) == "" -``` -*/ -@deprecated("Use `String.substringAtMost` instead") @send -external substrAtMost: (t, ~from: int, ~length: int) => t = "substr" - -/** -`substring(str, ~from: start, ~to_: finish)` returns characters `start` up to -but not including finish from `str`. -- If `start` is less than zero, it is treated as zero. -- If `finish` is zero or negative, the empty string is returned. -- If `start` is greater than `finish`, the `start` and `finish` points are swapped. - -See [`String.substring`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring) on MDN. - -## Examples - -```rescript -Js.String2.substring("playground", ~from=3, ~to_=6) == "ygr" -Js.String2.substring("playground", ~from=6, ~to_=3) == "ygr" -Js.String2.substring("playground", ~from=4, ~to_=12) == "ground" -``` -*/ -@deprecated({ - reason: "Use `String.substring` instead", - migrate: String.substring( - ~start=%insert.labelledArgument("from"), - ~end=%insert.labelledArgument("to_"), - ), -}) -@send -external substring: (t, ~from: int, ~to_: int) => t = "substring" - -/** -`substringToEnd(str, ~from: start)` returns the substring of `str` from -position `start` to the end. -- If `start` is less than or equal to zero, the entire string is returned. -- If `start` is greater than or equal to the length of `str`, the empty string is returned. - -See [`String.substring`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring) on MDN. - -## Examples - -```rescript -Js.String2.substringToEnd("playground", ~from=4) == "ground" -Js.String2.substringToEnd("playground", ~from=-3) == "playground" -Js.String2.substringToEnd("playground", ~from=12) == "" -``` -*/ -@deprecated({ - reason: "Use `String.substringToEnd` instead", - migrate: String.substringToEnd(~start=%insert.labelledArgument("from")), -}) -@send -external substringToEnd: (t, ~from: int) => t = "substring" - -/** -`toLowerCase(str)` converts `str` to lower case using the locale-insensitive -case mappings in the Unicode Character Database. Notice that the conversion can -give different results depending upon context, for example with the Greek -letter sigma, which has two different lower case forms; one when it is the last -character in a string and another when it is not. - -See [`String.toLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase) -on MDN. - -## Examples - -```rescript -Js.String2.toLowerCase("ABC") == "abc" -Js.String2.toLowerCase(`ΣΠ`) == `σπ` -Js.String2.toLowerCase(`ΠΣ`) == `πς` -``` -*/ -@deprecated({ - reason: "Use `String.toLowerCase` instead", - migrate: String.toLowerCase(), -}) -@send -external toLowerCase: t => t = "toLowerCase" - -/** -`toLocaleLowerCase(str)` converts `str` to lower case using the current locale. -See [`String.toLocaleLowerCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase) -on MDN. -*/ -@deprecated({ - reason: "Use `String.toLocaleLowerCase` instead", - migrate: String.toLocaleLowerCase(), -}) -@send -external toLocaleLowerCase: t => t = "toLocaleLowerCase" - -/** -`toUpperCase(str)` converts `str` to upper case using the locale-insensitive -case mappings in the Unicode Character Database. Notice that the conversion can -expand the number of letters in the result; for example the German ß -capitalizes to two Ses in a row. - -See [`String.toUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase) -on MDN. - -## Examples - -```rescript -Js.String2.toUpperCase("abc") == "ABC" -Js.String2.toUpperCase(`Straße`) == `STRASSE` -Js.String2.toUpperCase(`πς`) == `ΠΣ` -``` -*/ -@deprecated({ - reason: "Use `String.toUpperCase` instead", - migrate: String.toUpperCase(), -}) -@send -external toUpperCase: t => t = "toUpperCase" - -/** -`toLocaleUpperCase(str)` converts `str` to upper case using the current locale. -See [`String.to:LocaleUpperCase`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleUpperCase) -on MDN. -*/ -@deprecated({ - reason: "Use `String.toLocaleUpperCase` instead", - migrate: String.toLocaleUpperCase(), -}) -@send -external toLocaleUpperCase: t => t = "toLocaleUpperCase" - -/** -`trim(str)` returns a string that is `str` with whitespace stripped from both -ends. Internal whitespace is not removed. - -See [`String.trim`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim) -on MDN. - -## Examples - -```rescript -Js.String2.trim(" abc def ") == "abc def" -Js.String2.trim("\n\r\t abc def \n\n\t\r ") == "abc def" -``` -*/ -@deprecated({ - reason: "Use `String.trim` instead", - migrate: String.trim(), -}) -@send -external trim: t => t = "trim" - -/* HTML wrappers */ - -/** -`anchor(anchorText, anchorName)` creates a string with an HTML `` element -with name attribute of `anchorName` and `anchorText` as its content. Please do -not use this method, as it has been removed from the relevant web standards. - -See [`String.anchor`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/anchor) -on MDN. - -## Examples - -```rescript -Js.String2.anchor("Page One", "page1") == "Page One" -``` -*/ -@deprecated("This function has been removed from the relevant web standards.") @send -external anchor: (t, t) => t = "anchor" - -/** -ES2015: `link(linkText, urlText)` creates a string with an HTML `` element -with href attribute of `urlText` and `linkText` as its content. Please do not -use this method, as it has been removed from the relevant web standards. See -[`String.link`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/link) -on MDN. - -## Examples - -```rescript -Js.String2.link("Go to page two", "page2.html") == "Go to page two" -``` -*/ -@deprecated("This function has been removed from the relevant web standards.") @send -external link: (t, t) => t = "link" - -/* FIXME: we should not encourage people to use [%identity], better - to provide something using [@@val] so that we can track such - casting -*/ -/** -Casts its argument to an `array_like` entity that can be processed by functions -such as `Js.Array2.fromMap()` - -## Examples - -```rescript -let s = "abcde" -let arr = Js.Array2.fromMap(Js.String2.castToArrayLike(s), x => x) -arr == ["a", "b", "c", "d", "e"] -``` -*/ -@deprecated({ - reason: "Use `Array.fromString` instead", - migrate: Array.fromString(), -}) -external castToArrayLike: t => Js_array2.array_like = "%identity" diff --git a/packages/@rescript/runtime/Js_typed_array.res b/packages/@rescript/runtime/Js_typed_array.res deleted file mode 100644 index bddd5119d31..00000000000 --- a/packages/@rescript/runtime/Js_typed_array.res +++ /dev/null @@ -1,1848 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** -JavaScript Typed Array API - -**see** [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) -*/ - -@@warning("-103") - -@deprecated({ - reason: "Use `ArrayBuffer.t` instead.", - migrate: %replace.type(: ArrayBuffer.t), -}) -type array_buffer = Js_typed_array2.array_buffer - -@deprecated( - "This has been deprecated and will be removed in v13. Use functions and types from the `TypedArray` module instead." -) -type array_like<'a> = Js_typed_array2.array_like<'a> - -module type Type = { - type t -} -module ArrayBuffer = { - /*** - The underlying buffer that the typed arrays provide views of - - **see** [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) - */ - - type t = array_buffer - - /** takes length. initializes elements to 0 */ - @new - external make: int => t = "ArrayBuffer" - - /* ArrayBuffer.isView: seems pointless with a type system */ - /* experimental - external transfer : array_buffer -> t = "ArrayBuffer.transfer" [@@val] - external transferWithLength : array_buffer -> int -> t = "ArrayBuffer.transfer" [@@val] - */ - - @get external byteLength: t => int = "byteLength" - - // @bs.send.pipe(: t) external slice: (~start: int, ~end_: int) => array_buffer = "slice" /* FIXME */ - // @bs.send.pipe(: t) external sliceFrom: int => array_buffer = "slice" -} -module type S = { - /*** Implements functionality common to all the typed arrays */ - - type elt - type typed_array<'a> - type t = typed_array - - @get_index external unsafe_get: (t, int) => elt = "" - @set_index external unsafe_set: (t, int, elt) => unit = "" - - @get external buffer: t => array_buffer = "buffer" - @get external byteLength: t => int = "byteLength" - @get external byteOffset: t => int = "byteOffset" - - // @bs.send.pipe(: t) external setArray: array => unit = "set" - // @bs.send.pipe(: t) external setArrayOffset: (array, int) => unit = "set" - /* There's also an overload for typed arrays, but don't know how to model that without subtyping */ - - /* Array interface(-ish) - * --- - */ - @get external length: t => int = "length" - - /* Mutator functions - */ - // @bs.send.pipe(: t) external copyWithin: (~to_: int) => t = "copyWithin" - // @bs.send.pipe(: t) external copyWithinFrom: (~to_: int, ~from: int) => t = "copyWithin" - // @bs.send.pipe(: t) - external copyWithinFromRange: (~to_: int, ~start: int, ~end_: int) => t = "copyWithin" - - // @bs.send.pipe(: t) external fillInPlace: elt => t = "fill" - // @bs.send.pipe(: t) external fillFromInPlace: (elt, ~from: int) => t = "fill" - // @bs.send.pipe(: t) external fillRangeInPlace: (elt, ~start: int, ~end_: int) => t = "fill" - - // @bs.send.pipe(: t) external reverseInPlace: t = "reverse" - - // @bs.send.pipe(: t) external sortInPlace: t = "sort" - // @bs.send.pipe(: t) external sortInPlaceWith: ((elt, elt) => int) => t = "sort" - - /* Accessor functions - */ - // @bs.send.pipe(: t) /** ES2016 */ - @deprecated({ - reason: "Use `TypedArray.includes` instead.", - migrate: TypedArray.includes(), - }) - external includes: elt => bool = "includes" - - // @bs.send.pipe(: t) external indexOf: elt => int = "indexOf" - // @bs.send.pipe(: t) external indexOfFrom: (elt, ~from: int) => int = "indexOf" - - // @bs.send.pipe(: t) external join: string = "join" - // @bs.send.pipe(: t) external joinWith: string => string = "join" - - // @bs.send.pipe(: t) external lastIndexOf: elt => int = "lastIndexOf" - // @bs.send.pipe(: t) external lastIndexOfFrom: (elt, ~from: int) => int = "lastIndexOf" - - // @bs.send.pipe(: t) external slice: (~start: int, ~end_: int) => t = "slice" - // @bs.send.pipe(: t) external copy: t = "slice" - // @bs.send.pipe(: t) external sliceFrom: int => t = "slice" - - // @bs.send.pipe(: t) external subarray: (~start: int, ~end_: int) => t = "subarray" - // @bs.send.pipe(: t) external subarrayFrom: int => t = "subarray" - - // @bs.send.pipe(: t) external toString: string = "toString" - // @bs.send.pipe(: t) external toLocaleString: string = "toLocaleString" - - /* Iteration functions - */ - /* commented out until bs has a plan for iterators - external entries : (int * elt) array_iter = "" [@// @bs.send.pipe: t] - */ - - // @bs.send.pipe(: t) external every: ((elt) => bool) => bool = "every" - // @bs.send.pipe(: t) external everyi: ((elt, int) => bool) => bool = "every" - - /** should we use `bool` or `boolean` seems they are intechangeable here */ - external // @bs.send.pipe(: t) - filter: (elt => bool) => t = "filter" - // @bs.send.pipe(: t) external filteri: ((elt, int) => bool) => t = "filter" - - // @bs.send.pipe(: t) external find: ((elt) => bool) => Js.undefined = "find" - // @bs.send.pipe(: t) external findi: ((elt, int) => bool) => Js.undefined = "find" - - // @bs.send.pipe(: t) external findIndex: ((elt) => bool) => int = "findIndex" - // @bs.send.pipe(: t) external findIndexi: ((elt, int) => bool) => int = "findIndex" - - // @bs.send.pipe(: t) external forEach: ((elt) => unit) => unit = "forEach" - // @bs.send.pipe(: t) external forEachi: ((elt, int) => unit) => unit = "forEach" - - /* commented out until bs has a plan for iterators - external keys : int array_iter = "" [@// @bs.send.pipe: t] - */ - - // @bs.send.pipe(: t) external map: ((elt) => 'b) => typed_array<'b> = "map" - // @bs.send.pipe(: t) external mapi: ((elt, int) => 'b) => typed_array<'b> = "map" - - // @bs.send.pipe(: t) external reduce: (('b, elt) => 'b, 'b) => 'b = "reduce" - // @bs.send.pipe(: t) external reducei: (('b, elt, int) => 'b, 'b) => 'b = "reduce" - - // @bs.send.pipe(: t) external reduceRight: (('b, elt) => 'b, 'b) => 'b = "reduceRight" - // @bs.send.pipe(: t) external reduceRighti: (('b, elt, int) => 'b, 'b) => 'b = "reduceRight" - - // @bs.send.pipe(: t) external some: ((elt) => bool) => bool = "some" - // @bs.send.pipe(: t) external somei: ((elt, int) => bool) => bool = "some" - - /* commented out until bs has a plan for iterators - external values : elt array_iter = "" [@// @bs.send.pipe: t] - */ -} - -/* commented out until bs has a plan for iterators - external values : elt array_iter = "" [@// @bs.send.pipe: t] - */ - -module Int8Array = { - /** */ - type elt = int - type typed_array<'a> = Js_typed_array2.Int8Array.typed_array<'a> - type t = typed_array - - @get_index external unsafe_get: (t, int) => elt = "" - @set_index external unsafe_set: (t, int, elt) => unit = "" - - @get external buffer: t => array_buffer = "buffer" - @get external byteLength: t => int = "byteLength" - @get external byteOffset: t => int = "byteOffset" - - // @bs.send.pipe(: t) external setArray: array => unit = "set" - // @bs.send.pipe(: t) external setArrayOffset: (array, int) => unit = "set" - /* There's also an overload for typed arrays, but don't know how to model that without subtyping */ - - /* Array interface(-ish) */ - @deprecated({ - reason: "Use `TypedArray.length` instead.", - migrate: TypedArray.length(), - }) - @get - external length: t => int = "length" - - /* Mutator functions */ - // @bs.send.pipe(: t) external copyWithin: (~to_: int) => t = "copyWithin" - // @bs.send.pipe(: t) external copyWithinFrom: (~to_: int, ~from: int) => t = "copyWithin" - // @bs.send.pipe(: t) - @deprecated({ - reason: "Use `TypedArray.copyWithin` instead.", - migrate: TypedArray.copyWithin( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - external copyWithinFromRange: (~to_: int, ~start: int, ~end_: int) => t = "copyWithin" - - // @bs.send.pipe(: t) external fillInPlace: elt => t = "fill" - // @bs.send.pipe(: t) external fillFromInPlace: (elt, ~from: int) => t = "fill" - // @bs.send.pipe(: t) external fillRangeInPlace: (elt, ~start: int, ~end_: int) => t = "fill" - - // @bs.send.pipe(: t) external reverseInPlace: t = "reverse" - - // @bs.send.pipe(: t) external sortInPlace: t = "sort" - // @bs.send.pipe(: t) external sortInPlaceWith: ((elt, elt) => int) => t = "sort" - - /* Accessor functions */ - // @bs.send.pipe(: t) external includes: elt => bool = "includes" /* ES2016 */ - - // @bs.send.pipe(: t) external indexOf: elt => int = "indexOf" - // @bs.send.pipe(: t) external indexOfFrom: (elt, ~from: int) => int = "indexOf" - - // @bs.send.pipe(: t) external join: string = "join" - // @bs.send.pipe(: t) external joinWith: string => string = "join" - - // @bs.send.pipe(: t) external lastIndexOf: elt => int = "lastIndexOf" - // @bs.send.pipe(: t) external lastIndexOfFrom: (elt, ~from: int) => int = "lastIndexOf" - - @deprecated("Use `TypedArray.slice` instead.") - external // @bs.send.pipe(: t) /** `start` is inclusive, `end_` exclusive */ - slice: (~start: int, ~end_: int) => t = "slice" - - // @bs.send.pipe(: t) external copy: t = "slice" - @deprecated("Use `TypedArray.sliceToEnd` instead.") - external // @bs.send.pipe(: t) external sliceFrom: int => t = "slice" - - // @bs.send.pipe(: t) /** `start` is inclusive, `end_` exclusive */ - subarray: (~start: int, ~end_: int) => t = "subarray" - - // @bs.send.pipe(: t) external subarrayFrom: int => t = "subarray" - - // @bs.send.pipe(: t) external toString: string = "toString" - // @bs.send.pipe(: t) external toLocaleString: string = "toLocaleString" - - /* Iteration functions */ - /* commented out until bs has a plan for iterators - external entries : (int * elt) array_iter = "" [@// @bs.send.pipe: t] - */ - // @bs.send.pipe(: t) external every: ((elt) => bool) => bool = "every" - // @bs.send.pipe(: t) external everyi: ((elt, int) => bool) => bool = "every" - - // @bs.send.pipe(: t) external filter: ((elt) => bool) => t = "filter" - // @bs.send.pipe(: t) external filteri: ((elt, int) => bool) => t = "filter" - - // @bs.send.pipe(: t) external find: ((elt) => bool) => Js.undefined = "find" - // @bs.send.pipe(: t) external findi: ((elt, int) => bool) => Js.undefined = "find" - - // @bs.send.pipe(: t) external findIndex: ((elt) => bool) => int = "findIndex" - // @bs.send.pipe(: t) external findIndexi: ((elt, int) => bool) => int = "findIndex" - - // @bs.send.pipe(: t) external forEach: ((elt) => unit) => unit = "forEach" - // @bs.send.pipe(: t) external forEachi: ((elt, int) => unit) => unit = "forEach" - - /* commented out until bs has a plan for iterators - external keys : int array_iter = "" [@// @bs.send.pipe: t] - */ - - // @bs.send.pipe(: t) external map: ((elt) => 'b) => typed_array<'b> = "map" - // @bs.send.pipe(: t) external mapi: ((elt, int) => 'b) => typed_array<'b> = "map" - - // @bs.send.pipe(: t) external reduce: (('b, elt) => 'b, 'b) => 'b = "reduce" - // @bs.send.pipe(: t) external reducei: (('b, elt, int) => 'b, 'b) => 'b = "reduce" - - // @bs.send.pipe(: t) external reduceRight: (('b, elt) => 'b, 'b) => 'b = "reduceRight" - // @bs.send.pipe(: t) external reduceRighti: (('b, elt, int) => 'b, 'b) => 'b = "reduceRight" - - // @bs.send.pipe(: t) external some: ((elt) => bool) => bool = "some" - // @bs.send.pipe(: t) external somei: ((elt, int) => bool) => bool = "some" - - @deprecated({ - reason: "Use `Int8Array.Constants.bytesPerElement` instead.", - migrate: Int8Array.Constants.bytesPerElement, - }) - @val - external _BYTES_PER_ELEMENT: int = "Int8Array.BYTES_PER_ELEMENT" - - @deprecated({ - reason: "Use `Int8Array.fromArray` instead.", - migrate: Int8Array.fromArray(), - }) - @new - external make: array => t = "Int8Array" - /** can throw */ - @new - external fromBuffer: array_buffer => t = "Int8Array" - - /** - throw Js.Exn.Error throw Js exception - - param offset is in bytes - */ - @deprecated({ - reason: "Use `Int8Array.fromBufferToEnd` instead.", - migrate: Int8Array.fromBufferToEnd(~byteOffset=%insert.unlabelledArgument(1)), - }) - @new external fromBufferOffset: (array_buffer, int) => t = "Int8Array" - - /** - throw Js.Exn.Error throws Js exception - - param offset is in bytes, length in elements - */ - @deprecated({ - reason: "Use `Int8Array.fromBufferWithRange` instead.", - migrate: Int8Array.fromBufferWithRange( - ~byteOffset=%insert.labelledArgument("offset"), - ~length=%insert.labelledArgument("length"), - ), - }) - @new - external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Int8Array" - - @deprecated({ - reason: "Use `Int8Array.fromLength` instead.", - migrate: Int8Array.fromLength(), - }) - @new - external fromLength: int => t = "Int8Array" - @deprecated({ - reason: "Use `Int8Array.fromArrayLikeOrIterable` instead.", - migrate: Int8Array.fromArrayLikeOrIterable(), - }) - @val - external from: array_like => t = "Int8Array.from" - /* *Array.of is redundant, use make */ -} - -module Uint8Array = { - /** */ - type elt = int - type typed_array<'a> = Js_typed_array2.Uint8Array.typed_array<'a> - type t = typed_array - - @get_index external unsafe_get: (t, int) => elt = "" - @set_index external unsafe_set: (t, int, elt) => unit = "" - - @get external buffer: t => array_buffer = "buffer" - @get external byteLength: t => int = "byteLength" - @get external byteOffset: t => int = "byteOffset" - - // @bs.send.pipe(: t) external setArray: array => unit = "set" - // @bs.send.pipe(: t) external setArrayOffset: (array, int) => unit = "set" - /* There's also an overload for typed arrays, but don't know how to model that without subtyping */ - - /* Array interface(-ish) */ - @deprecated({ - reason: "Use `TypedArray.length` instead.", - migrate: TypedArray.length(), - }) - @get - external length: t => int = "length" - - /* Mutator functions */ - // @bs.send.pipe(: t) external copyWithin: (~to_: int) => t = "copyWithin" - // @bs.send.pipe(: t) external copyWithinFrom: (~to_: int, ~from: int) => t = "copyWithin" - // @bs.send.pipe(: t) - @deprecated({ - reason: "Use `TypedArray.copyWithin` instead.", - migrate: TypedArray.copyWithin( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - external copyWithinFromRange: (~to_: int, ~start: int, ~end_: int) => t = "copyWithin" - - // @bs.send.pipe(: t) external fillInPlace: elt => t = "fill" - // @bs.send.pipe(: t) external fillFromInPlace: (elt, ~from: int) => t = "fill" - // @bs.send.pipe(: t) external fillRangeInPlace: (elt, ~start: int, ~end_: int) => t = "fill" - - // @bs.send.pipe(: t) external reverseInPlace: t = "reverse" - - // @bs.send.pipe(: t) external sortInPlace: t = "sort" - // @bs.send.pipe(: t) external sortInPlaceWith: ((elt, elt) => int) => t = "sort" - - /* Accessor functions */ - // @bs.send.pipe(: t) external includes: elt => bool = "includes" /* ES2016 */ - - // @bs.send.pipe(: t) external indexOf: elt => int = "indexOf" - // @bs.send.pipe(: t) external indexOfFrom: (elt, ~from: int) => int = "indexOf" - - // @bs.send.pipe(: t) external join: string = "join" - // @bs.send.pipe(: t) external joinWith: string => string = "join" - - // @bs.send.pipe(: t) external lastIndexOf: elt => int = "lastIndexOf" - // @bs.send.pipe(: t) external lastIndexOfFrom: (elt, ~from: int) => int = "lastIndexOf" - - // @bs.send.pipe(: t) /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.slice` instead.", - migrate: TypedArray.slice(~end=%insert.labelledArgument("end_")), - }) - @deprecated({ - reason: "Use `TypedArray.slice` instead.", - migrate: TypedArray.slice(~end=%insert.labelledArgument("end_")), - }) - external slice: (~start: int, ~end_: int) => t = "slice" - - // @bs.send.pipe(: t) external copy: t = "slice" - // @bs.send.pipe(: t) external sliceFrom: int => t = "slice" - - // @bs.send.pipe(: t) /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~end=%insert.labelledArgument("end_")), - }) - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~end=%insert.labelledArgument("end_")), - }) - external subarray: (~start: int, ~end_: int) => t = "subarray" - - // @bs.send.pipe(: t) external subarrayFrom: int => t = "subarray" - - // @bs.send.pipe(: t) external toString: string = "toString" - // @bs.send.pipe(: t) external toLocaleString: string = "toLocaleString" - - /* Iteration functions */ - /* commented out until bs has a plan for iterators - external entries : (int * elt) array_iter = "" [@// @bs.send.pipe: t] - */ - // @bs.send.pipe(: t) external every: ((elt) => bool) => bool = "every" - // @bs.send.pipe(: t) external everyi: ((elt, int) => bool) => bool = "every" - - // @bs.send.pipe(: t) external filter: ((elt) => bool) => t = "filter" - // @bs.send.pipe(: t) external filteri: ((elt, int) => bool) => t = "filter" - - // @bs.send.pipe(: t) external find: ((elt) => bool) => Js.undefined = "find" - // @bs.send.pipe(: t) external findi: ((elt, int) => bool) => Js.undefined = "find" - - // @bs.send.pipe(: t) external findIndex: ((elt) => bool) => int = "findIndex" - // @bs.send.pipe(: t) external findIndexi: ((elt, int) => bool) => int = "findIndex" - - // @bs.send.pipe(: t) external forEach: ((elt) => unit) => unit = "forEach" - // @bs.send.pipe(: t) external forEachi: ((elt, int) => unit) => unit = "forEach" - - /* commented out until bs has a plan for iterators - external keys : int array_iter = "" [@// @bs.send.pipe: t] - */ - - // @bs.send.pipe(: t) external map: ((elt) => 'b) => typed_array<'b> = "map" - // @bs.send.pipe(: t) external mapi: ((elt, int) => 'b) => typed_array<'b> = "map" - - // @bs.send.pipe(: t) external reduce: (('b, elt) => 'b, 'b) => 'b = "reduce" - // @bs.send.pipe(: t) external reducei: (('b, elt, int) => 'b, 'b) => 'b = "reduce" - - // @bs.send.pipe(: t) external reduceRight: (('b, elt) => 'b, 'b) => 'b = "reduceRight" - // @bs.send.pipe(: t) external reduceRighti: (('b, elt, int) => 'b, 'b) => 'b = "reduceRight" - - // @bs.send.pipe(: t) external some: ((elt) => bool) => bool = "some" - // @bs.send.pipe(: t) external somei: ((elt, int) => bool) => bool = "some" - - @deprecated({ - reason: "Use `Uint8Array.Constants.bytesPerElement` instead.", - migrate: Uint8Array.Constants.bytesPerElement, - }) - @val - external _BYTES_PER_ELEMENT: int = "Uint8Array.BYTES_PER_ELEMENT" - - @deprecated({ - reason: "Use `Uint8Array.fromArray` instead.", - migrate: Uint8Array.fromArray(), - }) - @new - external make: array => t = "Uint8Array" - /** can throw */ - @new - external fromBuffer: array_buffer => t = "Uint8Array" - - /** - **throw** Js.Exn.Error throw Js exception - - **param** offset is in bytes - */ - @deprecated({ - reason: "Use `Uint8Array.fromBufferToEnd` instead.", - migrate: Uint8Array.fromBufferToEnd(~byteOffset=%insert.unlabelledArgument(1)), - }) - @new external fromBufferOffset: (array_buffer, int) => t = "Uint8Array" - - /** - **throw** Js.Exn.Error throws Js exception - - **param** offset is in bytes, length in elements - */ - @deprecated({ - reason: "Use `Uint8Array.fromBufferWithRange` instead.", - migrate: Uint8Array.fromBufferWithRange( - ~byteOffset=%insert.labelledArgument("offset"), - ~length=%insert.labelledArgument("length"), - ), - }) - @new - external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Uint8Array" - - @deprecated({ - reason: "Use `Uint8Array.fromLength` instead.", - migrate: Uint8Array.fromLength(), - }) - @new - external fromLength: int => t = "Uint8Array" - @deprecated({ - reason: "Use `Uint8Array.fromArrayLikeOrIterable` instead.", - migrate: Uint8Array.fromArrayLikeOrIterable(), - }) - @val - external from: array_like => t = "Uint8Array.from" - /* *Array.of is redundant, use make */ -} - -module Uint8ClampedArray = { - /** */ - type elt = int - type typed_array<'a> = Js_typed_array2.Uint8ClampedArray.typed_array<'a> - type t = typed_array - - @get_index external unsafe_get: (t, int) => elt = "" - @set_index external unsafe_set: (t, int, elt) => unit = "" - - @get external buffer: t => array_buffer = "buffer" - @get external byteLength: t => int = "byteLength" - @get external byteOffset: t => int = "byteOffset" - - // @bs.send.pipe(: t) external setArray: array => unit = "set" - // @bs.send.pipe(: t) external setArrayOffset: (array, int) => unit = "set" - /* There's also an overload for typed arrays, but don't know how to model that without subtyping */ - - /* Array interface(-ish) */ - @deprecated({ - reason: "Use `TypedArray.length` instead.", - migrate: TypedArray.length(), - }) - @get - external length: t => int = "length" - - /* Mutator functions */ - // @bs.send.pipe(: t) external copyWithin: (~to_: int) => t = "copyWithin" - // @bs.send.pipe(: t) external copyWithinFrom: (~to_: int, ~from: int) => t = "copyWithin" - // @bs.send.pipe(: t) - @deprecated({ - reason: "Use `TypedArray.copyWithin` instead.", - migrate: TypedArray.copyWithin( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - external copyWithinFromRange: (~to_: int, ~start: int, ~end_: int) => t = "copyWithin" - - // @bs.send.pipe(: t) external fillInPlace: elt => t = "fill" - // @bs.send.pipe(: t) external fillFromInPlace: (elt, ~from: int) => t = "fill" - // @bs.send.pipe(: t) external fillRangeInPlace: (elt, ~start: int, ~end_: int) => t = "fill" - - // @bs.send.pipe(: t) external reverseInPlace: t = "reverse" - - // @bs.send.pipe(: t) external sortInPlace: t = "sort" - // @bs.send.pipe(: t) external sortInPlaceWith: ((elt, elt) => int) => t = "sort" - - /* Accessor functions */ - // @bs.send.pipe(: t) external includes: elt => bool = "includes" /* ES2016 */ - - // @bs.send.pipe(: t) external indexOf: elt => int = "indexOf" - // @bs.send.pipe(: t) external indexOfFrom: (elt, ~from: int) => int = "indexOf" - - // @bs.send.pipe(: t) external join: string = "join" - // @bs.send.pipe(: t) external joinWith: string => string = "join" - - // @bs.send.pipe(: t) external lastIndexOf: elt => int = "lastIndexOf" - // @bs.send.pipe(: t) external lastIndexOfFrom: (elt, ~from: int) => int = "lastIndexOf" - - // @bs.send.pipe(: t) /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.slice` instead.", - migrate: TypedArray.slice(~end=%insert.labelledArgument("end_")), - }) - external slice: (~start: int, ~end_: int) => t = "slice" - - // @bs.send.pipe(: t) external copy: t = "slice" - // @bs.send.pipe(: t) external sliceFrom: int => t = "slice" - - // @bs.send.pipe(: t) /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~end=%insert.labelledArgument("end_")), - }) - external subarray: (~start: int, ~end_: int) => t = "subarray" - - // @bs.send.pipe(: t) external subarrayFrom: int => t = "subarray" - - // @bs.send.pipe(: t) external toString: string = "toString" - // @bs.send.pipe(: t) external toLocaleString: string = "toLocaleString" - - /* Iteration functions */ - /* commented out until bs has a plan for iterators - external entries : (int * elt) array_iter = "" [@// @bs.send.pipe: t] - */ - // @bs.send.pipe(: t) external every: ((elt) => bool) => bool = "every" - // @bs.send.pipe(: t) external everyi: ((elt, int) => bool) => bool = "every" - - // @bs.send.pipe(: t) external filter: ((elt) => bool) => t = "filter" - // @bs.send.pipe(: t) external filteri: ((elt, int) => bool) => t = "filter" - - // @bs.send.pipe(: t) external find: ((elt) => bool) => Js.undefined = "find" - // @bs.send.pipe(: t) external findi: ((elt, int) => bool) => Js.undefined = "find" - - // @bs.send.pipe(: t) external findIndex: ((elt) => bool) => int = "findIndex" - // @bs.send.pipe(: t) external findIndexi: ((elt, int) => bool) => int = "findIndex" - - // @bs.send.pipe(: t) external forEach: ((elt) => unit) => unit = "forEach" - // @bs.send.pipe(: t) external forEachi: ((elt, int) => unit) => unit = "forEach" - - /* commented out until bs has a plan for iterators - external keys : int array_iter = "" [@// @bs.send.pipe: t] - */ - - // @bs.send.pipe(: t) external map: ((elt) => 'b) => typed_array<'b> = "map" - // @bs.send.pipe(: t) external mapi: ((elt, int) => 'b) => typed_array<'b> = "map" - - // @bs.send.pipe(: t) external reduce: (('b, elt) => 'b, 'b) => 'b = "reduce" - // @bs.send.pipe(: t) external reducei: (('b, elt, int) => 'b, 'b) => 'b = "reduce" - - // @bs.send.pipe(: t) external reduceRight: (('b, elt) => 'b, 'b) => 'b = "reduceRight" - // @bs.send.pipe(: t) external reduceRighti: (('b, elt, int) => 'b, 'b) => 'b = "reduceRight" - - // @bs.send.pipe(: t) external some: ((elt) => bool) => bool = "some" - // @bs.send.pipe(: t) external somei: ((elt, int) => bool) => bool = "some" - - @deprecated({ - reason: "Use `Uint8ClampedArray.Constants.bytesPerElement` instead.", - migrate: Uint8ClampedArray.Constants.bytesPerElement, - }) - @val - external _BYTES_PER_ELEMENT: int = "Uint8ClampedArray.BYTES_PER_ELEMENT" - - @deprecated({ - reason: "Use `Uint8ClampedArray.fromArray` instead.", - migrate: Uint8ClampedArray.fromArray(), - }) - @new - external make: array => t = "Uint8ClampedArray" - /** can throw */ - @new - external fromBuffer: array_buffer => t = "Uint8ClampedArray" - - /** - **throw** Js.Exn.Error throw Js exception - - **param** offset is in bytes - */ - @deprecated({ - reason: "Use `Uint8ClampedArray.fromBufferToEnd` instead.", - migrate: Uint8ClampedArray.fromBufferToEnd(~byteOffset=%insert.unlabelledArgument(1)), - }) - @new external fromBufferOffset: (array_buffer, int) => t = "Uint8ClampedArray" - - /** - **throw** Js.Exn.Error throws Js exception - - **param** offset is in bytes, length in elements - */ - @deprecated({ - reason: "Use `Uint8ClampedArray.fromBufferWithRange` instead.", - migrate: Uint8ClampedArray.fromBufferWithRange( - ~byteOffset=%insert.labelledArgument("offset"), - ~length=%insert.labelledArgument("length"), - ), - }) - @new - external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Uint8ClampedArray" - - @deprecated({ - reason: "Use `Uint8ClampedArray.fromLength` instead.", - migrate: Uint8ClampedArray.fromLength(), - }) - @new - external fromLength: int => t = "Uint8ClampedArray" - @deprecated({ - reason: "Use `Uint8ClampedArray.fromArrayLikeOrIterable` instead.", - migrate: Uint8ClampedArray.fromArrayLikeOrIterable(), - }) - @val - external from: array_like => t = "Uint8ClampedArray.from" - /* *Array.of is redundant, use make */ -} - -module Int16Array = { - /** */ - type elt = int - type typed_array<'a> = Js_typed_array2.Int16Array.typed_array<'a> - type t = typed_array - - @get_index external unsafe_get: (t, int) => elt = "" - @set_index external unsafe_set: (t, int, elt) => unit = "" - - @get external buffer: t => array_buffer = "buffer" - @get external byteLength: t => int = "byteLength" - @get external byteOffset: t => int = "byteOffset" - - // @bs.send.pipe(: t) external setArray: array => unit = "set" - // @bs.send.pipe(: t) external setArrayOffset: (array, int) => unit = "set" - /* There's also an overload for typed arrays, but don't know how to model that without subtyping */ - - /* Array interface(-ish) */ - @deprecated({ - reason: "Use `TypedArray.length` instead.", - migrate: TypedArray.length(), - }) - @get - external length: t => int = "length" - - /* Mutator functions */ - // @bs.send.pipe(: t) external copyWithin: (~to_: int) => t = "copyWithin" - // @bs.send.pipe(: t) external copyWithinFrom: (~to_: int, ~from: int) => t = "copyWithin" - // @bs.send.pipe(: t) - @deprecated({ - reason: "Use `TypedArray.copyWithin` instead.", - migrate: TypedArray.copyWithin( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - external copyWithinFromRange: (~to_: int, ~start: int, ~end_: int) => t = "copyWithin" - - // @bs.send.pipe(: t) external fillInPlace: elt => t = "fill" - // @bs.send.pipe(: t) external fillFromInPlace: (elt, ~from: int) => t = "fill" - // @bs.send.pipe(: t) external fillRangeInPlace: (elt, ~start: int, ~end_: int) => t = "fill" - - // @bs.send.pipe(: t) external reverseInPlace: t = "reverse" - - // @bs.send.pipe(: t) external sortInPlace: t = "sort" - // @bs.send.pipe(: t) external sortInPlaceWith: ((elt, elt) => int) => t = "sort" - - /* Accessor functions */ - // @bs.send.pipe(: t) external includes: elt => bool = "includes" /* ES2016 */ - - // @bs.send.pipe(: t) external indexOf: elt => int = "indexOf" - // @bs.send.pipe(: t) external indexOfFrom: (elt, ~from: int) => int = "indexOf" - - // @bs.send.pipe(: t) external join: string = "join" - // @bs.send.pipe(: t) external joinWith: string => string = "join" - - // @bs.send.pipe(: t) external lastIndexOf: elt => int = "lastIndexOf" - // @bs.send.pipe(: t) external lastIndexOfFrom: (elt, ~from: int) => int = "lastIndexOf" - - // @bs.send.pipe(: t) /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.slice` instead.", - migrate: TypedArray.slice(~end=%insert.labelledArgument("end_")), - }) - external slice: (~start: int, ~end_: int) => t = "slice" - - // @bs.send.pipe(: t) external copy: t = "slice" - // @bs.send.pipe(: t) external sliceFrom: int => t = "slice" - - // @bs.send.pipe(: t) /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~end=%insert.labelledArgument("end_")), - }) - external subarray: (~start: int, ~end_: int) => t = "subarray" - - // @bs.send.pipe(: t) external subarrayFrom: int => t = "subarray" - - // @bs.send.pipe(: t) external toString: string = "toString" - // @bs.send.pipe(: t) external toLocaleString: string = "toLocaleString" - - /* Iteration functions */ - /* commented out until bs has a plan for iterators - external entries : (int * elt) array_iter = "" [@// @bs.send.pipe: t] - */ - // @bs.send.pipe(: t) external every: ((elt) => bool) => bool = "every" - // @bs.send.pipe(: t) external everyi: ((elt, int) => bool) => bool = "every" - - // @bs.send.pipe(: t) external filter: ((elt) => bool) => t = "filter" - // @bs.send.pipe(: t) external filteri: ((elt, int) => bool) => t = "filter" - - // @bs.send.pipe(: t) external find: ((elt) => bool) => Js.undefined = "find" - // @bs.send.pipe(: t) external findi: ((elt, int) => bool) => Js.undefined = "find" - - // @bs.send.pipe(: t) external findIndex: ((elt) => bool) => int = "findIndex" - // @bs.send.pipe(: t) external findIndexi: ((elt, int) => bool) => int = "findIndex" - - // @bs.send.pipe(: t) external forEach: ((elt) => unit) => unit = "forEach" - // @bs.send.pipe(: t) external forEachi: ((elt, int) => unit) => unit = "forEach" - - /* commented out until bs has a plan for iterators - external keys : int array_iter = "" [@// @bs.send.pipe: t] - */ - - // @bs.send.pipe(: t) external map: ((elt) => 'b) => typed_array<'b> = "map" - // @bs.send.pipe(: t) external mapi: ((elt, int) => 'b) => typed_array<'b> = "map" - - // @bs.send.pipe(: t) external reduce: (('b, elt) => 'b, 'b) => 'b = "reduce" - // @bs.send.pipe(: t) external reducei: (('b, elt, int) => 'b, 'b) => 'b = "reduce" - - // @bs.send.pipe(: t) external reduceRight: (('b, elt) => 'b, 'b) => 'b = "reduceRight" - // @bs.send.pipe(: t) external reduceRighti: (('b, elt, int) => 'b, 'b) => 'b = "reduceRight" - - // @bs.send.pipe(: t) external some: ((elt) => bool) => bool = "some" - // @bs.send.pipe(: t) external somei: ((elt, int) => bool) => bool = "some" - - @deprecated({ - reason: "Use `Int16Array.Constants.bytesPerElement` instead.", - migrate: Int16Array.Constants.bytesPerElement, - }) - @val - external _BYTES_PER_ELEMENT: int = "Int16Array.BYTES_PER_ELEMENT" - - @deprecated({ - reason: "Use `Int16Array.fromArray` instead.", - migrate: Int16Array.fromArray(), - }) - @new - external make: array => t = "Int16Array" - /** can throw */ - @new - @deprecated({ - reason: "Use `Int16Array.fromBuffer` instead.", - migrate: Int16Array.fromBuffer(), - }) - external fromBuffer: array_buffer => t = "Int16Array" - - /** - **throw** Js.Exn.Error throw Js exception - - **param** offset is in bytes - */ - @new - @deprecated({ - reason: "Use `Int16Array.fromBufferToEnd` instead.", - migrate: Int16Array.fromBufferToEnd(~byteOffset=%insert.unlabelledArgument(1)), - }) - external fromBufferOffset: (array_buffer, int) => t = "Int16Array" - - /** - **throw** Js.Exn.Error throws Js exception - - **param** offset is in bytes, length in elements - */ - @new - @deprecated({ - reason: "Use `Int16Array.fromBufferWithRange` instead.", - migrate: Int16Array.fromBufferWithRange( - ~byteOffset=%insert.labelledArgument("offset"), - ~length=%insert.labelledArgument("length"), - ), - }) - external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Int16Array" - - @deprecated({ - reason: "Use `Int16Array.fromLength` instead.", - migrate: Int16Array.fromLength(), - }) - @new - external fromLength: int => t = "Int16Array" - @deprecated({ - reason: "Use `Int16Array.fromArrayLikeOrIterable` instead.", - migrate: Int16Array.fromArrayLikeOrIterable(), - }) - @val - external from: array_like => t = "Int16Array.from" - /* *Array.of is redundant, use make */ -} - -module Uint16Array = { - /** */ - type elt = int - type typed_array<'a> = Js_typed_array2.Uint16Array.typed_array<'a> - type t = typed_array - - @get_index external unsafe_get: (t, int) => elt = "" - @set_index external unsafe_set: (t, int, elt) => unit = "" - - @get external buffer: t => array_buffer = "buffer" - @get external byteLength: t => int = "byteLength" - @get external byteOffset: t => int = "byteOffset" - - // @bs.send.pipe(: t) external setArray: array => unit = "set" - // @bs.send.pipe(: t) external setArrayOffset: (array, int) => unit = "set" - /* There's also an overload for typed arrays, but don't know how to model that without subtyping */ - - /* Array interface(-ish) */ - @deprecated({ - reason: "Use `TypedArray.length` instead.", - migrate: TypedArray.length(), - }) - @get - external length: t => int = "length" - - /* Mutator functions */ - // @bs.send.pipe(: t) external copyWithin: (~to_: int) => t = "copyWithin" - // @bs.send.pipe(: t) external copyWithinFrom: (~to_: int, ~from: int) => t = "copyWithin" - // @bs.send.pipe(: t) - @deprecated({ - reason: "Use `TypedArray.copyWithin` instead.", - migrate: TypedArray.copyWithin( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - external copyWithinFromRange: (~to_: int, ~start: int, ~end_: int) => t = "copyWithin" - - // @bs.send.pipe(: t) external fillInPlace: elt => t = "fill" - // @bs.send.pipe(: t) external fillFromInPlace: (elt, ~from: int) => t = "fill" - // @bs.send.pipe(: t) external fillRangeInPlace: (elt, ~start: int, ~end_: int) => t = "fill" - - // @bs.send.pipe(: t) external reverseInPlace: t = "reverse" - - // @bs.send.pipe(: t) external sortInPlace: t = "sort" - // @bs.send.pipe(: t) external sortInPlaceWith: ((elt, elt) => int) => t = "sort" - - /* Accessor functions */ - // @bs.send.pipe(: t) external includes: elt => bool = "includes" /* ES2016 */ - - // @bs.send.pipe(: t) external indexOf: elt => int = "indexOf" - // @bs.send.pipe(: t) external indexOfFrom: (elt, ~from: int) => int = "indexOf" - - // @bs.send.pipe(: t) external join: string = "join" - // @bs.send.pipe(: t) external joinWith: string => string = "join" - - // @bs.send.pipe(: t) external lastIndexOf: elt => int = "lastIndexOf" - // @bs.send.pipe(: t) external lastIndexOfFrom: (elt, ~from: int) => int = "lastIndexOf" - - // @bs.send.pipe(: t) /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.slice` instead.", - migrate: TypedArray.slice(~end=%insert.labelledArgument("end_")), - }) - external slice: (~start: int, ~end_: int) => t = "slice" - - // @bs.send.pipe(: t) external copy: t = "slice" - // @bs.send.pipe(: t) external sliceFrom: int => t = "slice" - - // @bs.send.pipe(: t) /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~end=%insert.labelledArgument("end_")), - }) - external subarray: (~start: int, ~end_: int) => t = "subarray" - - // @bs.send.pipe(: t) external subarrayFrom: int => t = "subarray" - - // @bs.send.pipe(: t) external toString: string = "toString" - // @bs.send.pipe(: t) external toLocaleString: string = "toLocaleString" - - /* Iteration functions */ - /* commented out until bs has a plan for iterators - external entries : (int * elt) array_iter = "" [@// @bs.send.pipe: t] - */ - // @bs.send.pipe(: t) external every: ((elt) => bool) => bool = "every" - // @bs.send.pipe(: t) external everyi: ((elt, int) => bool) => bool = "every" - - // @bs.send.pipe(: t) external filter: ((elt) => bool) => t = "filter" - // @bs.send.pipe(: t) external filteri: ((elt, int) => bool) => t = "filter" - - // @bs.send.pipe(: t) external find: ((elt) => bool) => Js.undefined = "find" - // @bs.send.pipe(: t) external findi: ((elt, int) => bool) => Js.undefined = "find" - - // @bs.send.pipe(: t) external findIndex: ((elt) => bool) => int = "findIndex" - // @bs.send.pipe(: t) external findIndexi: ((elt, int) => bool) => int = "findIndex" - - // @bs.send.pipe(: t) external forEach: ((elt) => unit) => unit = "forEach" - // @bs.send.pipe(: t) external forEachi: ((elt, int) => unit) => unit = "forEach" - - /* commented out until bs has a plan for iterators - external keys : int array_iter = "" [@// @bs.send.pipe: t] - */ - - // @bs.send.pipe(: t) external map: ((elt) => 'b) => typed_array<'b> = "map" - // @bs.send.pipe(: t) external mapi: ((elt, int) => 'b) => typed_array<'b> = "map" - - // @bs.send.pipe(: t) external reduce: (('b, elt) => 'b, 'b) => 'b = "reduce" - // @bs.send.pipe(: t) external reducei: (('b, elt, int) => 'b, 'b) => 'b = "reduce" - - // @bs.send.pipe(: t) external reduceRight: (('b, elt) => 'b, 'b) => 'b = "reduceRight" - // @bs.send.pipe(: t) external reduceRighti: (('b, elt, int) => 'b, 'b) => 'b = "reduceRight" - - // @bs.send.pipe(: t) external some: ((elt) => bool) => bool = "some" - // @bs.send.pipe(: t) external somei: ((elt, int) => bool) => bool = "some" - - @deprecated({ - reason: "Use `Uint16Array.Constants.bytesPerElement` instead.", - migrate: Uint16Array.Constants.bytesPerElement, - }) - @val - external _BYTES_PER_ELEMENT: int = "Uint16Array.BYTES_PER_ELEMENT" - - @deprecated({ - reason: "Use `Uint16Array.fromArray` instead.", - migrate: Uint16Array.fromArray(), - }) - @new - external make: array => t = "Uint16Array" - /** can throw */ - @new - @deprecated({ - reason: "Use `Uint16Array.fromBuffer` instead.", - migrate: Uint16Array.fromBuffer(), - }) - external fromBuffer: array_buffer => t = "Uint16Array" - - /** - **throw** Js.Exn.Error throw Js exception - - **param** offset is in bytes - */ - @new - @deprecated({ - reason: "Use `Uint16Array.fromBufferToEnd` instead.", - migrate: Uint16Array.fromBufferToEnd(~byteOffset=%insert.unlabelledArgument(1)), - }) - external fromBufferOffset: (array_buffer, int) => t = "Uint16Array" - - /** - **throw** Js.Exn.Error throws Js exception - - **param** offset is in bytes, length in elements - */ - @new - @deprecated({ - reason: "Use `Uint16Array.fromBufferWithRange` instead.", - migrate: Uint16Array.fromBufferWithRange( - ~byteOffset=%insert.labelledArgument("offset"), - ~length=%insert.labelledArgument("length"), - ), - }) - external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Uint16Array" - - @deprecated({ - reason: "Use `Uint16Array.fromLength` instead.", - migrate: Uint16Array.fromLength(), - }) - @new - external fromLength: int => t = "Uint16Array" - @deprecated({ - reason: "Use `Uint16Array.fromArrayLikeOrIterable` instead.", - migrate: Uint16Array.fromArrayLikeOrIterable(), - }) - @val - external from: array_like => t = "Uint16Array.from" - /* *Array.of is redundant, use make */ -} - -module Int32Array = { - /** */ - type elt = int - type typed_array<'a> = Js_typed_array2.Int32Array.typed_array<'a> - type t = typed_array - - @get_index external unsafe_get: (t, int) => elt = "" - @set_index external unsafe_set: (t, int, elt) => unit = "" - - @get external buffer: t => array_buffer = "buffer" - @get external byteLength: t => int = "byteLength" - @get external byteOffset: t => int = "byteOffset" - - // @bs.send.pipe(: t) external setArray: array => unit = "set" - // @bs.send.pipe(: t) external setArrayOffset: (array, int) => unit = "set" - /* There's also an overload for typed arrays, but don't know how to model that without subtyping */ - - /* Array interface(-ish) */ - @deprecated({ - reason: "Use `TypedArray.length` instead.", - migrate: TypedArray.length(), - }) - @get - external length: t => int = "length" - - /* Mutator functions */ - // @bs.send.pipe(: t) external copyWithin: (~to_: int) => t = "copyWithin" - // @bs.send.pipe(: t) external copyWithinFrom: (~to_: int, ~from: int) => t = "copyWithin" - // @bs.send.pipe(: t) - @deprecated({ - reason: "Use `TypedArray.copyWithin` instead.", - migrate: TypedArray.copyWithin( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - external copyWithinFromRange: (~to_: int, ~start: int, ~end_: int) => t = "copyWithin" - - // @bs.send.pipe(: t) external fillInPlace: elt => t = "fill" - // @bs.send.pipe(: t) external fillFromInPlace: (elt, ~from: int) => t = "fill" - // @bs.send.pipe(: t) external fillRangeInPlace: (elt, ~start: int, ~end_: int) => t = "fill" - - // @bs.send.pipe(: t) external reverseInPlace: t = "reverse" - - // @bs.send.pipe(: t) external sortInPlace: t = "sort" - // @bs.send.pipe(: t) external sortInPlaceWith: ((elt, elt) => int) => t = "sort" - - /* Accessor functions */ - // @bs.send.pipe(: t) external includes: elt => bool = "includes" /* ES2016 */ - - // @bs.send.pipe(: t) external indexOf: elt => int = "indexOf" - // @bs.send.pipe(: t) external indexOfFrom: (elt, ~from: int) => int = "indexOf" - - // @bs.send.pipe(: t) external join: string = "join" - // @bs.send.pipe(: t) external joinWith: string => string = "join" - - // @bs.send.pipe(: t) external lastIndexOf: elt => int = "lastIndexOf" - // @bs.send.pipe(: t) external lastIndexOfFrom: (elt, ~from: int) => int = "lastIndexOf" - - // @bs.send.pipe(: t) /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.slice` instead.", - migrate: TypedArray.slice(~end=%insert.labelledArgument("end_")), - }) - external slice: (~start: int, ~end_: int) => t = "slice" - - // @bs.send.pipe(: t) external copy: t = "slice" - // @bs.send.pipe(: t) external sliceFrom: int => t = "slice" - - // @bs.send.pipe(: t) /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~end=%insert.labelledArgument("end_")), - }) - external subarray: (~start: int, ~end_: int) => t = "subarray" - - // @bs.send.pipe(: t) external subarrayFrom: int => t = "subarray" - - // @bs.send.pipe(: t) external toString: string = "toString" - // @bs.send.pipe(: t) external toLocaleString: string = "toLocaleString" - - /* Iteration functions */ - /* commented out until bs has a plan for iterators - external entries : (int * elt) array_iter = "" [@// @bs.send.pipe: t] - */ - // @bs.send.pipe(: t) external every: ((elt) => bool) => bool = "every" - // @bs.send.pipe(: t) external everyi: ((elt, int) => bool) => bool = "every" - - // @bs.send.pipe(: t) external filter: ((elt) => bool) => t = "filter" - // @bs.send.pipe(: t) external filteri: ((elt, int) => bool) => t = "filter" - - // @bs.send.pipe(: t) external find: ((elt) => bool) => Js.undefined = "find" - // @bs.send.pipe(: t) external findi: ((elt, int) => bool) => Js.undefined = "find" - - // @bs.send.pipe(: t) external findIndex: ((elt) => bool) => int = "findIndex" - // @bs.send.pipe(: t) external findIndexi: ((elt, int) => bool) => int = "findIndex" - - // @bs.send.pipe(: t) external forEach: ((elt) => unit) => unit = "forEach" - // @bs.send.pipe(: t) external forEachi: ((elt, int) => unit) => unit = "forEach" - - /* commented out until bs has a plan for iterators - external keys : int array_iter = "" [@// @bs.send.pipe: t] - */ - - // @bs.send.pipe(: t) external map: ((elt) => 'b) => typed_array<'b> = "map" - // @bs.send.pipe(: t) external mapi: ((elt, int) => 'b) => typed_array<'b> = "map" - - // @bs.send.pipe(: t) external reduce: (('b, elt) => 'b, 'b) => 'b = "reduce" - // @bs.send.pipe(: t) external reducei: (('b, elt, int) => 'b, 'b) => 'b = "reduce" - - // @bs.send.pipe(: t) external reduceRight: (('b, elt) => 'b, 'b) => 'b = "reduceRight" - // @bs.send.pipe(: t) external reduceRighti: (('b, elt, int) => 'b, 'b) => 'b = "reduceRight" - - // @bs.send.pipe(: t) external some: ((elt) => bool) => bool = "some" - // @bs.send.pipe(: t) external somei: ((elt, int) => bool) => bool = "some" - - @deprecated({ - reason: "Use `Int32Array.Constants.bytesPerElement` instead.", - migrate: Int32Array.Constants.bytesPerElement, - }) - @val - external _BYTES_PER_ELEMENT: int = "Int32Array.BYTES_PER_ELEMENT" - - @deprecated({ - reason: "Use `Int32Array.fromArray` instead.", - migrate: Int32Array.fromArray(), - }) - @new - external make: array => t = "Int32Array" - /** can throw */ - @new - @deprecated({ - reason: "Use `Int32Array.fromBuffer` instead.", - migrate: Int32Array.fromBuffer(), - }) - external fromBuffer: array_buffer => t = "Int32Array" - - /** - **throw** Js.Exn.Error throw Js exception - - **param** offset is in bytes - */ - @new - @deprecated({ - reason: "Use `Int32Array.fromBufferToEnd", - migrate: Int32Array.fromBufferToEnd(~byteOffset=%insert.unlabelledArgument(1)), - }) - external fromBufferOffset: (array_buffer, int) => t = "Int32Array" - - /** - **throw** Js.Exn.Error throws Js exception - - **param** offset is in bytes, length in elements - */ - @new - @deprecated({ - reason: "Use `Int32Array.fromBufferWithRange` instead.", - migrate: Int32Array.fromBufferWithRange( - ~byteOffset=%insert.labelledArgument("offset"), - ~length=%insert.labelledArgument("length"), - ), - }) - external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Int32Array" - - @deprecated({ - reason: "Use `Int32Array.fromLength` instead.", - migrate: Int32Array.fromLength(), - }) - @new - external fromLength: int => t = "Int32Array" - @deprecated({ - reason: "Use `Int32Array.fromArrayLikeOrIterable` instead.", - migrate: Int32Array.fromArrayLikeOrIterable(), - }) - @val - external from: array_like => t = "Int32Array.from" - /* *Array.of is redundant, use make */ - @new @deprecated("use `make` instead") external create: array => t = "Int32Array" - @new @deprecated("use `fromBuffer` instead") external of_buffer: array_buffer => t = "Int32Array" -} -module Int32_array = Int32Array - -module Uint32Array = { - /** */ - type elt = int - type typed_array<'a> = Js_typed_array2.Uint32Array.typed_array<'a> - type t = typed_array - - @get_index external unsafe_get: (t, int) => elt = "" - @set_index external unsafe_set: (t, int, elt) => unit = "" - - @get external buffer: t => array_buffer = "buffer" - @get external byteLength: t => int = "byteLength" - @get external byteOffset: t => int = "byteOffset" - - // @bs.send.pipe(: t) external setArray: array => unit = "set" - // @bs.send.pipe(: t) external setArrayOffset: (array, int) => unit = "set" - /* There's also an overload for typed arrays, but don't know how to model that without subtyping */ - - /* Array interface(-ish) */ - @deprecated({ - reason: "Use `TypedArray.length` instead.", - migrate: TypedArray.length(), - }) - @get - external length: t => int = "length" - - /* Mutator functions */ - // @bs.send.pipe(: t) external copyWithin: (~to_: int) => t = "copyWithin" - // @bs.send.pipe(: t) external copyWithinFrom: (~to_: int, ~from: int) => t = "copyWithin" - // @bs.send.pipe(: t) - @deprecated({ - reason: "Use `TypedArray.copyWithin` instead.", - migrate: TypedArray.copyWithin( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - external copyWithinFromRange: (~to_: int, ~start: int, ~end_: int) => t = "copyWithin" - - // @bs.send.pipe(: t) external fillInPlace: elt => t = "fill" - // @bs.send.pipe(: t) external fillFromInPlace: (elt, ~from: int) => t = "fill" - // @bs.send.pipe(: t) external fillRangeInPlace: (elt, ~start: int, ~end_: int) => t = "fill" - - // @bs.send.pipe(: t) external reverseInPlace: t = "reverse" - - // @bs.send.pipe(: t) external sortInPlace: t = "sort" - // @bs.send.pipe(: t) external sortInPlaceWith: ((elt, elt) => int) => t = "sort" - - /* Accessor functions */ - // @bs.send.pipe(: t) external includes: elt => bool = "includes" /* ES2016 */ - - // @bs.send.pipe(: t) external indexOf: elt => int = "indexOf" - // @bs.send.pipe(: t) external indexOfFrom: (elt, ~from: int) => int = "indexOf" - - // @bs.send.pipe(: t) external join: string = "join" - // @bs.send.pipe(: t) external joinWith: string => string = "join" - - // @bs.send.pipe(: t) external lastIndexOf: elt => int = "lastIndexOf" - // @bs.send.pipe(: t) external lastIndexOfFrom: (elt, ~from: int) => int = "lastIndexOf" - - // @bs.send.pipe(: t) /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.slice` instead.", - migrate: TypedArray.slice(~end=%insert.labelledArgument("end_")), - }) - external slice: (~start: int, ~end_: int) => t = "slice" - - // @bs.send.pipe(: t) external copy: t = "slice" - // @bs.send.pipe(: t) external sliceFrom: int => t = "slice" - - // @bs.send.pipe(: t) /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~end=%insert.labelledArgument("end_")), - }) - external subarray: (~start: int, ~end_: int) => t = "subarray" - - // @bs.send.pipe(: t) external subarrayFrom: int => t = "subarray" - - // @bs.send.pipe(: t) external toString: string = "toString" - // @bs.send.pipe(: t) external toLocaleString: string = "toLocaleString" - - /* Iteration functions */ - /* commented out until bs has a plan for iterators - external entries : (int * elt) array_iter = "" [@// @bs.send.pipe: t] - */ - // @bs.send.pipe(: t) external every: ((elt) => bool) => bool = "every" - // @bs.send.pipe(: t) external everyi: ((elt, int) => bool) => bool = "every" - - // @bs.send.pipe(: t) external filter: ((elt) => bool) => t = "filter" - // @bs.send.pipe(: t) external filteri: ((elt, int) => bool) => t = "filter" - - // @bs.send.pipe(: t) external find: ((elt) => bool) => Js.undefined = "find" - // @bs.send.pipe(: t) external findi: ((elt, int) => bool) => Js.undefined = "find" - - // @bs.send.pipe(: t) external findIndex: ((elt) => bool) => int = "findIndex" - // @bs.send.pipe(: t) external findIndexi: ((elt, int) => bool) => int = "findIndex" - - // @bs.send.pipe(: t) external forEach: ((elt) => unit) => unit = "forEach" - // @bs.send.pipe(: t) external forEachi: ((elt, int) => unit) => unit = "forEach" - - /* commented out until bs has a plan for iterators - external keys : int array_iter = "" [@// @bs.send.pipe: t] - */ - - // @bs.send.pipe(: t) external map: ((elt) => 'b) => typed_array<'b> = "map" - // @bs.send.pipe(: t) external mapi: ((elt, int) => 'b) => typed_array<'b> = "map" - - // @bs.send.pipe(: t) external reduce: (('b, elt) => 'b, 'b) => 'b = "reduce" - // @bs.send.pipe(: t) external reducei: (('b, elt, int) => 'b, 'b) => 'b = "reduce" - - // @bs.send.pipe(: t) external reduceRight: (('b, elt) => 'b, 'b) => 'b = "reduceRight" - // @bs.send.pipe(: t) external reduceRighti: (('b, elt, int) => 'b, 'b) => 'b = "reduceRight" - - // @bs.send.pipe(: t) external some: ((elt) => bool) => bool = "some" - // @bs.send.pipe(: t) external somei: ((elt, int) => bool) => bool = "some" - - @deprecated({ - reason: "Use `Uint32Array.Constants.bytesPerElement` instead.", - migrate: Uint32Array.Constants.bytesPerElement, - }) - @val - external _BYTES_PER_ELEMENT: int = "Uint32Array.BYTES_PER_ELEMENT" - - @deprecated({ - reason: "Use `Uint32Array.fromArray` instead.", - migrate: Uint32Array.fromArray(), - }) - @new - external make: array => t = "Uint32Array" - /** can throw */ - @new - @deprecated({ - reason: "Use `Uint32Array.fromBuffer` instead.", - migrate: Uint32Array.fromBuffer(), - }) - external fromBuffer: array_buffer => t = "Uint32Array" - - /** - **throw** Js.Exn.Error throw Js exception - - **param** offset is in bytes - */ - @new - @deprecated({ - reason: "Use `Uint32Array.fromBufferToEnd` instead.", - migrate: Uint32Array.fromBufferToEnd(~byteOffset=%insert.unlabelledArgument(1)), - }) - external fromBufferOffset: (array_buffer, int) => t = "Uint32Array" - - /** - **throw** Js.Exn.Error throws Js exception - - **param** offset is in bytes, length in elements - */ - @new - @deprecated({ - reason: "Use `Uint32Array.fromBufferWithRange` instead.", - migrate: Uint32Array.fromBufferWithRange( - ~byteOffset=%insert.labelledArgument("offset"), - ~length=%insert.labelledArgument("length"), - ), - }) - external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Uint32Array" - - @deprecated({ - reason: "Use `Uint32Array.fromLength` instead.", - migrate: Uint32Array.fromLength(), - }) - @new - external fromLength: int => t = "Uint32Array" - @deprecated({ - reason: "Use `Uint32Array.fromArrayLikeOrIterable` instead.", - migrate: Uint32Array.fromArrayLikeOrIterable(), - }) - @val - external from: array_like => t = "Uint32Array.from" - /* *Array.of is redundant, use make */ -} - -/* - it still return number, `float` in this case -*/ -module Float32Array = { - /** */ - type elt = float - type typed_array<'a> = Js_typed_array2.Float32Array.typed_array<'a> - type t = typed_array - - @get_index external unsafe_get: (t, int) => elt = "" - @set_index external unsafe_set: (t, int, elt) => unit = "" - - @get external buffer: t => array_buffer = "buffer" - @get external byteLength: t => int = "byteLength" - @get external byteOffset: t => int = "byteOffset" - - // @bs.send.pipe(: t) external setArray: array => unit = "set" - // @bs.send.pipe(: t) external setArrayOffset: (array, int) => unit = "set" - /* There's also an overload for typed arrays, but don't know how to model that without subtyping */ - - /* Array interface(-ish) */ - @deprecated({ - reason: "Use `TypedArray.length` instead.", - migrate: TypedArray.length(), - }) - @get - external length: t => int = "length" - - /* Mutator functions */ - // @bs.send.pipe(: t) external copyWithin: (~to_: int) => t = "copyWithin" - // @bs.send.pipe(: t) external copyWithinFrom: (~to_: int, ~from: int) => t = "copyWithin" - // @bs.send.pipe(: t) - @deprecated({ - reason: "Use `TypedArray.copyWithin` instead.", - migrate: TypedArray.copyWithin( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - external copyWithinFromRange: (~to_: int, ~start: int, ~end_: int) => t = "copyWithin" - - // @bs.send.pipe(: t) external fillInPlace: elt => t = "fill" - // @bs.send.pipe(: t) external fillFromInPlace: (elt, ~from: int) => t = "fill" - // @bs.send.pipe(: t) external fillRangeInPlace: (elt, ~start: int, ~end_: int) => t = "fill" - - // @bs.send.pipe(: t) external reverseInPlace: t = "reverse" - - // @bs.send.pipe(: t) external sortInPlace: t = "sort" - // @bs.send.pipe(: t) external sortInPlaceWith: ((elt, elt) => int) => t = "sort" - - /* Accessor functions */ - // @bs.send.pipe(: t) external includes: elt => bool = "includes" /* ES2016 */ - - // @bs.send.pipe(: t) external indexOf: elt => int = "indexOf" - // @bs.send.pipe(: t) external indexOfFrom: (elt, ~from: int) => int = "indexOf" - - // @bs.send.pipe(: t) external join: string = "join" - // @bs.send.pipe(: t) external joinWith: string => string = "join" - - // @bs.send.pipe(: t) external lastIndexOf: elt => int = "lastIndexOf" - // @bs.send.pipe(: t) external lastIndexOfFrom: (elt, ~from: int) => int = "lastIndexOf" - - // @bs.send.pipe(: t) /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.slice` instead.", - migrate: TypedArray.slice(~end=%insert.labelledArgument("end_")), - }) - external slice: (~start: int, ~end_: int) => t = "slice" - - // @bs.send.pipe(: t) external copy: t = "slice" - // @bs.send.pipe(: t) external sliceFrom: int => t = "slice" - - // @bs.send.pipe(: t) /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~end=%insert.labelledArgument("end_")), - }) - external subarray: (~start: int, ~end_: int) => t = "subarray" - - // @bs.send.pipe(: t) external subarrayFrom: int => t = "subarray" - - // @bs.send.pipe(: t) external toString: string = "toString" - // @bs.send.pipe(: t) external toLocaleString: string = "toLocaleString" - - /* Iteration functions */ - /* commented out until bs has a plan for iterators - external entries : (int * elt) array_iter = "" [@// @bs.send.pipe: t] - */ - // @bs.send.pipe(: t) external every: ((elt) => bool) => bool = "every" - // @bs.send.pipe(: t) external everyi: ((elt, int) => bool) => bool = "every" - - // @bs.send.pipe(: t) external filter: ((elt) => bool) => t = "filter" - // @bs.send.pipe(: t) external filteri: ((elt, int) => bool) => t = "filter" - - // @bs.send.pipe(: t) external find: ((elt) => bool) => Js.undefined = "find" - // @bs.send.pipe(: t) external findi: ((elt, int) => bool) => Js.undefined = "find" - - // @bs.send.pipe(: t) external findIndex: ((elt) => bool) => int = "findIndex" - // @bs.send.pipe(: t) external findIndexi: ((elt, int) => bool) => int = "findIndex" - - // @bs.send.pipe(: t) external forEach: ((elt) => unit) => unit = "forEach" - // @bs.send.pipe(: t) external forEachi: ((elt, int) => unit) => unit = "forEach" - - /* commented out until bs has a plan for iterators - external keys : int array_iter = "" [@// @bs.send.pipe: t] - */ - - // @bs.send.pipe(: t) external map: ((elt) => 'b) => typed_array<'b> = "map" - // @bs.send.pipe(: t) external mapi: ((elt, int) => 'b) => typed_array<'b> = "map" - - // @bs.send.pipe(: t) external reduce: (('b, elt) => 'b, 'b) => 'b = "reduce" - // @bs.send.pipe(: t) external reducei: (('b, elt, int) => 'b, 'b) => 'b = "reduce" - - // @bs.send.pipe(: t) external reduceRight: (('b, elt) => 'b, 'b) => 'b = "reduceRight" - // @bs.send.pipe(: t) external reduceRighti: (('b, elt, int) => 'b, 'b) => 'b = "reduceRight" - - // @bs.send.pipe(: t) external some: ((elt) => bool) => bool = "some" - // @bs.send.pipe(: t) external somei: ((elt, int) => bool) => bool = "some" - - @deprecated({ - reason: "Use `Float32Array.Constants.bytesPerElement` instead.", - migrate: Float32Array.Constants.bytesPerElement, - }) - @val - external _BYTES_PER_ELEMENT: int = "Float32Array.BYTES_PER_ELEMENT" - - @deprecated({ - reason: "Use `Float32Array.fromArray` instead.", - migrate: Float32Array.fromArray(), - }) - @new - external make: array => t = "Float32Array" - /** can throw */ - @new - @deprecated({ - reason: "Use `Float32Array.fromBuffer` instead.", - migrate: Float32Array.fromBuffer(), - }) - external fromBuffer: array_buffer => t = "Float32Array" - - /** - **throw** Js.Exn.Error throw Js exception - - **param** offset is in bytes - */ - @new - @deprecated({ - reason: "Use `Float32Array.fromBufferToEnd` instead.", - migrate: Float32Array.fromBufferToEnd(~byteOffset=%insert.unlabelledArgument(1)), - }) - external fromBufferOffset: (array_buffer, int) => t = "Float32Array" - - /** - **throw** Js.Exn.Error throws Js exception - - **param** offset is in bytes, length in elements - */ - @new - @deprecated({ - reason: "Use `Float32Array.fromBufferWithRange` instead.", - migrate: Float32Array.fromBufferWithRange( - ~byteOffset=%insert.labelledArgument("offset"), - ~length=%insert.labelledArgument("length"), - ), - }) - external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Float32Array" - - @deprecated({ - reason: "Use `Float32Array.fromLength` instead.", - migrate: Float32Array.fromLength(), - }) - @new - external fromLength: int => t = "Float32Array" - @deprecated({ - reason: "Use `Float32Array.fromArrayLikeOrIterable` instead.", - migrate: Float32Array.fromArrayLikeOrIterable(), - }) - @val - external from: array_like => t = "Float32Array.from" - /* *Array.of is redundant, use make */ - @new @deprecated("use `make` instead") external create: array => t = "Float32Array" - @new @deprecated("use `fromBuffer` instead") - external of_buffer: array_buffer => t = "Float32Array" -} -module Float32_array = Float32Array - -module Float64Array = { - /** */ - type elt = float - type typed_array<'a> = Js_typed_array2.Float64Array.typed_array<'a> - type t = typed_array - - @get_index external unsafe_get: (t, int) => elt = "" - @set_index external unsafe_set: (t, int, elt) => unit = "" - - @get external buffer: t => array_buffer = "buffer" - @get external byteLength: t => int = "byteLength" - @get external byteOffset: t => int = "byteOffset" - - // @bs.send.pipe(: t) external setArray: array => unit = "set" - // @bs.send.pipe(: t) external setArrayOffset: (array, int) => unit = "set" - /* There's also an overload for typed arrays, but don't know how to model that without subtyping */ - - /* Array interface(-ish) */ - @deprecated({ - reason: "Use `TypedArray.length` instead.", - migrate: TypedArray.length(), - }) - @get - external length: t => int = "length" - - /* Mutator functions */ - // @bs.send.pipe(: t) external copyWithin: (~to_: int) => t = "copyWithin" - // @bs.send.pipe(: t) external copyWithinFrom: (~to_: int, ~from: int) => t = "copyWithin" - // @bs.send.pipe(: t) - @deprecated({ - reason: "Use `TypedArray.copyWithin` instead.", - migrate: TypedArray.copyWithin( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - external copyWithinFromRange: (~to_: int, ~start: int, ~end_: int) => t = "copyWithin" - - // @bs.send.pipe(: t) external fillInPlace: elt => t = "fill" - // @bs.send.pipe(: t) external fillFromInPlace: (elt, ~from: int) => t = "fill" - // @bs.send.pipe(: t) external fillRangeInPlace: (elt, ~start: int, ~end_: int) => t = "fill" - - // @bs.send.pipe(: t) external reverseInPlace: t = "reverse" - - // @bs.send.pipe(: t) external sortInPlace: t = "sort" - // @bs.send.pipe(: t) external sortInPlaceWith: ((elt, elt) => int) => t = "sort" - - /* Accessor functions */ - // @bs.send.pipe(: t) external includes: elt => bool = "includes" /* ES2016 */ - - // @bs.send.pipe(: t) external indexOf: elt => int = "indexOf" - // @bs.send.pipe(: t) external indexOfFrom: (elt, ~from: int) => int = "indexOf" - - // @bs.send.pipe(: t) external join: string = "join" - // @bs.send.pipe(: t) external joinWith: string => string = "join" - - // @bs.send.pipe(: t) external lastIndexOf: elt => int = "lastIndexOf" - // @bs.send.pipe(: t) external lastIndexOfFrom: (elt, ~from: int) => int = "lastIndexOf" - - // @bs.send.pipe(: t) /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.slice` instead.", - migrate: TypedArray.slice(~end=%insert.labelledArgument("end_")), - }) - external slice: (~start: int, ~end_: int) => t = "slice" - - // @bs.send.pipe(: t) external copy: t = "slice" - // @bs.send.pipe(: t) external sliceFrom: int => t = "slice" - - // @bs.send.pipe(: t) /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~end=%insert.labelledArgument("end_")), - }) - external subarray: (~start: int, ~end_: int) => t = "subarray" - - // @bs.send.pipe(: t) external subarrayFrom: int => t = "subarray" - - // @bs.send.pipe(: t) external toString: string = "toString" - // @bs.send.pipe(: t) external toLocaleString: string = "toLocaleString" - - /* Iteration functions */ - /* commented out until bs has a plan for iterators - external entries : (int * elt) array_iter = "" [@// @bs.send.pipe: t] - */ - // @bs.send.pipe(: t) external every: ((elt) => bool) => bool = "every" - // @bs.send.pipe(: t) external everyi: ((elt, int) => bool) => bool = "every" - - // @bs.send.pipe(: t) external filter: ((elt) => bool) => t = "filter" - // @bs.send.pipe(: t) external filteri: ((elt, int) => bool) => t = "filter" - - // @bs.send.pipe(: t) external find: ((elt) => bool) => Js.undefined = "find" - // @bs.send.pipe(: t) external findi: ((elt, int) => bool) => Js.undefined = "find" - - // @bs.send.pipe(: t) external findIndex: ((elt) => bool) => int = "findIndex" - // @bs.send.pipe(: t) external findIndexi: ((elt, int) => bool) => int = "findIndex" - - // @bs.send.pipe(: t) external forEach: ((elt) => unit) => unit = "forEach" - // @bs.send.pipe(: t) external forEachi: ((elt, int) => unit) => unit = "forEach" - - /* commented out until bs has a plan for iterators - external keys : int array_iter = "" [@// @bs.send.pipe: t] - */ - - // @bs.send.pipe(: t) external map: ((elt) => 'b) => typed_array<'b> = "map" - // @bs.send.pipe(: t) external mapi: ((elt, int) => 'b) => typed_array<'b> = "map" - - // @bs.send.pipe(: t) external reduce: (('b, elt) => 'b, 'b) => 'b = "reduce" - // @bs.send.pipe(: t) external reducei: (('b, elt, int) => 'b, 'b) => 'b = "reduce" - - // @bs.send.pipe(: t) external reduceRight: (('b, elt) => 'b, 'b) => 'b = "reduceRight" - // @bs.send.pipe(: t) external reduceRighti: (('b, elt, int) => 'b, 'b) => 'b = "reduceRight" - - // @bs.send.pipe(: t) external some: ((elt) => bool) => bool = "some" - // @bs.send.pipe(: t) external somei: ((elt, int) => bool) => bool = "some" - - @deprecated({ - reason: "Use `Float64Array.Constants.bytesPerElement` instead.", - migrate: Float64Array.Constants.bytesPerElement, - }) - @val - external _BYTES_PER_ELEMENT: int = "Float64Array.BYTES_PER_ELEMENT" - - @deprecated({ - reason: "Use `Float64Array.fromArray` instead.", - migrate: Float64Array.fromArray(), - }) - @new - external make: array => t = "Float64Array" - /** can throw */ - @new - @deprecated({ - reason: "Use `Float64Array.fromBuffer` instead.", - migrate: Float64Array.fromBuffer(), - }) - external fromBuffer: array_buffer => t = "Float64Array" - - /** - **throw** Js.Exn.Error throw Js exception - - **param** offset is in bytes - */ - @new - @deprecated({ - reason: "Use `Float64Array.fromBufferToEnd` instead.", - migrate: Float64Array.fromBufferToEnd(~byteOffset=%insert.unlabelledArgument(1)), - }) - external fromBufferOffset: (array_buffer, int) => t = "Float64Array" - - /** - **throw** Js.Exn.Error throws Js exception - - **param** offset is in bytes, length in elements - */ - @new - @deprecated({ - reason: "Use `Float64Array.fromBufferWithRange` instead.", - migrate: Float64Array.fromBufferWithRange( - ~byteOffset=%insert.labelledArgument("offset"), - ~length=%insert.labelledArgument("length"), - ), - }) - external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Float64Array" - - @deprecated({ - reason: "Use `Float64Array.fromLength` instead.", - migrate: Float64Array.fromLength(), - }) - @new - external fromLength: int => t = "Float64Array" - @deprecated({ - reason: "Use `Float64Array.fromArrayLikeOrIterable` instead.", - migrate: Float64Array.fromArrayLikeOrIterable(), - }) - @val - external from: array_like => t = "Float64Array.from" - /* *Array.of is redundant, use make */ - @new @deprecated("use `make` instead") external create: array => t = "Float64Array" - @new @deprecated("use `fromBuffer` instead") - external of_buffer: array_buffer => t = "Float64Array" -} -module Float64_array = Float64Array - -/** -The DataView view provides a low-level interface for reading and writing -multiple number types in an ArrayBuffer irrespective of the platform's endianness. - -**see** [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView) -*/ -module DataView = { - type t = Js_typed_array2.DataView.t - - @new external make: array_buffer => t = "DataView" - @new external fromBuffer: array_buffer => t = "DataView" - @new external fromBufferOffset: (array_buffer, int) => t = "DataView" - @new external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "DataView" - - @get external buffer: t => array_buffer = "buffer" - @get external byteLength: t => int = "byteLength" - @get external byteOffset: t => int = "byteOffset" - - @send external getInt8: (t, int) => int = "getInt8" - @send external getUint8: (t, int) => int = "getUint8" - - @send external getInt16: (t, int) => int = "getInt16" - @send external getInt16LittleEndian: (t, int, @as(1) _) => int = "getInt16" - - @send external getUint16: (t, int) => int = "getUint16" - @send external getUint16LittleEndian: (t, int, @as(1) _) => int = "getUint16" - - @send external getInt32: (t, int) => int = "getInt32" - @send external getInt32LittleEndian: (t, int, @as(1) _) => int = "getInt32" - - @send external getUint32: (t, int) => int = "getUint32" - @send external getUint32LittleEndian: (t, int, @as(1) _) => int = "getUint32" - - @send external getFloat32: (t, int) => float = "getFloat32" - @send external getFloat32LittleEndian: (t, int, @as(1) _) => float = "getFloat32" - - @send external getFloat64: (t, int) => float = "getFloat64" - @send external getFloat64LittleEndian: (t, int, @as(1) _) => float = "getFloat64" - - @send external setInt8: (t, int, int) => unit = "setInt8" - @send external setUint8: (t, int, int) => unit = "setUint8" - - @send external setInt16: (t, int, int) => unit = "setInt16" - @send external setInt16LittleEndian: (t, int, int, @as(1) _) => unit = "setInt16" - - @send external setUint16: (t, int, int) => unit = "setUint16" - @send external setUint16LittleEndian: (t, int, int, @as(1) _) => unit = "setUint16" - - @send external setInt32: (t, int, int) => unit = "setInt32" - @send external setInt32LittleEndian: (t, int, int, @as(1) _) => unit = "setInt32" - - @send external setUint32: (t, int, int) => unit = "setUint32" - @send external setUint32LittleEndian: (t, int, int, @as(1) _) => unit = "setUint32" - - @send external setFloat32: (t, int, float) => unit = "setFloat32" - @send external setFloat32LittleEndian: (t, int, float, @as(1) _) => unit = "setFloat32" - - @send external setFloat64: (t, int, float) => unit = "setFloat64" - @send external setFloat64LittleEndian: (t, int, float, @as(1) _) => unit = "setFloat64" -} diff --git a/packages/@rescript/runtime/Js_typed_array2.res b/packages/@rescript/runtime/Js_typed_array2.res deleted file mode 100644 index 498092edd11..00000000000 --- a/packages/@rescript/runtime/Js_typed_array2.res +++ /dev/null @@ -1,2941 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** -JavaScript Typed Array API - -**see** [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) -*/ - -type array_buffer = Stdlib_ArrayBuffer.t -type array_like<'a> /* should be shared with js_array */ - -module ArrayBuffer = { - /*** - The underlying buffer that the typed arrays provide views of - - **see** [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) - */ - - type t = array_buffer - - /** takes length. initializes elements to 0 */ - @new - external make: int => t = "ArrayBuffer" - - /* ArrayBuffer.isView: seems pointless with a type system */ - /* experimental - external transfer : array_buffer -> t = "ArrayBuffer.transfer" [@@val] - external transferWithLength : array_buffer -> int -> t = "ArrayBuffer.transfer" [@@val] - */ - - @get external byteLength: t => int = "byteLength" - - @deprecated({ - reason: "Use `ArrayBuffer.slice` instead.", - migrate: ArrayBuffer.slice(~end=%insert.labelledArgument("end_")), - }) - @send - external slice: (t, ~start: int, ~end_: int) => array_buffer = "slice" - @deprecated({ - reason: "Use `ArrayBuffer.sliceToEnd` instead.", - migrate: ArrayBuffer.sliceToEnd(~start=%insert.unlabelledArgument(1)), - }) - @send - external sliceFrom: (t, int) => array_buffer = "slice" -} - -/* commented out until bs has a plan for iterators - external values : t -> elt array_iter = "" [@@send] - */ - -module Int8Array = { - /** */ - type elt = int - type typed_array<'a> - type t = typed_array - - @get_index external unsafe_get: (t, int) => elt = "" - @set_index external unsafe_set: (t, int, elt) => unit = "" - - @get external buffer: t => array_buffer = "buffer" - @get external byteLength: t => int = "byteLength" - @get external byteOffset: t => int = "byteOffset" - - @deprecated({ - reason: "Use `TypedArray.setArray` instead.", - migrate: TypedArray.setArray(), - }) - @send - external setArray: (t, array) => unit = "set" - @deprecated({ - reason: "Use `TypedArray.setArrayFrom` instead.", - migrate: TypedArray.setArrayFrom(%insert.unlabelledArgument(2)), - }) - @send - external setArrayOffset: (t, array, int) => unit = "set" - /* There's also an overload for typed arrays, but don't know how to model that without subtyping */ - - /* Array interface(-ish) */ - @deprecated({ - reason: "Use `TypedArray.length` instead.", - migrate: TypedArray.length(), - }) - @get - external length: t => int = "length" - - /* Mutator functions */ - @deprecated({ - reason: "Use `TypedArray.copyAllWithin` instead.", - migrate: TypedArray.copyAllWithin(~target=%insert.labelledArgument("to_")), - }) - @send - external copyWithin: (t, ~to_: int) => t = "copyWithin" - @deprecated({ - reason: "Use `TypedArray.copyWithinToEnd` instead.", - migrate: TypedArray.copyWithinToEnd( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("from"), - ), - }) - @send - external copyWithinFrom: (t, ~to_: int, ~from: int) => t = "copyWithin" - @deprecated({ - reason: "Use `TypedArray.copyWithin` instead.", - migrate: TypedArray.copyWithin( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - @send - external copyWithinFromRange: (t, ~to_: int, ~start: int, ~end_: int) => t = "copyWithin" - - @deprecated({ - reason: "Use `TypedArray.fillAll` instead.", - migrate: TypedArray.fillAll(), - }) - @send - external fillInPlace: (t, elt) => t = "fill" - @deprecated({ - reason: "Use `TypedArray.fillToEnd` instead.", - migrate: TypedArray.fillToEnd(~start=%insert.labelledArgument("from")), - }) - @send - external fillFromInPlace: (t, elt, ~from: int) => t = "fill" - @deprecated({ - reason: "Use `TypedArray.fill` instead.", - migrate: TypedArray.fill( - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - @send - external fillRangeInPlace: (t, elt, ~start: int, ~end_: int) => t = "fill" - - @deprecated({ - reason: "Use `TypedArray.reverse` instead.", - migrate: TypedArray.reverse(), - }) - @send - external reverseInPlace: t => t = "reverse" - - @deprecated({ - reason: "Use `TypedArray.toSorted` instead.", - migrate: TypedArray.toSorted((a, b) => - %todo_("This needs a comparator function. Use `Int.compare` for ints, etc.") - ), - }) - @send - external sortInPlace: t => t = "sort" - @deprecated({ - reason: "Use `TypedArray.sort` instead.", - migrate: TypedArray.sort(), - }) - @deprecated({ - reason: "Use `TypedArray.sort` instead.", - migrate: TypedArray.sort(), - }) - @send - external sortInPlaceWith: (t, (elt, elt) => int) => t = "sort" - - /* Accessor functions */ - @deprecated({ - reason: "Use `TypedArray.includes` instead.", - migrate: TypedArray.includes(), - }) - @send - external includes: (t, elt) => bool = "includes" /* ES2016 */ - - @deprecated({ - reason: "Use `TypedArray.indexOf` instead.", - migrate: TypedArray.indexOf(), - }) - @send - external indexOf: (t, elt) => int = "indexOf" - @deprecated({ - reason: "Use `TypedArray.indexOfFrom` instead.", - migrate: TypedArray.indexOfFrom(%insert.labelledArgument("from")), - }) - @send - external indexOfFrom: (t, elt, ~from: int) => int = "indexOf" - - @deprecated({ - reason: "Use `TypedArray.joinWith` instead.", - migrate: TypedArray.joinWith(","), - }) - @send - external join: t => string = "join" - @deprecated({ - reason: "Use `TypedArray.joinWith` instead.", - migrate: TypedArray.joinWith(), - }) - @send - external joinWith: (t, string) => string = "join" - - @deprecated({ - reason: "Use `TypedArray.lastIndexOf` instead.", - migrate: TypedArray.lastIndexOf(), - }) - @send - external lastIndexOf: (t, elt) => int = "lastIndexOf" - @deprecated({ - reason: "Use `TypedArray.lastIndexOfFrom` instead.", - migrate: TypedArray.lastIndexOfFrom(%insert.labelledArgument("from")), - }) - @send - external lastIndexOfFrom: (t, elt, ~from: int) => int = "lastIndexOf" - - /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.slice` instead.", - migrate: TypedArray.slice(~end=%insert.labelledArgument("end_")), - }) - @send - external slice: (t, ~start: int, ~end_: int) => t = "slice" - - @deprecated({ - reason: "Use `TypedArray.copy` instead.", - migrate: TypedArray.copy(), - }) - @send - external copy: t => t = "slice" - @deprecated({ - reason: "Use `TypedArray.sliceToEnd` instead.", - migrate: TypedArray.sliceToEnd(~start=%insert.unlabelledArgument(1)), - }) - @send - external sliceFrom: (t, int) => t = "slice" - - /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~end=%insert.labelledArgument("end_")), - }) - @send - external subarray: (t, ~start: int, ~end_: int) => t = "subarray" - - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~start=%insert.unlabelledArgument(1)), - }) - @send - external subarrayFrom: (t, int) => t = "subarray" - - @deprecated({ - reason: "Use `TypedArray.toString` instead.", - migrate: TypedArray.toString(), - }) - @send - external toString: t => string = "toString" - @deprecated({ - reason: "Use `TypedArray.toLocaleString` instead.", - migrate: TypedArray.toLocaleString(), - }) - @send - external toLocaleString: t => string = "toLocaleString" - - /* Iteration functions */ - /* commented out until bs has a plan for iterators - external entries : t -> (int * elt) array_iter = "" [@@send] - */ - @deprecated({ - reason: "Use `TypedArray.every` instead.", - migrate: TypedArray.every(), - }) - @send - external every: (t, elt => bool) => bool = "every" - @deprecated({ - reason: "Use `TypedArray.everyWithIndex` instead.", - migrate: TypedArray.everyWithIndex(), - }) - @send - external everyi: (t, (elt, int) => bool) => bool = "every" - - @deprecated({ - reason: "Use `TypedArray.filter` instead.", - migrate: TypedArray.filter(), - }) - @send - external filter: (t, elt => bool) => t = "filter" - @deprecated({ - reason: "Use `TypedArray.filterWithIndex` instead.", - migrate: TypedArray.filterWithIndex(), - }) - @send - external filteri: (t, (elt, int) => bool) => t = "filter" - - @deprecated({ - reason: "Use `TypedArray.find` instead.", - migrate: TypedArray.find(), - }) - @send - external find: (t, elt => bool) => Js_undefined.t = "find" - @deprecated({ - reason: "Use `TypedArray.findWithIndex` instead.", - migrate: TypedArray.findWithIndex(), - }) - @send - external findi: (t, (elt, int) => bool) => Js_undefined.t = "find" - - @deprecated({ - reason: "Use `TypedArray.findIndex` instead.", - migrate: TypedArray.findIndex(), - }) - @send - external findIndex: (t, elt => bool) => int = "findIndex" - @deprecated({ - reason: "Use `TypedArray.findIndexWithIndex` instead.", - migrate: TypedArray.findIndexWithIndex(), - }) - @send - external findIndexi: (t, (elt, int) => bool) => int = "findIndex" - - @deprecated({ - reason: "Use `TypedArray.forEach` instead.", - migrate: TypedArray.forEach(), - }) - @send - external forEach: (t, elt => unit) => unit = "forEach" - @deprecated({ - reason: "Use `TypedArray.forEachWithIndex` instead.", - migrate: TypedArray.forEachWithIndex(), - }) - @send - external forEachi: (t, (elt, int) => unit) => unit = "forEach" - - /* commented out until bs has a plan for iterators - external keys : t -> int array_iter = "" [@@send] - */ - - @deprecated({ - reason: "Use `TypedArray.map` instead.", - migrate: TypedArray.map(), - }) - @send - external map: (t, elt => 'b) => typed_array<'b> = "map" - @deprecated({ - reason: "Use `TypedArray.mapWithIndex` instead.", - migrate: TypedArray.mapWithIndex(), - }) - @send - external mapi: (t, (elt, int) => 'b) => typed_array<'b> = "map" - - @deprecated({ - reason: "Use `TypedArray.reduce` instead.", - migrate: TypedArray.reduce(), - }) - @send - external reduce: (t, ('b, elt) => 'b, 'b) => 'b = "reduce" - @deprecated({ - reason: "Use `TypedArray.reduceWithIndex` instead.", - migrate: TypedArray.reduceWithIndex(), - }) - @send - external reducei: (t, ('b, elt, int) => 'b, 'b) => 'b = "reduce" - - @deprecated({ - reason: "Use `TypedArray.reduceRight` instead.", - migrate: TypedArray.reduceRight(), - }) - @send - external reduceRight: (t, ('b, elt) => 'b, 'b) => 'b = "reduceRight" - @deprecated({ - reason: "Use `TypedArray.reduceRightWithIndex` instead.", - migrate: TypedArray.reduceRightWithIndex(), - }) - @send - external reduceRighti: (t, ('b, elt, int) => 'b, 'b) => 'b = "reduceRight" - - @deprecated({ - reason: "Use `TypedArray.some` instead.", - migrate: TypedArray.some(), - }) - @send - external some: (t, elt => bool) => bool = "some" - @deprecated({ - reason: "Use `TypedArray.someWithIndex` instead.", - migrate: TypedArray.someWithIndex(), - }) - @send - external somei: (t, (elt, int) => bool) => bool = "some" - - @deprecated({ - reason: "Use `Int8Array.Constants.bytesPerElement` instead.", - migrate: Int8Array.Constants.bytesPerElement, - }) - @val - external _BYTES_PER_ELEMENT: int = "Int8Array.BYTES_PER_ELEMENT" - - @deprecated({ - reason: "Use `Int8Array.fromArray` instead.", - migrate: Int8Array.fromArray(), - }) - @new - external make: array => t = "Int8Array" - /** can throw */ - @new - external fromBuffer: array_buffer => t = "Int8Array" - - /** - **throw** Js.Exn.Error throw Js exception - - **param** offset is in bytes - */ - @deprecated({ - reason: "Use `Int8Array.fromBufferToEnd` instead.", - migrate: Int8Array.fromBufferToEnd(~byteOffset=%insert.unlabelledArgument(1)), - }) - @new external fromBufferOffset: (array_buffer, int) => t = "Int8Array" - - /** - **throw** Js.Exn.Error throws Js exception - - **param** offset is in bytes, length in elements - */ - @deprecated({ - reason: "Use `Int8Array.fromBufferWithRange` instead.", - migrate: Int8Array.fromBufferWithRange( - ~byteOffset=%insert.labelledArgument("offset"), - ~length=%insert.labelledArgument("length"), - ), - }) - @new - external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Int8Array" - - @deprecated({ - reason: "Use `Int8Array.fromLength` instead.", - migrate: Int8Array.fromLength(), - }) - @new - external fromLength: int => t = "Int8Array" - @deprecated({ - reason: "Use `Int8Array.fromArrayLikeOrIterable` instead.", - migrate: Int8Array.fromArrayLikeOrIterable(), - }) - @val - external from: array_like => t = "Int8Array.from" - /* *Array.of is redundant, use make */ -} - -module Uint8Array = { - /** */ - type elt = int - type typed_array<'a> - type t = typed_array - - @get_index external unsafe_get: (t, int) => elt = "" - @set_index external unsafe_set: (t, int, elt) => unit = "" - - @get external buffer: t => array_buffer = "buffer" - @get external byteLength: t => int = "byteLength" - @get external byteOffset: t => int = "byteOffset" - - @deprecated({ - reason: "Use `TypedArray.setArray` instead.", - migrate: TypedArray.setArray(), - }) - @send - external setArray: (t, array) => unit = "set" - @deprecated({ - reason: "Use `TypedArray.setArrayFrom` instead.", - migrate: TypedArray.setArrayFrom(%insert.unlabelledArgument(2)), - }) - @send - external setArrayOffset: (t, array, int) => unit = "set" - /* There's also an overload for typed arrays, but don't know how to model that without subtyping */ - - /* Array interface(-ish) */ - @deprecated({ - reason: "Use `TypedArray.length` instead.", - migrate: TypedArray.length(), - }) - @get - external length: t => int = "length" - - /* Mutator functions */ - @deprecated({ - reason: "Use `TypedArray.copyAllWithin` instead.", - migrate: TypedArray.copyAllWithin(~target=%insert.labelledArgument("to_")), - }) - @send - external copyWithin: (t, ~to_: int) => t = "copyWithin" - @deprecated({ - reason: "Use `TypedArray.copyWithinToEnd` instead.", - migrate: TypedArray.copyWithinToEnd( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("from"), - ), - }) - @send - external copyWithinFrom: (t, ~to_: int, ~from: int) => t = "copyWithin" - @deprecated({ - reason: "Use `TypedArray.copyWithin` instead.", - migrate: TypedArray.copyWithin( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - @send - external copyWithinFromRange: (t, ~to_: int, ~start: int, ~end_: int) => t = "copyWithin" - - @deprecated({ - reason: "Use `TypedArray.fillAll` instead.", - migrate: TypedArray.fillAll(), - }) - @send - external fillInPlace: (t, elt) => t = "fill" - @deprecated({ - reason: "Use `TypedArray.fillToEnd` instead.", - migrate: TypedArray.fillToEnd(~start=%insert.labelledArgument("from")), - }) - @send - external fillFromInPlace: (t, elt, ~from: int) => t = "fill" - @deprecated({ - reason: "Use `TypedArray.fill` instead.", - migrate: TypedArray.fill( - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - @send - external fillRangeInPlace: (t, elt, ~start: int, ~end_: int) => t = "fill" - - @deprecated({ - reason: "Use `TypedArray.reverse` instead.", - migrate: TypedArray.reverse(), - }) - @send - external reverseInPlace: t => t = "reverse" - - @deprecated({ - reason: "Use `TypedArray.toSorted` instead.", - migrate: TypedArray.toSorted((a, b) => - %todo_("This needs a comparator function. Use an appropriate comparator (e.g. Int.compare).") - ), - }) - @send - external sortInPlace: t => t = "sort" - @send external sortInPlaceWith: (t, (elt, elt) => int) => t = "sort" - - /* Accessor functions */ - @deprecated({ - reason: "Use `TypedArray.includes` instead.", - migrate: TypedArray.includes(), - }) - @send - external includes: (t, elt) => bool = "includes" /* ES2016 */ - - @deprecated({ - reason: "Use `TypedArray.indexOf` instead.", - migrate: TypedArray.indexOf(), - }) - @send - external indexOf: (t, elt) => int = "indexOf" - @deprecated({ - reason: "Use `TypedArray.indexOfFrom` instead.", - migrate: TypedArray.indexOfFrom(%insert.labelledArgument("from")), - }) - @send - external indexOfFrom: (t, elt, ~from: int) => int = "indexOf" - - @deprecated({ - reason: "Use `TypedArray.joinWith` instead.", - migrate: TypedArray.joinWith(","), - }) - @send - external join: t => string = "join" - @deprecated({ - reason: "Use `TypedArray.joinWith` instead.", - migrate: TypedArray.joinWith(), - }) - @send - external joinWith: (t, string) => string = "join" - - @deprecated({ - reason: "Use `TypedArray.lastIndexOf` instead.", - migrate: TypedArray.lastIndexOf(), - }) - @send - external lastIndexOf: (t, elt) => int = "lastIndexOf" - @deprecated({ - reason: "Use `TypedArray.lastIndexOfFrom` instead.", - migrate: TypedArray.lastIndexOfFrom(%insert.labelledArgument("from")), - }) - @send - external lastIndexOfFrom: (t, elt, ~from: int) => int = "lastIndexOf" - - /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.slice` instead.", - migrate: TypedArray.slice(~end=%insert.labelledArgument("end_")), - }) - @send external slice: (t, ~start: int, ~end_: int) => t = "slice" - - @deprecated({ - reason: "Use `TypedArray.copy` instead.", - migrate: TypedArray.copy(), - }) - @send - external copy: t => t = "slice" - @deprecated({ - reason: "Use `TypedArray.sliceToEnd` instead.", - migrate: TypedArray.sliceToEnd(~start=%insert.unlabelledArgument(1)), - }) - @send - external sliceFrom: (t, int) => t = "slice" - - /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~end=%insert.labelledArgument("end_")), - }) - @send external subarray: (t, ~start: int, ~end_: int) => t = "subarray" - - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~start=%insert.unlabelledArgument(1)), - }) - @send - external subarrayFrom: (t, int) => t = "subarray" - - @deprecated({ - reason: "Use `TypedArray.toString` instead.", - migrate: TypedArray.toString(), - }) - @send - external toString: t => string = "toString" - @deprecated({ - reason: "Use `TypedArray.toLocaleString` instead.", - migrate: TypedArray.toLocaleString(), - }) - @send - external toLocaleString: t => string = "toLocaleString" - - /* Iteration functions */ - /* commented out until bs has a plan for iterators - external entries : t -> (int * elt) array_iter = "" [@@send] - */ - @deprecated({ - reason: "Use `TypedArray.every` instead.", - migrate: TypedArray.every(), - }) - @send - external every: (t, elt => bool) => bool = "every" - @deprecated({ - reason: "Use `TypedArray.everyWithIndex` instead.", - migrate: TypedArray.everyWithIndex(), - }) - @send - external everyi: (t, (elt, int) => bool) => bool = "every" - - @deprecated({ - reason: "Use `TypedArray.filter` instead.", - migrate: TypedArray.filter(), - }) - @send - external filter: (t, elt => bool) => t = "filter" - @deprecated({ - reason: "Use `TypedArray.filterWithIndex` instead.", - migrate: TypedArray.filterWithIndex(), - }) - @send - external filteri: (t, (elt, int) => bool) => t = "filter" - - @deprecated({ - reason: "Use `TypedArray.find` instead.", - migrate: TypedArray.find(), - }) - @send - external find: (t, elt => bool) => Js_undefined.t = "find" - @deprecated({ - reason: "Use `TypedArray.findWithIndex` instead.", - migrate: TypedArray.findWithIndex(), - }) - @send - external findi: (t, (elt, int) => bool) => Js_undefined.t = "find" - - @deprecated({ - reason: "Use `TypedArray.findIndex` instead.", - migrate: TypedArray.findIndex(), - }) - @send - external findIndex: (t, elt => bool) => int = "findIndex" - @deprecated({ - reason: "Use `TypedArray.findIndexWithIndex` instead.", - migrate: TypedArray.findIndexWithIndex(), - }) - @send - external findIndexi: (t, (elt, int) => bool) => int = "findIndex" - - @deprecated({ - reason: "Use `TypedArray.forEach` instead.", - migrate: TypedArray.forEach(), - }) - @send - external forEach: (t, elt => unit) => unit = "forEach" - @deprecated({ - reason: "Use `TypedArray.forEachWithIndex` instead.", - migrate: TypedArray.forEachWithIndex(), - }) - @send - external forEachi: (t, (elt, int) => unit) => unit = "forEach" - - /* commented out until bs has a plan for iterators - external keys : t -> int array_iter = "" [@@send] - */ - - @deprecated({ - reason: "Use `TypedArray.map` instead.", - migrate: TypedArray.map(), - }) - @send - external map: (t, elt => 'b) => typed_array<'b> = "map" - @deprecated({ - reason: "Use `TypedArray.mapWithIndex` instead.", - migrate: TypedArray.mapWithIndex(), - }) - @send - external mapi: (t, (elt, int) => 'b) => typed_array<'b> = "map" - - @deprecated({ - reason: "Use `TypedArray.reduce` instead.", - migrate: TypedArray.reduce(), - }) - @send - external reduce: (t, ('b, elt) => 'b, 'b) => 'b = "reduce" - @deprecated({ - reason: "Use `TypedArray.reduceWithIndex` instead.", - migrate: TypedArray.reduceWithIndex(), - }) - @send - external reducei: (t, ('b, elt, int) => 'b, 'b) => 'b = "reduce" - - @deprecated({ - reason: "Use `TypedArray.reduceRight` instead.", - migrate: TypedArray.reduceRight(), - }) - @send - external reduceRight: (t, ('b, elt) => 'b, 'b) => 'b = "reduceRight" - @deprecated({ - reason: "Use `TypedArray.reduceRightWithIndex` instead.", - migrate: TypedArray.reduceRightWithIndex(), - }) - @send - external reduceRighti: (t, ('b, elt, int) => 'b, 'b) => 'b = "reduceRight" - - @deprecated({ - reason: "Use `TypedArray.some` instead.", - migrate: TypedArray.some(), - }) - @send - external some: (t, elt => bool) => bool = "some" - @deprecated({ - reason: "Use `TypedArray.someWithIndex` instead.", - migrate: TypedArray.someWithIndex(), - }) - @send - external somei: (t, (elt, int) => bool) => bool = "some" - - @deprecated({ - reason: "Use `Uint8Array.Constants.bytesPerElement` instead.", - migrate: Uint8Array.Constants.bytesPerElement, - }) - @val - external _BYTES_PER_ELEMENT: int = "Uint8Array.BYTES_PER_ELEMENT" - - @deprecated({ - reason: "Use `Uint8Array.fromArray` instead.", - migrate: Uint8Array.fromArray(), - }) - @new - external make: array => t = "Uint8Array" - /** can throw */ - @new - external fromBuffer: array_buffer => t = "Uint8Array" - - /** - **throw** Js.Exn.Error throw Js exception - - **param** offset is in bytes - */ - @deprecated({ - reason: "Use `Uint8Array.fromBufferToEnd` instead.", - migrate: Uint8Array.fromBufferToEnd(~byteOffset=%insert.unlabelledArgument(1)), - }) - @new external fromBufferOffset: (array_buffer, int) => t = "Uint8Array" - - /** - **throw** Js.Exn.Error throws Js exception - - **param** offset is in bytes, length in elements - */ - @deprecated({ - reason: "Use `Uint8Array.fromBufferWithRange` instead.", - migrate: Uint8Array.fromBufferWithRange( - ~byteOffset=%insert.labelledArgument("offset"), - ~length=%insert.labelledArgument("length"), - ), - }) - @new - external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Uint8Array" - - @deprecated({ - reason: "Use `Uint8Array.fromLength` instead.", - migrate: Uint8Array.fromLength(), - }) - @new - external fromLength: int => t = "Uint8Array" - @deprecated({ - reason: "Use `Uint8Array.fromArrayLikeOrIterable` instead.", - migrate: Uint8Array.fromArrayLikeOrIterable(), - }) - @val - external from: array_like => t = "Uint8Array.from" - /* *Array.of is redundant, use make */ -} - -module Uint8ClampedArray = { - /** */ - type elt = int - type typed_array<'a> - type t = typed_array - - @get_index external unsafe_get: (t, int) => elt = "" - @set_index external unsafe_set: (t, int, elt) => unit = "" - - @get external buffer: t => array_buffer = "buffer" - @get external byteLength: t => int = "byteLength" - @get external byteOffset: t => int = "byteOffset" - - @deprecated({ - reason: "Use `TypedArray.setArray` instead.", - migrate: TypedArray.setArray(), - }) - @send - external setArray: (t, array) => unit = "set" - @deprecated({ - reason: "Use `TypedArray.setArrayFrom` instead.", - migrate: TypedArray.setArrayFrom(%insert.unlabelledArgument(2)), - }) - @send - external setArrayOffset: (t, array, int) => unit = "set" - /* There's also an overload for typed arrays, but don't know how to model that without subtyping */ - - /* Array interface(-ish) */ - @deprecated({ - reason: "Use `TypedArray.length` instead.", - migrate: TypedArray.length(), - }) - @get - external length: t => int = "length" - - /* Mutator functions */ - @deprecated({ - reason: "Use `TypedArray.copyAllWithin` instead.", - migrate: TypedArray.copyAllWithin(~target=%insert.labelledArgument("to_")), - }) - @send - external copyWithin: (t, ~to_: int) => t = "copyWithin" - @deprecated({ - reason: "Use `TypedArray.copyWithinToEnd` instead.", - migrate: TypedArray.copyWithinToEnd( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("from"), - ), - }) - @send - external copyWithinFrom: (t, ~to_: int, ~from: int) => t = "copyWithin" - @deprecated({ - reason: "Use `TypedArray.copyWithin` instead.", - migrate: TypedArray.copyWithin( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - @send - external copyWithinFromRange: (t, ~to_: int, ~start: int, ~end_: int) => t = "copyWithin" - - @deprecated({ - reason: "Use `TypedArray.fillAll` instead.", - migrate: TypedArray.fillAll(), - }) - @send - external fillInPlace: (t, elt) => t = "fill" - @deprecated({ - reason: "Use `TypedArray.fillToEnd` instead.", - migrate: TypedArray.fillToEnd(~start=%insert.labelledArgument("from")), - }) - @send - external fillFromInPlace: (t, elt, ~from: int) => t = "fill" - @deprecated({ - reason: "Use `TypedArray.fill` instead.", - migrate: TypedArray.fill( - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - @send - external fillRangeInPlace: (t, elt, ~start: int, ~end_: int) => t = "fill" - - @deprecated({ - reason: "Use `TypedArray.reverse` instead.", - migrate: TypedArray.reverse(), - }) - @send - external reverseInPlace: t => t = "reverse" - - @deprecated({ - reason: "Use `TypedArray.toSorted` instead.", - migrate: TypedArray.toSorted((a, b) => - %todo_("This needs a comparator function. Use an appropriate comparator (e.g. Int.compare).") - ), - }) - @send - external sortInPlace: t => t = "sort" - @send external sortInPlaceWith: (t, (elt, elt) => int) => t = "sort" - - /* Accessor functions */ - @deprecated({ - reason: "Use `TypedArray.includes` instead.", - migrate: TypedArray.includes(), - }) - @send - external includes: (t, elt) => bool = "includes" /* ES2016 */ - - @deprecated({ - reason: "Use `TypedArray.indexOf` instead.", - migrate: TypedArray.indexOf(), - }) - @send - external indexOf: (t, elt) => int = "indexOf" - @deprecated({ - reason: "Use `TypedArray.indexOfFrom` instead.", - migrate: TypedArray.indexOfFrom(%insert.labelledArgument("from")), - }) - @send - external indexOfFrom: (t, elt, ~from: int) => int = "indexOf" - - @deprecated({ - reason: "Use `TypedArray.joinWith` instead.", - migrate: TypedArray.joinWith(","), - }) - @send - external join: t => string = "join" - @deprecated({ - reason: "Use `TypedArray.joinWith` instead.", - migrate: TypedArray.joinWith(), - }) - @send - external joinWith: (t, string) => string = "join" - - @deprecated({ - reason: "Use `TypedArray.lastIndexOf` instead.", - migrate: TypedArray.lastIndexOf(), - }) - @send - external lastIndexOf: (t, elt) => int = "lastIndexOf" - @deprecated({ - reason: "Use `TypedArray.lastIndexOfFrom` instead.", - migrate: TypedArray.lastIndexOfFrom(%insert.labelledArgument("from")), - }) - @send - external lastIndexOfFrom: (t, elt, ~from: int) => int = "lastIndexOf" - - /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.slice` instead.", - migrate: TypedArray.slice(~end=%insert.labelledArgument("end_")), - }) - @send external slice: (t, ~start: int, ~end_: int) => t = "slice" - - @deprecated({ - reason: "Use `TypedArray.copy` instead.", - migrate: TypedArray.copy(), - }) - @send - external copy: t => t = "slice" - @deprecated({ - reason: "Use `TypedArray.sliceToEnd` instead.", - migrate: TypedArray.sliceToEnd(~start=%insert.unlabelledArgument(1)), - }) - @send - external sliceFrom: (t, int) => t = "slice" - - /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~end=%insert.labelledArgument("end_")), - }) - @send external subarray: (t, ~start: int, ~end_: int) => t = "subarray" - - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~start=%insert.unlabelledArgument(1)), - }) - @send - external subarrayFrom: (t, int) => t = "subarray" - - @deprecated({ - reason: "Use `TypedArray.toString` instead.", - migrate: TypedArray.toString(), - }) - @send - external toString: t => string = "toString" - @deprecated({ - reason: "Use `TypedArray.toLocaleString` instead.", - migrate: TypedArray.toLocaleString(), - }) - @send - external toLocaleString: t => string = "toLocaleString" - - /* Iteration functions */ - /* commented out until bs has a plan for iterators - external entries : t -> (int * elt) array_iter = "" [@@send] - */ - @deprecated({ - reason: "Use `TypedArray.every` instead.", - migrate: TypedArray.every(), - }) - @send - external every: (t, elt => bool) => bool = "every" - @deprecated({ - reason: "Use `TypedArray.everyWithIndex` instead.", - migrate: TypedArray.everyWithIndex(), - }) - @send - external everyi: (t, (elt, int) => bool) => bool = "every" - - @deprecated({ - reason: "Use `TypedArray.filter` instead.", - migrate: TypedArray.filter(), - }) - @send - external filter: (t, elt => bool) => t = "filter" - @deprecated({ - reason: "Use `TypedArray.filterWithIndex` instead.", - migrate: TypedArray.filterWithIndex(), - }) - @send - external filteri: (t, (elt, int) => bool) => t = "filter" - - @deprecated({ - reason: "Use `TypedArray.find` instead.", - migrate: TypedArray.find(), - }) - @send - external find: (t, elt => bool) => Js_undefined.t = "find" - @deprecated({ - reason: "Use `TypedArray.findWithIndex` instead.", - migrate: TypedArray.findWithIndex(), - }) - @send - external findi: (t, (elt, int) => bool) => Js_undefined.t = "find" - - @deprecated({ - reason: "Use `TypedArray.findIndex` instead.", - migrate: TypedArray.findIndex(), - }) - @send - external findIndex: (t, elt => bool) => int = "findIndex" - @deprecated({ - reason: "Use `TypedArray.findIndexWithIndex` instead.", - migrate: TypedArray.findIndexWithIndex(), - }) - @send - external findIndexi: (t, (elt, int) => bool) => int = "findIndex" - - @deprecated({ - reason: "Use `TypedArray.forEach` instead.", - migrate: TypedArray.forEach(), - }) - @send - external forEach: (t, elt => unit) => unit = "forEach" - @deprecated({ - reason: "Use `TypedArray.forEachWithIndex` instead.", - migrate: TypedArray.forEachWithIndex(), - }) - @send - external forEachi: (t, (elt, int) => unit) => unit = "forEach" - - /* commented out until bs has a plan for iterators - external keys : t -> int array_iter = "" [@@send] - */ - - @deprecated({ - reason: "Use `TypedArray.map` instead.", - migrate: TypedArray.map(), - }) - @send - external map: (t, elt => 'b) => typed_array<'b> = "map" - @deprecated({ - reason: "Use `TypedArray.mapWithIndex` instead.", - migrate: TypedArray.mapWithIndex(), - }) - @send - external mapi: (t, (elt, int) => 'b) => typed_array<'b> = "map" - - @deprecated({ - reason: "Use `TypedArray.reduce` instead.", - migrate: TypedArray.reduce(), - }) - @send - external reduce: (t, ('b, elt) => 'b, 'b) => 'b = "reduce" - @deprecated({ - reason: "Use `TypedArray.reduceWithIndex` instead.", - migrate: TypedArray.reduceWithIndex(), - }) - @send - external reducei: (t, ('b, elt, int) => 'b, 'b) => 'b = "reduce" - - @deprecated({ - reason: "Use `TypedArray.reduceRight` instead.", - migrate: TypedArray.reduceRight(), - }) - @send - external reduceRight: (t, ('b, elt) => 'b, 'b) => 'b = "reduceRight" - @deprecated({ - reason: "Use `TypedArray.reduceRightWithIndex` instead.", - migrate: TypedArray.reduceRightWithIndex(), - }) - @send - external reduceRighti: (t, ('b, elt, int) => 'b, 'b) => 'b = "reduceRight" - - @deprecated({ - reason: "Use `TypedArray.some` instead.", - migrate: TypedArray.some(), - }) - @send - external some: (t, elt => bool) => bool = "some" - @deprecated({ - reason: "Use `TypedArray.someWithIndex` instead.", - migrate: TypedArray.someWithIndex(), - }) - @send - external somei: (t, (elt, int) => bool) => bool = "some" - - @deprecated({ - reason: "Use `Uint8ClampedArray.Constants.bytesPerElement` instead.", - migrate: Uint8ClampedArray.Constants.bytesPerElement, - }) - @val - external _BYTES_PER_ELEMENT: int = "Uint8ClampedArray.BYTES_PER_ELEMENT" - - @deprecated({ - reason: "Use `Uint8ClampedArray.fromArray` instead.", - migrate: Uint8ClampedArray.fromArray(), - }) - @new - external make: array => t = "Uint8ClampedArray" - /** can throw */ - @new - external fromBuffer: array_buffer => t = "Uint8ClampedArray" - - /** - **throw** Js.Exn.Error throw Js exception - - **param** offset is in bytes - */ - @deprecated({ - reason: "Use `Uint8ClampedArray.fromBufferToEnd` instead.", - migrate: Uint8ClampedArray.fromBufferToEnd(~byteOffset=%insert.unlabelledArgument(1)), - }) - @new external fromBufferOffset: (array_buffer, int) => t = "Uint8ClampedArray" - - /** - **throw** Js.Exn.Error throws Js exception - - **param** offset is in bytes, length in elements - */ - @deprecated({ - reason: "Use `Uint8ClampedArray.fromBufferWithRange` instead.", - migrate: Uint8ClampedArray.fromBufferWithRange( - ~byteOffset=%insert.labelledArgument("offset"), - ~length=%insert.labelledArgument("length"), - ), - }) - @new - external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Uint8ClampedArray" - - @deprecated({ - reason: "Use `Uint8ClampedArray.fromLength` instead.", - migrate: Uint8ClampedArray.fromLength(), - }) - @new - external fromLength: int => t = "Uint8ClampedArray" - @deprecated({ - reason: "Use `Uint8ClampedArray.fromArrayLikeOrIterable` instead.", - migrate: Uint8ClampedArray.fromArrayLikeOrIterable(), - }) - @val - external from: array_like => t = "Uint8ClampedArray.from" - /* *Array.of is redundant, use make */ -} - -module Int16Array = { - /** */ - type elt = int - type typed_array<'a> - type t = typed_array - - @get_index external unsafe_get: (t, int) => elt = "" - @set_index external unsafe_set: (t, int, elt) => unit = "" - - @get external buffer: t => array_buffer = "buffer" - @get external byteLength: t => int = "byteLength" - @get external byteOffset: t => int = "byteOffset" - - @deprecated({reason: "Use `TypedArray.setArray` instead.", migrate: TypedArray.setArray()}) @send - external setArray: (t, array) => unit = "set" - @deprecated({ - reason: "Use `TypedArray.setArrayFrom` instead.", - migrate: TypedArray.setArrayFrom(%insert.unlabelledArgument(2)), - }) - @send - external setArrayOffset: (t, array, int) => unit = "set" - /* There's also an overload for typed arrays, but don't know how to model that without subtyping */ - - /* Array interface(-ish) */ - @deprecated({reason: "Use `TypedArray.length` instead.", migrate: TypedArray.length()}) @get - external length: t => int = "length" - - /* Mutator functions */ - @deprecated({ - reason: "Use `TypedArray.copyAllWithin` instead.", - migrate: TypedArray.copyAllWithin(~target=%insert.labelledArgument("to_")), - }) - @send - external copyWithin: (t, ~to_: int) => t = "copyWithin" - @deprecated({ - reason: "Use `TypedArray.copyWithinToEnd` instead.", - migrate: TypedArray.copyWithinToEnd( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("from"), - ), - }) - @send - external copyWithinFrom: (t, ~to_: int, ~from: int) => t = "copyWithin" - @deprecated({ - reason: "Use `TypedArray.copyWithin", - migrate: TypedArray.copyWithin( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - @send - external /* end mapped below */ - - copyWithinFromRange: (t, ~to_: int, ~start: int, ~end_: int) => t = "copyWithin" - - @deprecated({reason: "Use `TypedArray.fillAll` instead.", migrate: TypedArray.fillAll()}) @send - external fillInPlace: (t, elt) => t = "fill" - @deprecated({ - reason: "Use `TypedArray.fillToEnd` instead.", - migrate: TypedArray.fillToEnd(~start=%insert.labelledArgument("from")), - }) - @send - external fillFromInPlace: (t, elt, ~from: int) => t = "fill" - @deprecated({ - reason: "Use `TypedArray.fill` instead.", - migrate: TypedArray.fill( - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - @send - external fillRangeInPlace: (t, elt, ~start: int, ~end_: int) => t = "fill" - - @deprecated({reason: "Use `TypedArray.reverse` instead.", migrate: TypedArray.reverse()}) @send - external reverseInPlace: t => t = "reverse" - - @deprecated({ - reason: "Use `TypedArray.toSorted` instead.", - migrate: TypedArray.toSorted((a, b) => - %todo_("This needs a comparator function. Use an appropriate comparator (e.g. Int.compare).") - ), - }) - @send - external sortInPlace: t => t = "sort" - @deprecated({reason: "Use `TypedArray.sort` instead.", migrate: TypedArray.sort()}) @send - external sortInPlaceWith: (t, (elt, elt) => int) => t = "sort" - - /* Accessor functions */ - @deprecated({reason: "Use `TypedArray.includes` instead.", migrate: TypedArray.includes()}) @send - external includes: (t, elt) => bool = "includes" /* ES2016 */ - - @deprecated({reason: "Use `TypedArray.indexOf` instead.", migrate: TypedArray.indexOf()}) @send - external indexOf: (t, elt) => int = "indexOf" - @deprecated({ - reason: "Use `TypedArray.indexOfFrom` instead.", - migrate: TypedArray.indexOfFrom(%insert.labelledArgument("from")), - }) - @send - external indexOfFrom: (t, elt, ~from: int) => int = "indexOf" - - @deprecated({reason: "Use `TypedArray.joinWith` instead.", migrate: TypedArray.joinWith(",")}) - @send - external join: t => string = "join" - @deprecated({reason: "Use `TypedArray.joinWith` instead.", migrate: TypedArray.joinWith()}) @send - external joinWith: (t, string) => string = "join" - - @deprecated({reason: "Use `TypedArray.lastIndexOf` instead.", migrate: TypedArray.lastIndexOf()}) - @send - external lastIndexOf: (t, elt) => int = "lastIndexOf" - @deprecated({ - reason: "Use `TypedArray.lastIndexOfFrom` instead.", - migrate: TypedArray.lastIndexOfFrom(%insert.labelledArgument("from")), - }) - @send - external lastIndexOfFrom: (t, elt, ~from: int) => int = "lastIndexOf" - - /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.slice` instead.", - migrate: TypedArray.slice(~end=%insert.labelledArgument("end_")), - }) - @send external slice: (t, ~start: int, ~end_: int) => t = "slice" - - @deprecated({reason: "Use `TypedArray.copy` instead.", migrate: TypedArray.copy()}) @send - external copy: t => t = "slice" - @deprecated({ - reason: "Use `TypedArray.sliceToEnd` instead.", - migrate: TypedArray.sliceToEnd(~start=%insert.unlabelledArgument(1)), - }) - @send - external sliceFrom: (t, int) => t = "slice" - - /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~end=%insert.labelledArgument("end_")), - }) - @send external subarray: (t, ~start: int, ~end_: int) => t = "subarray" - - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~start=%insert.unlabelledArgument(1)), - }) - @send - external subarrayFrom: (t, int) => t = "subarray" - - @deprecated({reason: "Use `TypedArray.toString` instead.", migrate: TypedArray.toString()}) @send - external toString: t => string = "toString" - @deprecated({ - reason: "Use `TypedArray.toLocaleString` instead.", - migrate: TypedArray.toLocaleString(), - }) - @send - external toLocaleString: t => string = "toLocaleString" - - /* Iteration functions */ - /* commented out until bs has a plan for iterators - external entries : t -> (int * elt) array_iter = "" [@@send] - */ - @deprecated({reason: "Use `TypedArray.every` instead.", migrate: TypedArray.every()}) @send - external every: (t, elt => bool) => bool = "every" - @deprecated({ - reason: "Use `TypedArray.everyWithIndex` instead.", - migrate: TypedArray.everyWithIndex(), - }) - @send - external everyi: (t, (elt, int) => bool) => bool = "every" - - @deprecated({reason: "Use `TypedArray.filter` instead.", migrate: TypedArray.filter()}) @send - external filter: (t, elt => bool) => t = "filter" - @deprecated({ - reason: "Use `TypedArray.filterWithIndex` instead.", - migrate: TypedArray.filterWithIndex(), - }) - @send - external filteri: (t, (elt, int) => bool) => t = "filter" - - @deprecated({reason: "Use `TypedArray.find` instead.", migrate: TypedArray.find()}) @send - external find: (t, elt => bool) => Js_undefined.t = "find" - @deprecated({ - reason: "Use `TypedArray.findWithIndex` instead.", - migrate: TypedArray.findWithIndex(), - }) - @send - external findi: (t, (elt, int) => bool) => Js_undefined.t = "find" - - @deprecated({reason: "Use `TypedArray.findIndex` instead.", migrate: TypedArray.findIndex()}) - @send - external findIndex: (t, elt => bool) => int = "findIndex" - @deprecated({ - reason: "Use `TypedArray.findIndexWithIndex` instead.", - migrate: TypedArray.findIndexWithIndex(), - }) - @send - external findIndexi: (t, (elt, int) => bool) => int = "findIndex" - - @deprecated({reason: "Use `TypedArray.forEach` instead.", migrate: TypedArray.forEach()}) @send - external forEach: (t, elt => unit) => unit = "forEach" - @deprecated({ - reason: "Use `TypedArray.forEachWithIndex` instead.", - migrate: TypedArray.forEachWithIndex(), - }) - @send - external forEachi: (t, (elt, int) => unit) => unit = "forEach" - - /* commented out until bs has a plan for iterators - external keys : t -> int array_iter = "" [@@send] - */ - - @deprecated({reason: "Use `TypedArray.map` instead.", migrate: TypedArray.map()}) @send - external map: (t, elt => 'b) => typed_array<'b> = "map" - @deprecated({ - reason: "Use `TypedArray.mapWithIndex` instead.", - migrate: TypedArray.mapWithIndex(), - }) - @send - external mapi: (t, (elt, int) => 'b) => typed_array<'b> = "map" - - @deprecated({reason: "Use `TypedArray.reduce` instead.", migrate: TypedArray.reduce()}) @send - external reduce: (t, ('b, elt) => 'b, 'b) => 'b = "reduce" - @deprecated({ - reason: "Use `TypedArray.reduceWithIndex` instead.", - migrate: TypedArray.reduceWithIndex(), - }) - @send - external reducei: (t, ('b, elt, int) => 'b, 'b) => 'b = "reduce" - - @deprecated({reason: "Use `TypedArray.reduceRight` instead.", migrate: TypedArray.reduceRight()}) - @send - external reduceRight: (t, ('b, elt) => 'b, 'b) => 'b = "reduceRight" - @deprecated({ - reason: "Use `TypedArray.reduceRightWithIndex` instead.", - migrate: TypedArray.reduceRightWithIndex(), - }) - @send - external reduceRighti: (t, ('b, elt, int) => 'b, 'b) => 'b = "reduceRight" - - @deprecated({reason: "Use `TypedArray.some` instead.", migrate: TypedArray.some()}) @send - external some: (t, elt => bool) => bool = "some" - @deprecated({ - reason: "Use `TypedArray.someWithIndex` instead.", - migrate: TypedArray.someWithIndex(), - }) - @send - external somei: (t, (elt, int) => bool) => bool = "some" - - @val external _BYTES_PER_ELEMENT: int = "Int16Array.BYTES_PER_ELEMENT" - - @new external make: array => t = "Int16Array" - /** can throw */ - @new - external fromBuffer: array_buffer => t = "Int16Array" - - /** - **throw** Js.Exn.Error throw Js exception - - **param** offset is in bytes - */ - @new - external fromBufferOffset: (array_buffer, int) => t = "Int16Array" - - /** - **throw** Js.Exn.Error throws Js exception - - **param** offset is in bytes, length in elements - */ - @new - external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Int16Array" - - @new external fromLength: int => t = "Int16Array" - @val external from: array_like => t = "Int16Array.from" - /* *Array.of is redundant, use make */ -} - -module Uint16Array = { - /** */ - type elt = int - type typed_array<'a> - type t = typed_array - - @get_index external unsafe_get: (t, int) => elt = "" - @set_index external unsafe_set: (t, int, elt) => unit = "" - - @get external buffer: t => array_buffer = "buffer" - @get external byteLength: t => int = "byteLength" - @get external byteOffset: t => int = "byteOffset" - - @send external setArray: (t, array) => unit = "set" - @send external setArrayOffset: (t, array, int) => unit = "set" - /* There's also an overload for typed arrays, but don't know how to model that without subtyping */ - - /* Array interface(-ish) */ - @deprecated({ - reason: "Use `TypedArray.length` instead.", - migrate: TypedArray.length(), - }) - @get - external length: t => int = "length" - - /* Mutator functions */ - @send external copyWithin: (t, ~to_: int) => t = "copyWithin" - @send external copyWithinFrom: (t, ~to_: int, ~from: int) => t = "copyWithin" - @send external copyWithinFromRange: (t, ~to_: int, ~start: int, ~end_: int) => t = "copyWithin" - - @send external fillInPlace: (t, elt) => t = "fill" - @send external fillFromInPlace: (t, elt, ~from: int) => t = "fill" - @send external fillRangeInPlace: (t, elt, ~start: int, ~end_: int) => t = "fill" - - @send external reverseInPlace: t => t = "reverse" - - @send external sortInPlace: t => t = "sort" - @send external sortInPlaceWith: (t, (elt, elt) => int) => t = "sort" - - /* Accessor functions */ - @deprecated({ - reason: "Use `TypedArray.includes` instead.", - migrate: TypedArray.includes(), - }) - @send - external includes: (t, elt) => bool = "includes" /* ES2016 */ - - @send external indexOf: (t, elt) => int = "indexOf" - @deprecated({ - reason: "Use `TypedArray.indexOfFrom` instead.", - migrate: TypedArray.indexOfFrom(%insert.labelledArgument("from")), - }) - @send - external indexOfFrom: (t, elt, ~from: int) => int = "indexOf" - - @send external join: t => string = "join" - @send external joinWith: (t, string) => string = "join" - - @send external lastIndexOf: (t, elt) => int = "lastIndexOf" - @send external lastIndexOfFrom: (t, elt, ~from: int) => int = "lastIndexOf" - - /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.slice` instead.", - migrate: TypedArray.slice(~end=%insert.labelledArgument("end_")), - }) - @send - external slice: (t, ~start: int, ~end_: int) => t = "slice" - - @send external copy: t => t = "slice" - @deprecated({ - reason: "Use `TypedArray.sliceToEnd` instead.", - migrate: TypedArray.sliceToEnd(~start=%insert.unlabelledArgument(1)), - }) - @send - external sliceFrom: (t, int) => t = "slice" - - /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~end=%insert.labelledArgument("end_")), - }) - @send - external subarray: (t, ~start: int, ~end_: int) => t = "subarray" - - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~start=%insert.unlabelledArgument(1)), - }) - @send - external subarrayFrom: (t, int) => t = "subarray" - - @send external toString: t => string = "toString" - @send external toLocaleString: t => string = "toLocaleString" - - /* Iteration functions */ - /* commented out until bs has a plan for iterators - external entries : t -> (int * elt) array_iter = "" [@@send] - */ - @send external every: (t, elt => bool) => bool = "every" - @send external everyi: (t, (elt, int) => bool) => bool = "every" - - @send external filter: (t, elt => bool) => t = "filter" - @send external filteri: (t, (elt, int) => bool) => t = "filter" - - @send external find: (t, elt => bool) => Js_undefined.t = "find" - @send external findi: (t, (elt, int) => bool) => Js_undefined.t = "find" - - @send external findIndex: (t, elt => bool) => int = "findIndex" - @send external findIndexi: (t, (elt, int) => bool) => int = "findIndex" - - @send external forEach: (t, elt => unit) => unit = "forEach" - @send external forEachi: (t, (elt, int) => unit) => unit = "forEach" - - /* commented out until bs has a plan for iterators - external keys : t -> int array_iter = "" [@@send] - */ - - @deprecated({ - reason: "Use `TypedArray.map` instead.", - migrate: TypedArray.map(), - }) - @send - external map: (t, elt => 'b) => typed_array<'b> = "map" - @send external mapi: (t, (elt, int) => 'b) => typed_array<'b> = "map" - - @deprecated({ - reason: "Use `TypedArray.reduce` instead.", - migrate: TypedArray.reduce(), - }) - @send - external reduce: (t, ('b, elt) => 'b, 'b) => 'b = "reduce" - @send external reducei: (t, ('b, elt, int) => 'b, 'b) => 'b = "reduce" - - @send external reduceRight: (t, ('b, elt) => 'b, 'b) => 'b = "reduceRight" - @send external reduceRighti: (t, ('b, elt, int) => 'b, 'b) => 'b = "reduceRight" - - @send external some: (t, elt => bool) => bool = "some" - @send external somei: (t, (elt, int) => bool) => bool = "some" - - @deprecated({ - reason: "Use `Uint16Array.Constants.bytesPerElement` instead.", - migrate: Uint16Array.Constants.bytesPerElement, - }) - @val - external _BYTES_PER_ELEMENT: int = "Uint16Array.BYTES_PER_ELEMENT" - - @deprecated({reason: "Use `Uint16Array.fromArray` instead.", migrate: Uint16Array.fromArray()}) - @new - external make: array => t = "Uint16Array" - /** can throw */ - @new - @deprecated({reason: "Use `Uint16Array.fromBuffer` instead.", migrate: Uint16Array.fromBuffer()}) - external fromBuffer: array_buffer => t = "Uint16Array" - - /** - **throw** Js.Exn.Error throw Js exception - - **param** offset is in bytes - */ - @new - @deprecated({ - reason: "Use `Uint16Array.fromBufferToEnd` instead.", - migrate: Uint16Array.fromBufferToEnd(~byteOffset=%insert.unlabelledArgument(1)), - }) - external fromBufferOffset: (array_buffer, int) => t = "Uint16Array" - - /** - **throw** Js.Exn.Error throws Js exception - - **param** offset is in bytes, length in elements - */ - @new - @deprecated({ - reason: "Use `Uint16Array.fromBufferWithRange", - migrate: Uint16Array.fromBufferWithRange( - ~byteOffset=%insert.labelledArgument("offset"), - ~length=%insert.labelledArgument("length"), - ), - }) - external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Uint16Array" - - @deprecated({reason: "Use `Uint16Array.fromLength` instead.", migrate: Uint16Array.fromLength()}) - @new - external fromLength: int => t = "Uint16Array" - @deprecated({ - reason: "Use `Uint16Array.fromArrayLikeOrIterable` instead.", - migrate: Uint16Array.fromArrayLikeOrIterable(), - }) - @val - external from: array_like => t = "Uint16Array.from" - /* *Array.of is redundant, use make */ -} - -module Int32Array = { - /** */ - type elt = int - type typed_array<'a> - type t = typed_array - - @get_index external unsafe_get: (t, int) => elt = "" - @set_index external unsafe_set: (t, int, elt) => unit = "" - - @get external buffer: t => array_buffer = "buffer" - @get external byteLength: t => int = "byteLength" - @get external byteOffset: t => int = "byteOffset" - - @deprecated({reason: "Use `TypedArray.setArray` instead.", migrate: TypedArray.setArray()}) @send - external setArray: (t, array) => unit = "set" - @deprecated({ - reason: "Use `TypedArray.setArrayFrom` instead.", - migrate: TypedArray.setArrayFrom(%insert.unlabelledArgument(2)), - }) - @send - external setArrayOffset: (t, array, int) => unit = "set" - /* There's also an overload for typed arrays, but don't know how to model that without subtyping */ - - /* Array interface(-ish) */ - @deprecated({reason: "Use `TypedArray.length` instead.", migrate: TypedArray.length()}) @get - external length: t => int = "length" - - /* Mutator functions */ - @deprecated({ - reason: "Use `TypedArray.copyAllWithin` instead.", - migrate: TypedArray.copyAllWithin(~target=%insert.labelledArgument("to_")), - }) - @send - external copyWithin: (t, ~to_: int) => t = "copyWithin" - @deprecated({ - reason: "Use `TypedArray.copyWithinToEnd` instead.", - migrate: TypedArray.copyWithinToEnd( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("from"), - ), - }) - @send - external copyWithinFrom: (t, ~to_: int, ~from: int) => t = "copyWithin" - @deprecated({ - reason: "Use `TypedArray.copyWithin` instead.", - migrate: TypedArray.copyWithin( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - @send - external copyWithinFromRange: (t, ~to_: int, ~start: int, ~end_: int) => t = "copyWithin" - - @deprecated({reason: "Use `TypedArray.fillAll` instead.", migrate: TypedArray.fillAll()}) @send - external fillInPlace: (t, elt) => t = "fill" - @deprecated({ - reason: "Use `TypedArray.fillToEnd` instead.", - migrate: TypedArray.fillToEnd(~start=%insert.labelledArgument("from")), - }) - @send - external fillFromInPlace: (t, elt, ~from: int) => t = "fill" - @deprecated({ - reason: "Use `TypedArray.fill` instead.", - migrate: TypedArray.fill( - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - @send - external fillRangeInPlace: (t, elt, ~start: int, ~end_: int) => t = "fill" - - @deprecated({reason: "Use `TypedArray.reverse` instead.", migrate: TypedArray.reverse()}) @send - external reverseInPlace: t => t = "reverse" - - @deprecated({ - reason: "Use `TypedArray.toSorted` instead.", - migrate: TypedArray.toSorted((a, b) => - %todo_("This needs a comparator function. Use an appropriate comparator (e.g. Int.compare).") - ), - }) - @send - external sortInPlace: t => t = "sort" - @deprecated({reason: "Use `TypedArray.sort` instead.", migrate: TypedArray.sort()}) @send - external sortInPlaceWith: (t, (elt, elt) => int) => t = "sort" - - /* Accessor functions */ - @deprecated({reason: "Use `TypedArray.includes` instead.", migrate: TypedArray.includes()}) @send - external includes: (t, elt) => bool = "includes" /* ES2016 */ - - @deprecated({reason: "Use `TypedArray.indexOf` instead.", migrate: TypedArray.indexOf()}) @send - external indexOf: (t, elt) => int = "indexOf" - @deprecated({ - reason: "Use `TypedArray.indexOfFrom` instead.", - migrate: TypedArray.indexOfFrom(%insert.labelledArgument("from")), - }) - @send - external indexOfFrom: (t, elt, ~from: int) => int = "indexOf" - - @deprecated({reason: "Use `TypedArray.joinWith` instead.", migrate: TypedArray.joinWith(",")}) - @send - external join: t => string = "join" - @deprecated({reason: "Use `TypedArray.joinWith` instead.", migrate: TypedArray.joinWith()}) @send - external joinWith: (t, string) => string = "join" - - @deprecated({reason: "Use `TypedArray.lastIndexOf` instead.", migrate: TypedArray.lastIndexOf()}) - @send - external lastIndexOf: (t, elt) => int = "lastIndexOf" - @deprecated({ - reason: "Use `TypedArray.lastIndexOfFrom` instead.", - migrate: TypedArray.lastIndexOfFrom(%insert.labelledArgument("from")), - }) - @send - external lastIndexOfFrom: (t, elt, ~from: int) => int = "lastIndexOf" - - /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.slice` instead.", - migrate: TypedArray.slice(~end=%insert.labelledArgument("end_")), - }) - @send external slice: (t, ~start: int, ~end_: int) => t = "slice" - - @deprecated({reason: "Use `TypedArray.copy` instead.", migrate: TypedArray.copy()}) @send - external copy: t => t = "slice" - @deprecated({ - reason: "Use `TypedArray.sliceToEnd` instead.", - migrate: TypedArray.sliceToEnd(~start=%insert.unlabelledArgument(1)), - }) - @send - external sliceFrom: (t, int) => t = "slice" - - /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~end=%insert.labelledArgument("end_")), - }) - @send external subarray: (t, ~start: int, ~end_: int) => t = "subarray" - - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~start=%insert.unlabelledArgument(1)), - }) - @send - external subarrayFrom: (t, int) => t = "subarray" - - @deprecated({reason: "Use `TypedArray.toString` instead.", migrate: TypedArray.toString()}) @send - external toString: t => string = "toString" - @deprecated({ - reason: "Use `TypedArray.toLocaleString` instead.", - migrate: TypedArray.toLocaleString(), - }) - @send - external toLocaleString: t => string = "toLocaleString" - - /* Iteration functions */ - /* commented out until bs has a plan for iterators - external entries : t -> (int * elt) array_iter = "" [@@send] - */ - @deprecated({reason: "Use `TypedArray.every` instead.", migrate: TypedArray.every()}) @send - external every: (t, elt => bool) => bool = "every" - @deprecated({ - reason: "Use `TypedArray.everyWithIndex` instead.", - migrate: TypedArray.everyWithIndex(), - }) - @send - external everyi: (t, (elt, int) => bool) => bool = "every" - - @deprecated({reason: "Use `TypedArray.filter` instead.", migrate: TypedArray.filter()}) @send - external filter: (t, elt => bool) => t = "filter" - @deprecated({ - reason: "Use `TypedArray.filterWithIndex` instead.", - migrate: TypedArray.filterWithIndex(), - }) - @send - external filteri: (t, (elt, int) => bool) => t = "filter" - - @deprecated({reason: "Use `TypedArray.find` instead.", migrate: TypedArray.find()}) @send - external find: (t, elt => bool) => Js_undefined.t = "find" - @deprecated({ - reason: "Use `TypedArray.findWithIndex` instead.", - migrate: TypedArray.findWithIndex(), - }) - @send - external findi: (t, (elt, int) => bool) => Js_undefined.t = "find" - - @deprecated({reason: "Use `TypedArray.findIndex` instead.", migrate: TypedArray.findIndex()}) - @send - external findIndex: (t, elt => bool) => int = "findIndex" - @deprecated({ - reason: "Use `TypedArray.findIndexWithIndex` instead.", - migrate: TypedArray.findIndexWithIndex(), - }) - @send - external findIndexi: (t, (elt, int) => bool) => int = "findIndex" - - @deprecated({reason: "Use `TypedArray.forEach` instead.", migrate: TypedArray.forEach()}) @send - external forEach: (t, elt => unit) => unit = "forEach" - @deprecated({ - reason: "Use `TypedArray.forEachWithIndex` instead.", - migrate: TypedArray.forEachWithIndex(), - }) - @send - external forEachi: (t, (elt, int) => unit) => unit = "forEach" - - /* commented out until bs has a plan for iterators - external keys : t -> int array_iter = "" [@@send] - */ - - @deprecated({reason: "Use `TypedArray.map` instead.", migrate: TypedArray.map()}) @send - external map: (t, elt => 'b) => typed_array<'b> = "map" - @deprecated({ - reason: "Use `TypedArray.mapWithIndex` instead.", - migrate: TypedArray.mapWithIndex(), - }) - @send - external mapi: (t, (elt, int) => 'b) => typed_array<'b> = "map" - - @deprecated({reason: "Use `TypedArray.reduce` instead.", migrate: TypedArray.reduce()}) @send - external reduce: (t, ('b, elt) => 'b, 'b) => 'b = "reduce" - @deprecated({ - reason: "Use `TypedArray.reduceWithIndex` instead.", - migrate: TypedArray.reduceWithIndex(), - }) - @send - external reducei: (t, ('b, elt, int) => 'b, 'b) => 'b = "reduce" - - @deprecated({reason: "Use `TypedArray.reduceRight` instead.", migrate: TypedArray.reduceRight()}) - @send - external reduceRight: (t, ('b, elt) => 'b, 'b) => 'b = "reduceRight" - @deprecated({ - reason: "Use `TypedArray.reduceRightWithIndex` instead.", - migrate: TypedArray.reduceRightWithIndex(), - }) - @send - external reduceRighti: (t, ('b, elt, int) => 'b, 'b) => 'b = "reduceRight" - - @deprecated({reason: "Use `TypedArray.some` instead.", migrate: TypedArray.some()}) @send - external some: (t, elt => bool) => bool = "some" - @deprecated({ - reason: "Use `TypedArray.someWithIndex` instead.", - migrate: TypedArray.someWithIndex(), - }) - @send - external somei: (t, (elt, int) => bool) => bool = "some" - - @deprecated({ - reason: "Use `Int32Array.Constants.bytesPerElement` instead.", - migrate: Int32Array.Constants.bytesPerElement, - }) - @val - external _BYTES_PER_ELEMENT: int = "Int32Array.BYTES_PER_ELEMENT" - - @deprecated({reason: "Use `Int32Array.fromArray` instead.", migrate: Int32Array.fromArray()}) @new - external make: array => t = "Int32Array" - /** can throw */ - @new @deprecated({reason: "Use `Int32Array.fromBuffer", migrate: Int32Array.fromBuffer()}) - external fromBuffer: array_buffer => t = "Int32Array" - - /** - **throw** Js.Exn.Error throw Js exception - - **param** offset is in bytes - */ - @new - @deprecated({ - reason: "Use `Int32Array.fromBufferToEnd` instead.", - migrate: Int32Array.fromBufferToEnd(~byteOffset=%insert.unlabelledArgument(1)), - }) - external fromBufferOffset: (array_buffer, int) => t = "Int32Array" - - /** - **throw** Js.Exn.Error throws Js exception - - **param** offset is in bytes, length in elements - */ - @new - @deprecated({ - reason: "Use `Int32Array.fromBufferWithRange", - migrate: Int32Array.fromBufferWithRange( - ~byteOffset=%insert.labelledArgument("offset"), - ~length=%insert.labelledArgument("length"), - ), - }) - external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Int32Array" - - @deprecated({reason: "Use `Int32Array.fromLength` instead.", migrate: Int32Array.fromLength()}) - @new - external fromLength: int => t = "Int32Array" - @deprecated({ - reason: "Use `Int32Array.fromArrayLikeOrIterable` instead.", - migrate: Int32Array.fromArrayLikeOrIterable(), - }) - @val - external from: array_like => t = "Int32Array.from" - /* *Array.of is redundant, use make */ -} - -module Uint32Array = { - /** */ - type elt = int - type typed_array<'a> - type t = typed_array - - @get_index external unsafe_get: (t, int) => elt = "" - @set_index external unsafe_set: (t, int, elt) => unit = "" - - @get external buffer: t => array_buffer = "buffer" - @get external byteLength: t => int = "byteLength" - @get external byteOffset: t => int = "byteOffset" - - @deprecated({reason: "Use `TypedArray.setArray` instead.", migrate: TypedArray.setArray()}) @send - external setArray: (t, array) => unit = "set" - @deprecated({ - reason: "Use `TypedArray.setArrayFrom` instead.", - migrate: TypedArray.setArrayFrom(%insert.unlabelledArgument(2)), - }) - @send - external setArrayOffset: (t, array, int) => unit = "set" - /* There's also an overload for typed arrays, but don't know how to model that without subtyping */ - - /* Array interface(-ish) */ - @deprecated({reason: "Use `TypedArray.length` instead.", migrate: TypedArray.length()}) @get - external length: t => int = "length" - - /* Mutator functions */ - @deprecated({ - reason: "Use `TypedArray.copyAllWithin` instead.", - migrate: TypedArray.copyAllWithin(~target=%insert.labelledArgument("to_")), - }) - @send - external copyWithin: (t, ~to_: int) => t = "copyWithin" - @deprecated({ - reason: "Use `TypedArray.copyWithinToEnd` instead.", - migrate: TypedArray.copyWithinToEnd( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("from"), - ), - }) - @send - external copyWithinFrom: (t, ~to_: int, ~from: int) => t = "copyWithin" - @deprecated({ - reason: "Use `TypedArray.copyWithin` instead.", - migrate: TypedArray.copyWithin( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - @send - external copyWithinFromRange: (t, ~to_: int, ~start: int, ~end_: int) => t = "copyWithin" - - @deprecated({reason: "Use `TypedArray.fillAll` instead.", migrate: TypedArray.fillAll()}) @send - external fillInPlace: (t, elt) => t = "fill" - @deprecated({ - reason: "Use `TypedArray.fillToEnd` instead.", - migrate: TypedArray.fillToEnd(~start=%insert.labelledArgument("from")), - }) - @send - external fillFromInPlace: (t, elt, ~from: int) => t = "fill" - @deprecated({ - reason: "Use `TypedArray.fill` instead.", - migrate: TypedArray.fill( - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - @send - external fillRangeInPlace: (t, elt, ~start: int, ~end_: int) => t = "fill" - - @deprecated({reason: "Use `TypedArray.reverse` instead.", migrate: TypedArray.reverse()}) @send - external reverseInPlace: t => t = "reverse" - - @deprecated({ - reason: "Use `TypedArray.toSorted` instead.", - migrate: TypedArray.toSorted((a, b) => - %todo_("This needs a comparator function. Use an appropriate comparator (e.g. Int.compare).") - ), - }) - @send - external sortInPlace: t => t = "sort" - @deprecated({reason: "Use `TypedArray.sort` instead.", migrate: TypedArray.sort()}) @send - external sortInPlaceWith: (t, (elt, elt) => int) => t = "sort" - - /* Accessor functions */ - @deprecated({reason: "Use `TypedArray.includes` instead.", migrate: TypedArray.includes()}) @send - external includes: (t, elt) => bool = "includes" /* ES2016 */ - - @deprecated({reason: "Use `TypedArray.indexOf` instead.", migrate: TypedArray.indexOf()}) @send - external indexOf: (t, elt) => int = "indexOf" - @deprecated({ - reason: "Use `TypedArray.indexOfFrom` instead.", - migrate: TypedArray.indexOfFrom(%insert.labelledArgument("from")), - }) - @send - external indexOfFrom: (t, elt, ~from: int) => int = "indexOf" - - @deprecated({reason: "Use `TypedArray.joinWith` instead.", migrate: TypedArray.joinWith(",")}) - @send - external join: t => string = "join" - @deprecated({reason: "Use `TypedArray.joinWith` instead.", migrate: TypedArray.joinWith()}) @send - external joinWith: (t, string) => string = "join" - - @deprecated({reason: "Use `TypedArray.lastIndexOf` instead.", migrate: TypedArray.lastIndexOf()}) - @send - external lastIndexOf: (t, elt) => int = "lastIndexOf" - @deprecated({ - reason: "Use `TypedArray.lastIndexOfFrom` instead.", - migrate: TypedArray.lastIndexOfFrom(%insert.labelledArgument("from")), - }) - @send - external lastIndexOfFrom: (t, elt, ~from: int) => int = "lastIndexOf" - - /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.slice` instead.", - migrate: TypedArray.slice(~end=%insert.labelledArgument("end_")), - }) - @send external slice: (t, ~start: int, ~end_: int) => t = "slice" - - @deprecated({reason: "Use `TypedArray.copy` instead.", migrate: TypedArray.copy()}) @send - external copy: t => t = "slice" - @deprecated({ - reason: "Use `TypedArray.sliceToEnd` instead.", - migrate: TypedArray.sliceToEnd(~start=%insert.unlabelledArgument(1)), - }) - @send - external sliceFrom: (t, int) => t = "slice" - - /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~end=%insert.labelledArgument("end_")), - }) - @send external subarray: (t, ~start: int, ~end_: int) => t = "subarray" - - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~start=%insert.unlabelledArgument(1)), - }) - @send - external subarrayFrom: (t, int) => t = "subarray" - - @deprecated({reason: "Use `TypedArray.toString` instead.", migrate: TypedArray.toString()}) @send - external toString: t => string = "toString" - @deprecated({ - reason: "Use `TypedArray.toLocaleString` instead.", - migrate: TypedArray.toLocaleString(), - }) - @send - external toLocaleString: t => string = "toLocaleString" - - /* Iteration functions */ - /* commented out until bs has a plan for iterators - external entries : t -> (int * elt) array_iter = "" [@@send] - */ - @deprecated({reason: "Use `TypedArray.every` instead.", migrate: TypedArray.every()}) @send - external every: (t, elt => bool) => bool = "every" - @deprecated({ - reason: "Use `TypedArray.everyWithIndex` instead.", - migrate: TypedArray.everyWithIndex(), - }) - @send - external everyi: (t, (elt, int) => bool) => bool = "every" - - @deprecated({reason: "Use `TypedArray.filter` instead.", migrate: TypedArray.filter()}) @send - external filter: (t, elt => bool) => t = "filter" - @deprecated({ - reason: "Use `TypedArray.filterWithIndex` instead.", - migrate: TypedArray.filterWithIndex(), - }) - @send - external filteri: (t, (elt, int) => bool) => t = "filter" - - @deprecated({reason: "Use `TypedArray.find` instead.", migrate: TypedArray.find()}) @send - external find: (t, elt => bool) => Js_undefined.t = "find" - @deprecated({ - reason: "Use `TypedArray.findWithIndex` instead.", - migrate: TypedArray.findWithIndex(), - }) - @send - external findi: (t, (elt, int) => bool) => Js_undefined.t = "find" - - @deprecated({reason: "Use `TypedArray.findIndex` instead.", migrate: TypedArray.findIndex()}) - @send - external findIndex: (t, elt => bool) => int = "findIndex" - @deprecated({ - reason: "Use `TypedArray.findIndexWithIndex` instead.", - migrate: TypedArray.findIndexWithIndex(), - }) - @send - external findIndexi: (t, (elt, int) => bool) => int = "findIndex" - - @deprecated({reason: "Use `TypedArray.forEach` instead.", migrate: TypedArray.forEach()}) @send - external forEach: (t, elt => unit) => unit = "forEach" - @deprecated({ - reason: "Use `TypedArray.forEachWithIndex` instead.", - migrate: TypedArray.forEachWithIndex(), - }) - @send - external forEachi: (t, (elt, int) => unit) => unit = "forEach" - - /* commented out until bs has a plan for iterators - external keys : t -> int array_iter = "" [@@send] - */ - - @deprecated({reason: "Use `TypedArray.map` instead.", migrate: TypedArray.map()}) @send - external map: (t, elt => 'b) => typed_array<'b> = "map" - @deprecated({ - reason: "Use `TypedArray.mapWithIndex` instead.", - migrate: TypedArray.mapWithIndex(), - }) - @send - external mapi: (t, (elt, int) => 'b) => typed_array<'b> = "map" - - @deprecated({reason: "Use `TypedArray.reduce` instead.", migrate: TypedArray.reduce()}) @send - external reduce: (t, ('b, elt) => 'b, 'b) => 'b = "reduce" - @deprecated({ - reason: "Use `TypedArray.reduceWithIndex` instead.", - migrate: TypedArray.reduceWithIndex(), - }) - @send - external reducei: (t, ('b, elt, int) => 'b, 'b) => 'b = "reduce" - - @deprecated({reason: "Use `TypedArray.reduceRight` instead.", migrate: TypedArray.reduceRight()}) - @send - external reduceRight: (t, ('b, elt) => 'b, 'b) => 'b = "reduceRight" - @deprecated({ - reason: "Use `TypedArray.reduceRightWithIndex` instead.", - migrate: TypedArray.reduceRightWithIndex(), - }) - @send - external reduceRighti: (t, ('b, elt, int) => 'b, 'b) => 'b = "reduceRight" - - @deprecated({reason: "Use `TypedArray.some` instead.", migrate: TypedArray.some()}) @send - external some: (t, elt => bool) => bool = "some" - @deprecated({ - reason: "Use `TypedArray.someWithIndex` instead.", - migrate: TypedArray.someWithIndex(), - }) - @send - external somei: (t, (elt, int) => bool) => bool = "some" - - @deprecated({ - reason: "Use `Uint32Array.Constants.bytesPerElement` instead.", - migrate: Uint32Array.Constants.bytesPerElement, - }) - @val - external _BYTES_PER_ELEMENT: int = "Uint32Array.BYTES_PER_ELEMENT" - - @deprecated({reason: "Use `Uint32Array.fromArray` instead.", migrate: Uint32Array.fromArray()}) - @new - external make: array => t = "Uint32Array" - /** can throw */ - @new - @deprecated({reason: "Use `Uint32Array.fromBuffer` instead.", migrate: Uint32Array.fromBuffer()}) - external fromBuffer: array_buffer => t = "Uint32Array" - - /** - **throw** Js.Exn.Error throw Js exception - - **param** offset is in bytes - */ - @new - @deprecated({ - reason: "Use `Uint32Array.fromBufferToEnd` instead.", - migrate: Uint32Array.fromBufferToEnd(~byteOffset=%insert.unlabelledArgument(1)), - }) - external fromBufferOffset: (array_buffer, int) => t = "Uint32Array" - - /** - **throw** Js.Exn.Error throws Js exception - - **param** offset is in bytes, length in elements - */ - @new - @deprecated({ - reason: "Use `Uint32Array.fromBufferWithRange` instead.", - migrate: Uint32Array.fromBufferWithRange( - ~byteOffset=%insert.labelledArgument("offset"), - ~length=%insert.labelledArgument("length"), - ), - }) - external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Uint32Array" - - @deprecated({reason: "Use `Uint32Array.fromLength` instead.", migrate: Uint32Array.fromLength()}) - @new - external fromLength: int => t = "Uint32Array" - @deprecated({ - reason: "Use `Uint32Array.fromArrayLikeOrIterable` instead.", - migrate: Uint32Array.fromArrayLikeOrIterable(), - }) - @val - external from: array_like => t = "Uint32Array.from" - /* *Array.of is redundant, use make */ -} - -/* - it still return number, `float` in this case -*/ -module Float32Array = { - /** */ - type elt = float - type typed_array<'a> - type t = typed_array - - @get_index external unsafe_get: (t, int) => elt = "" - @set_index external unsafe_set: (t, int, elt) => unit = "" - - @get external buffer: t => array_buffer = "buffer" - @get external byteLength: t => int = "byteLength" - @get external byteOffset: t => int = "byteOffset" - - @deprecated({reason: "Use `TypedArray.setArray` instead.", migrate: TypedArray.setArray()}) @send - external setArray: (t, array) => unit = "set" - @deprecated({ - reason: "Use `TypedArray.setArrayFrom` instead.", - migrate: TypedArray.setArrayFrom(%insert.unlabelledArgument(2)), - }) - @send - external setArrayOffset: (t, array, int) => unit = "set" - /* There's also an overload for typed arrays, but don't know how to model that without subtyping */ - - /* Array interface(-ish) */ - @deprecated({reason: "Use `TypedArray.length` instead.", migrate: TypedArray.length()}) @get - external length: t => int = "length" - - /* Mutator functions */ - @deprecated({ - reason: "Use `TypedArray.copyAllWithin` instead.", - migrate: TypedArray.copyAllWithin(~target=%insert.labelledArgument("to_")), - }) - @send - external copyWithin: (t, ~to_: int) => t = "copyWithin" - @deprecated({ - reason: "Use `TypedArray.copyWithinToEnd` instead.", - migrate: TypedArray.copyWithinToEnd( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("from"), - ), - }) - @send - external copyWithinFrom: (t, ~to_: int, ~from: int) => t = "copyWithin" - @deprecated({ - reason: "Use `TypedArray.copyWithin` instead.", - migrate: TypedArray.copyWithin( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - @send - external copyWithinFromRange: (t, ~to_: int, ~start: int, ~end_: int) => t = "copyWithin" - - @deprecated({reason: "Use `TypedArray.fillAll` instead.", migrate: TypedArray.fillAll()}) @send - external fillInPlace: (t, elt) => t = "fill" - @deprecated({ - reason: "Use `TypedArray.fillToEnd` instead.", - migrate: TypedArray.fillToEnd(~start=%insert.labelledArgument("from")), - }) - @send - external fillFromInPlace: (t, elt, ~from: int) => t = "fill" - @deprecated({ - reason: "Use `TypedArray.fill` instead.", - migrate: TypedArray.fill( - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - @send - external fillRangeInPlace: (t, elt, ~start: int, ~end_: int) => t = "fill" - - @deprecated({reason: "Use `TypedArray.reverse` instead.", migrate: TypedArray.reverse()}) @send - external reverseInPlace: t => t = "reverse" - - @deprecated({ - reason: "Use `TypedArray.toSorted` instead.", - migrate: TypedArray.toSorted((a, b) => - %todo_( - "This needs a comparator function. Use an appropriate comparator (e.g. Float.compare)." - ) - ), - }) - @send - external sortInPlace: t => t = "sort" - @deprecated({reason: "Use `TypedArray.sort` instead.", migrate: TypedArray.sort()}) @send - external sortInPlaceWith: (t, (elt, elt) => int) => t = "sort" - - /* Accessor functions */ - @deprecated({reason: "Use `TypedArray.includes` instead.", migrate: TypedArray.includes()}) @send - external includes: (t, elt) => bool = "includes" /* ES2016 */ - - @deprecated({reason: "Use `TypedArray.indexOf` instead.", migrate: TypedArray.indexOf()}) @send - external indexOf: (t, elt) => int = "indexOf" - @deprecated({ - reason: "Use `TypedArray.indexOfFrom` instead.", - migrate: TypedArray.indexOfFrom(%insert.labelledArgument("from")), - }) - @send - external indexOfFrom: (t, elt, ~from: int) => int = "indexOf" - - @deprecated({reason: "Use `TypedArray.joinWith` instead.", migrate: TypedArray.joinWith(",")}) - @send - external join: t => string = "join" - @deprecated({reason: "Use `TypedArray.joinWith` instead.", migrate: TypedArray.joinWith()}) @send - external joinWith: (t, string) => string = "join" - - @deprecated({reason: "Use `TypedArray.lastIndexOf` instead.", migrate: TypedArray.lastIndexOf()}) - @send - external lastIndexOf: (t, elt) => int = "lastIndexOf" - @deprecated({ - reason: "Use `TypedArray.lastIndexOfFrom` instead.", - migrate: TypedArray.lastIndexOfFrom(%insert.labelledArgument("from")), - }) - @send - external lastIndexOfFrom: (t, elt, ~from: int) => int = "lastIndexOf" - - /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.slice` instead.", - migrate: TypedArray.slice(~end=%insert.labelledArgument("end_")), - }) - @send external slice: (t, ~start: int, ~end_: int) => t = "slice" - - @deprecated({reason: "Use `TypedArray.copy` instead.", migrate: TypedArray.copy()}) @send - external copy: t => t = "slice" - @deprecated({ - reason: "Use `TypedArray.sliceToEnd` instead.", - migrate: TypedArray.sliceToEnd(~start=%insert.unlabelledArgument(1)), - }) - @send - external sliceFrom: (t, int) => t = "slice" - - /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~end=%insert.labelledArgument("end_")), - }) - @send external subarray: (t, ~start: int, ~end_: int) => t = "subarray" - - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~start=%insert.unlabelledArgument(1)), - }) - @send - external subarrayFrom: (t, int) => t = "subarray" - - @deprecated({reason: "Use `TypedArray.toString` instead.", migrate: TypedArray.toString()}) @send - external toString: t => string = "toString" - @deprecated({ - reason: "Use `TypedArray.toLocaleString` instead.", - migrate: TypedArray.toLocaleString(), - }) - @send - external toLocaleString: t => string = "toLocaleString" - - /* Iteration functions */ - /* commented out until bs has a plan for iterators - external entries : t -> (int * elt) array_iter = "" [@@send] - */ - @deprecated({reason: "Use `TypedArray.every` instead.", migrate: TypedArray.every()}) @send - external every: (t, elt => bool) => bool = "every" - @deprecated({ - reason: "Use `TypedArray.everyWithIndex` instead.", - migrate: TypedArray.everyWithIndex(), - }) - @send - external everyi: (t, (elt, int) => bool) => bool = "every" - - @deprecated({reason: "Use `TypedArray.filter` instead.", migrate: TypedArray.filter()}) @send - external filter: (t, elt => bool) => t = "filter" - @deprecated({ - reason: "Use `TypedArray.filterWithIndex` instead.", - migrate: TypedArray.filterWithIndex(), - }) - @send - external filteri: (t, (elt, int) => bool) => t = "filter" - - @deprecated({reason: "Use `TypedArray.find` instead.", migrate: TypedArray.find()}) @send - external find: (t, elt => bool) => Js_undefined.t = "find" - @deprecated({ - reason: "Use `TypedArray.findWithIndex` instead.", - migrate: TypedArray.findWithIndex(), - }) - @send - external findi: (t, (elt, int) => bool) => Js_undefined.t = "find" - - @deprecated({reason: "Use `TypedArray.findIndex` instead.", migrate: TypedArray.findIndex()}) - @send - external findIndex: (t, elt => bool) => int = "findIndex" - @deprecated({ - reason: "Use `TypedArray.findIndexWithIndex` instead.", - migrate: TypedArray.findIndexWithIndex(), - }) - @send - external findIndexi: (t, (elt, int) => bool) => int = "findIndex" - - @deprecated({reason: "Use `TypedArray.forEach` instead.", migrate: TypedArray.forEach()}) @send - external forEach: (t, elt => unit) => unit = "forEach" - @deprecated({ - reason: "Use `TypedArray.forEachWithIndex` instead.", - migrate: TypedArray.forEachWithIndex(), - }) - @send - external forEachi: (t, (elt, int) => unit) => unit = "forEach" - - /* commented out until bs has a plan for iterators - external keys : t -> int array_iter = "" [@@send] - */ - - @deprecated({reason: "Use `TypedArray.map` instead.", migrate: TypedArray.map()}) @send - external map: (t, elt => 'b) => typed_array<'b> = "map" - @deprecated({ - reason: "Use `TypedArray.mapWithIndex` instead.", - migrate: TypedArray.mapWithIndex(), - }) - @send - external mapi: (t, (elt, int) => 'b) => typed_array<'b> = "map" - - @deprecated({reason: "Use `TypedArray.reduce` instead.", migrate: TypedArray.reduce()}) @send - external reduce: (t, ('b, elt) => 'b, 'b) => 'b = "reduce" - @deprecated({ - reason: "Use `TypedArray.reduceWithIndex` instead.", - migrate: TypedArray.reduceWithIndex(), - }) - @send - external reducei: (t, ('b, elt, int) => 'b, 'b) => 'b = "reduce" - - @deprecated({reason: "Use `TypedArray.reduceRight` instead.", migrate: TypedArray.reduceRight()}) - @send - external reduceRight: (t, ('b, elt) => 'b, 'b) => 'b = "reduceRight" - @deprecated({ - reason: "Use `TypedArray.reduceRightWithIndex` instead.", - migrate: TypedArray.reduceRightWithIndex(), - }) - @send - external reduceRighti: (t, ('b, elt, int) => 'b, 'b) => 'b = "reduceRight" - - @deprecated({reason: "Use `TypedArray.some` instead.", migrate: TypedArray.some()}) @send - external some: (t, elt => bool) => bool = "some" - @deprecated({ - reason: "Use `TypedArray.someWithIndex` instead.", - migrate: TypedArray.someWithIndex(), - }) - @send - external somei: (t, (elt, int) => bool) => bool = "some" - - @deprecated({ - reason: "Use `Float32Array.Constants.bytesPerElement` instead.", - migrate: Float32Array.Constants.bytesPerElement, - }) - @val - external _BYTES_PER_ELEMENT: int = "Float32Array.BYTES_PER_ELEMENT" - - @deprecated({reason: "Use `Float32Array.fromArray` instead.", migrate: Float32Array.fromArray()}) - @new - external make: array => t = "Float32Array" - /** can throw */ - @new - @deprecated({ - reason: "Use `Float32Array.fromBuffer` instead.", - migrate: Float32Array.fromBuffer(), - }) - external fromBuffer: array_buffer => t = "Float32Array" - - /** - **throw** Js.Exn.Error throw Js exception - - **param** offset is in bytes - */ - @new - @deprecated({ - reason: "Use `Float32Array.fromBufferToEnd` instead.", - migrate: Float32Array.fromBufferToEnd(~byteOffset=%insert.unlabelledArgument(1)), - }) - external fromBufferOffset: (array_buffer, int) => t = "Float32Array" - - /** - **throw** Js.Exn.Error throws Js exception - - **param** offset is in bytes, length in elements - */ - @new - @deprecated({ - reason: "Use `Float32Array.fromBufferWithRange` instead.", - migrate: Float32Array.fromBufferWithRange( - ~byteOffset=%insert.labelledArgument("offset"), - ~length=%insert.labelledArgument("length"), - ), - }) - external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Float32Array" - - @deprecated({ - reason: "Use `Float32Array.fromLength` instead.", - migrate: Float32Array.fromLength(), - }) - @new - external fromLength: int => t = "Float32Array" - @deprecated({ - reason: "Use `Float32Array.fromArrayLikeOrIterable` instead.", - migrate: Float32Array.fromArrayLikeOrIterable(), - }) - @val - external from: array_like => t = "Float32Array.from" - /* *Array.of is redundant, use make */ -} - -module Float64Array = { - /** */ - type elt = float - type typed_array<'a> - type t = typed_array - - @get_index external unsafe_get: (t, int) => elt = "" - @set_index external unsafe_set: (t, int, elt) => unit = "" - - @get external buffer: t => array_buffer = "buffer" - @get external byteLength: t => int = "byteLength" - @get external byteOffset: t => int = "byteOffset" - - @deprecated({reason: "Use `TypedArray.setArray` instead.", migrate: TypedArray.setArray()}) @send - external setArray: (t, array) => unit = "set" - @deprecated({ - reason: "Use `TypedArray.setArrayFrom` instead.", - migrate: TypedArray.setArrayFrom(%insert.unlabelledArgument(2)), - }) - @send - external setArrayOffset: (t, array, int) => unit = "set" - /* There's also an overload for typed arrays, but don't know how to model that without subtyping */ - - /* Array interface(-ish) */ - @deprecated({reason: "Use `TypedArray.length` instead.", migrate: TypedArray.length()}) @get - external length: t => int = "length" - - /* Mutator functions */ - @deprecated({ - reason: "Use `TypedArray.copyAllWithin` instead.", - migrate: TypedArray.copyAllWithin(~target=%insert.labelledArgument("to_")), - }) - @send - external copyWithin: (t, ~to_: int) => t = "copyWithin" - @deprecated({ - reason: "Use `TypedArray.copyWithinToEnd` instead.", - migrate: TypedArray.copyWithinToEnd( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("from"), - ), - }) - @send - external copyWithinFrom: (t, ~to_: int, ~from: int) => t = "copyWithin" - @deprecated({ - reason: "Use `TypedArray.copyWithin` instead.", - migrate: TypedArray.copyWithin( - ~target=%insert.labelledArgument("to_"), - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - @send - external copyWithinFromRange: (t, ~to_: int, ~start: int, ~end_: int) => t = "copyWithin" - - @deprecated({reason: "Use `TypedArray.fillAll` instead.", migrate: TypedArray.fillAll()}) @send - external fillInPlace: (t, elt) => t = "fill" - @deprecated({ - reason: "Use `TypedArray.fillToEnd` instead.", - migrate: TypedArray.fillToEnd(~start=%insert.labelledArgument("from")), - }) - @send - external fillFromInPlace: (t, elt, ~from: int) => t = "fill" - @deprecated({ - reason: "Use `TypedArray.fill` instead.", - migrate: TypedArray.fill( - ~start=%insert.labelledArgument("start"), - ~end=%insert.labelledArgument("end_"), - ), - }) - @send - external fillRangeInPlace: (t, elt, ~start: int, ~end_: int) => t = "fill" - - @deprecated({reason: "Use `TypedArray.reverse` instead.", migrate: TypedArray.reverse()}) @send - external reverseInPlace: t => t = "reverse" - - @deprecated({ - reason: "Use `TypedArray.toSorted` instead.", - migrate: TypedArray.toSorted((a, b) => - %todo_( - "This needs a comparator function. Use an appropriate comparator (e.g. Float.compare)." - ) - ), - }) - @send - external sortInPlace: t => t = "sort" - @deprecated({reason: "Use `TypedArray.sort` instead.", migrate: TypedArray.sort()}) @send - external sortInPlaceWith: (t, (elt, elt) => int) => t = "sort" - - /* Accessor functions */ - @deprecated({reason: "Use `TypedArray.includes` instead.", migrate: TypedArray.includes()}) @send - external includes: (t, elt) => bool = "includes" /* ES2016 */ - - @deprecated({reason: "Use `TypedArray.indexOf` instead.", migrate: TypedArray.indexOf()}) @send - external indexOf: (t, elt) => int = "indexOf" - @deprecated({ - reason: "Use `TypedArray.indexOfFrom` instead.", - migrate: TypedArray.indexOfFrom(%insert.labelledArgument("from")), - }) - @send - external indexOfFrom: (t, elt, ~from: int) => int = "indexOf" - - @deprecated({reason: "Use `TypedArray.joinWith` instead.", migrate: TypedArray.joinWith(",")}) - @send - external join: t => string = "join" - @deprecated({reason: "Use `TypedArray.joinWith` instead.", migrate: TypedArray.joinWith()}) @send - external joinWith: (t, string) => string = "join" - - @deprecated({reason: "Use `TypedArray.lastIndexOf` instead.", migrate: TypedArray.lastIndexOf()}) - @send - external lastIndexOf: (t, elt) => int = "lastIndexOf" - @deprecated({ - reason: "Use `TypedArray.lastIndexOfFrom` instead.", - migrate: TypedArray.lastIndexOfFrom(%insert.labelledArgument("from")), - }) - @send - external lastIndexOfFrom: (t, elt, ~from: int) => int = "lastIndexOf" - - /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.slice` instead.", - migrate: TypedArray.slice(~end=%insert.labelledArgument("end_")), - }) - @send external slice: (t, ~start: int, ~end_: int) => t = "slice" - - @deprecated({reason: "Use `TypedArray.copy` instead.", migrate: TypedArray.copy()}) @send - external copy: t => t = "slice" - @deprecated({ - reason: "Use `TypedArray.sliceToEnd` instead.", - migrate: TypedArray.sliceToEnd(~start=%insert.unlabelledArgument(1)), - }) - @send - external sliceFrom: (t, int) => t = "slice" - - /** `start` is inclusive, `end_` exclusive */ - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~end=%insert.labelledArgument("end_")), - }) - @send external subarray: (t, ~start: int, ~end_: int) => t = "subarray" - - @deprecated({ - reason: "Use `TypedArray.subarray` instead.", - migrate: TypedArray.subarray(~start=%insert.unlabelledArgument(1)), - }) - @send - external subarrayFrom: (t, int) => t = "subarray" - - @deprecated({reason: "Use `TypedArray.toString` instead.", migrate: TypedArray.toString()}) @send - external toString: t => string = "toString" - @deprecated({ - reason: "Use `TypedArray.toLocaleString` instead.", - migrate: TypedArray.toLocaleString(), - }) - @send - external toLocaleString: t => string = "toLocaleString" - - /* Iteration functions */ - /* commented out until bs has a plan for iterators - external entries : t -> (int * elt) array_iter = "" [@@send] - */ - @deprecated({reason: "Use `TypedArray.every` instead.", migrate: TypedArray.every()}) @send - external every: (t, elt => bool) => bool = "every" - @deprecated({ - reason: "Use `TypedArray.everyWithIndex` instead.", - migrate: TypedArray.everyWithIndex(), - }) - @send - external everyi: (t, (elt, int) => bool) => bool = "every" - - @deprecated({reason: "Use `TypedArray.filter` instead.", migrate: TypedArray.filter()}) @send - external filter: (t, elt => bool) => t = "filter" - @deprecated({ - reason: "Use `TypedArray.filterWithIndex` instead.", - migrate: TypedArray.filterWithIndex(), - }) - @send - external filteri: (t, (elt, int) => bool) => t = "filter" - - @deprecated({reason: "Use `TypedArray.find` instead.", migrate: TypedArray.find()}) @send - external find: (t, elt => bool) => Js_undefined.t = "find" - @deprecated({ - reason: "Use `TypedArray.findWithIndex` instead.", - migrate: TypedArray.findWithIndex(), - }) - @send - external findi: (t, (elt, int) => bool) => Js_undefined.t = "find" - - @deprecated({reason: "Use `TypedArray.findIndex` instead.", migrate: TypedArray.findIndex()}) - @send - external findIndex: (t, elt => bool) => int = "findIndex" - @deprecated({ - reason: "Use `TypedArray.findIndexWithIndex` instead.", - migrate: TypedArray.findIndexWithIndex(), - }) - @send - external findIndexi: (t, (elt, int) => bool) => int = "findIndex" - - @deprecated({reason: "Use `TypedArray.forEach` instead.", migrate: TypedArray.forEach()}) @send - external forEach: (t, elt => unit) => unit = "forEach" - @deprecated({ - reason: "Use `TypedArray.forEachWithIndex` instead.", - migrate: TypedArray.forEachWithIndex(), - }) - @send - external forEachi: (t, (elt, int) => unit) => unit = "forEach" - - /* commented out until bs has a plan for iterators - external keys : t -> int array_iter = "" [@@send] - */ - - @deprecated({reason: "Use `TypedArray.map` instead.", migrate: TypedArray.map()}) @send - external map: (t, elt => 'b) => typed_array<'b> = "map" - @deprecated({ - reason: "Use `TypedArray.mapWithIndex` instead.", - migrate: TypedArray.mapWithIndex(), - }) - @send - external mapi: (t, (elt, int) => 'b) => typed_array<'b> = "map" - - @deprecated({reason: "Use `TypedArray.reduce` instead.", migrate: TypedArray.reduce()}) @send - external reduce: (t, ('b, elt) => 'b, 'b) => 'b = "reduce" - @deprecated({ - reason: "Use `TypedArray.reduceWithIndex` instead.", - migrate: TypedArray.reduceWithIndex(), - }) - @send - external reducei: (t, ('b, elt, int) => 'b, 'b) => 'b = "reduce" - - @deprecated({reason: "Use `TypedArray.reduceRight` instead.", migrate: TypedArray.reduceRight()}) - @send - external reduceRight: (t, ('b, elt) => 'b, 'b) => 'b = "reduceRight" - @deprecated({ - reason: "Use `TypedArray.reduceRightWithIndex` instead.", - migrate: TypedArray.reduceRightWithIndex(), - }) - @send - external reduceRighti: (t, ('b, elt, int) => 'b, 'b) => 'b = "reduceRight" - - @deprecated({reason: "Use `TypedArray.some` instead.", migrate: TypedArray.some()}) @send - external some: (t, elt => bool) => bool = "some" - @deprecated({ - reason: "Use `TypedArray.someWithIndex` instead.", - migrate: TypedArray.someWithIndex(), - }) - @send - external somei: (t, (elt, int) => bool) => bool = "some" - - @deprecated({ - reason: "Use `Float64Array.Constants.bytesPerElement` instead.", - migrate: Float64Array.Constants.bytesPerElement, - }) - @val - external _BYTES_PER_ELEMENT: int = "Float64Array.BYTES_PER_ELEMENT" - - @deprecated({reason: "Use `Float64Array.fromArray` instead.", migrate: Float64Array.fromArray()}) - @new - external make: array => t = "Float64Array" - /** can throw */ - @new - @deprecated({ - reason: "Use `Float64Array.fromBuffer` instead.", - migrate: Float64Array.fromBuffer(), - }) - external fromBuffer: array_buffer => t = "Float64Array" - - /** - **throw** Js.Exn.Error throw Js exception - - **param** offset is in bytes - */ - @new - @deprecated({ - reason: "Use `Float64Array.fromBufferToEnd` instead.", - migrate: Float64Array.fromBufferToEnd(~byteOffset=%insert.unlabelledArgument(1)), - }) - external fromBufferOffset: (array_buffer, int) => t = "Float64Array" - - /** - **throw** Js.Exn.Error throws Js exception - - **param** offset is in bytes, length in elements - */ - @new - @deprecated({ - reason: "Use `Float64Array.fromBufferWithRange` instead.", - migrate: Float64Array.fromBufferWithRange( - ~byteOffset=%insert.labelledArgument("offset"), - ~length=%insert.labelledArgument("length"), - ), - }) - external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "Float64Array" - - @deprecated({ - reason: "Use `Float64Array.fromLength` instead.", - migrate: Float64Array.fromLength(), - }) - @new - external fromLength: int => t = "Float64Array" - @deprecated({ - reason: "Use `Float64Array.fromArrayLikeOrIterable` instead.", - migrate: Float64Array.fromArrayLikeOrIterable(), - }) - @val - external from: array_like => t = "Float64Array.from" - /* *Array.of is redundant, use make */ -} - -/** -The DataView view provides a low-level interface for reading and writing -multiple number types in an ArrayBuffer irrespective of the platform's endianness. - -**see** [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView) -*/ -module DataView = { - type t - - @new external make: array_buffer => t = "DataView" - @new external fromBuffer: array_buffer => t = "DataView" - @new external fromBufferOffset: (array_buffer, int) => t = "DataView" - @new external fromBufferRange: (array_buffer, ~offset: int, ~length: int) => t = "DataView" - - @get external buffer: t => array_buffer = "buffer" - @get external byteLength: t => int = "byteLength" - @get external byteOffset: t => int = "byteOffset" - - @send external getInt8: (t, int) => int = "getInt8" - @send external getUint8: (t, int) => int = "getUint8" - - @send external getInt16: (t, int) => int = "getInt16" - @send external getInt16LittleEndian: (t, int, @as(1) _) => int = "getInt16" - - @send external getUint16: (t, int) => int = "getUint16" - @send external getUint16LittleEndian: (t, int, @as(1) _) => int = "getUint16" - - @send external getInt32: (t, int) => int = "getInt32" - @send external getInt32LittleEndian: (t, int, @as(1) _) => int = "getInt32" - - @send external getUint32: (t, int) => int = "getUint32" - @send external getUint32LittleEndian: (t, int, @as(1) _) => int = "getUint32" - - @send external getFloat32: (t, int) => float = "getFloat32" - @send external getFloat32LittleEndian: (t, int, @as(1) _) => float = "getFloat32" - - @send external getFloat64: (t, int) => float = "getFloat64" - @send external getFloat64LittleEndian: (t, int, @as(1) _) => float = "getFloat64" - - @send external setInt8: (t, int, int) => unit = "setInt8" - @send external setUint8: (t, int, int) => unit = "setUint8" - - @send external setInt16: (t, int, int) => unit = "setInt16" - @send external setInt16LittleEndian: (t, int, int, @as(1) _) => unit = "setInt16" - - @send external setUint16: (t, int, int) => unit = "setUint16" - @send external setUint16LittleEndian: (t, int, int, @as(1) _) => unit = "setUint16" - - @send external setInt32: (t, int, int) => unit = "setInt32" - @send external setInt32LittleEndian: (t, int, int, @as(1) _) => unit = "setInt32" - - @send external setUint32: (t, int, int) => unit = "setUint32" - @send external setUint32LittleEndian: (t, int, int, @as(1) _) => unit = "setUint32" - - @send external setFloat32: (t, int, float) => unit = "setFloat32" - @send external setFloat32LittleEndian: (t, int, float, @as(1) _) => unit = "setFloat32" - - @send external setFloat64: (t, int, float) => unit = "setFloat64" - @send external setFloat64LittleEndian: (t, int, float, @as(1) _) => unit = "setFloat64" -} diff --git a/packages/@rescript/runtime/Js_types.res b/packages/@rescript/runtime/Js_types.res deleted file mode 100644 index 8f3d0130306..00000000000 --- a/packages/@rescript/runtime/Js_types.res +++ /dev/null @@ -1,81 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/** Js symbol type only available in ES6 */ -type symbol = Stdlib_Symbol.t - -type obj_val = Stdlib_Type.Classify.object - -/** This type has only one value `undefined` */ -type undefined_val - -/** This type has only one value `null` */ -type null_val - -type function_val = Stdlib_Type.Classify.function - -type rec t<_> = - | Undefined: t - | Null: t - | Boolean: t - | Number: t - | String: t - | Function: t - | Object: t - | Symbol: t - | BigInt: t - -type tagged_t = - | JSFalse - | JSTrue - | JSNull - | JSUndefined - | JSNumber(float) - | JSString(string) - | JSFunction(function_val) - | JSObject(obj_val) - | JSSymbol(symbol) - | JSBigInt(bigint) - -let classify = (x: 'a): tagged_t => { - let ty = Js_extern.typeof(x) - if ty == "undefined" { - JSUndefined - } else if x === Obj.magic(Js_null.empty) { - JSNull - } else if ty == "number" { - JSNumber(Obj.magic(x)) - } else if ty == "bigint" { - JSBigInt(Obj.magic(x)) - } else if ty == "string" { - JSString(Obj.magic(x)) - } else if ty == "boolean" { - if Obj.magic(x) == true { - JSTrue - } else { - JSFalse - } - } else if ty == "symbol" { - JSSymbol(Obj.magic(x)) - } else if ty == "function" { - JSFunction(Obj.magic(x)) - } else { - JSObject(Obj.magic(x)) - } -} - -let test = (type a, x: 'a, v: t): bool => - switch v { - | Number => Js_extern.typeof(x) == "number" - | Boolean => Js_extern.typeof(x) == "boolean" - | Undefined => Js_extern.typeof(x) == "undefined" - | Null => x === Obj.magic(Js_null.empty) - | String => Js_extern.typeof(x) == "string" - | Function => Js_extern.typeof(x) == "function" - | Object => Js_extern.typeof(x) == "object" - | Symbol => Js_extern.typeof(x) == "symbol" - | BigInt => Js_extern.typeof(x) == "bigint" - } diff --git a/packages/@rescript/runtime/Js_types.resi b/packages/@rescript/runtime/Js_types.resi deleted file mode 100644 index a2d111d14fa..00000000000 --- a/packages/@rescript/runtime/Js_types.resi +++ /dev/null @@ -1,89 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** Provide utilities for manipulating JS types. */ - -/** Js symbol type (only available in ES6) */ -@deprecated({ - reason: "Use `Symbol.t` instead.", - migrate: %replace.type(: Symbol.t), -}) -type symbol = Stdlib_Symbol.t - -@deprecated({ - reason: "Use `Type.Classify.object` instead.", - migrate: %replace.type(: Type.Classify.object), -}) -type obj_val = Stdlib_Type.Classify.object - -/** This type has only one value `undefined` */ -@deprecated( - "This has been deprecated and will be removed in v13. Use functions and types from the `Type` module instead." -) -type undefined_val - -/** This type has only one value `null` */ -@deprecated( - "This has been deprecated and will be removed in v13. Use functions and types from the `Type` module instead." -) -type null_val - -@deprecated({ - reason: "Use `Type.Classify.function` instead.", - migrate: %replace.type(: Type.Classify.function), -}) -type function_val = Stdlib_Type.Classify.function - -@deprecated( - "This has been deprecated and will be removed in v13. Use functions and types from the `Type` module instead." -) -type rec t<_> = - | Undefined: t - | Null: t - | Boolean: t - | Number: t - | String: t - | Function: t - | Object: t - | Symbol: t - | BigInt: t - -/** -`test(value, t)` returns `true` if `value` is `typeof t`, otherwise `false`. -This is useful for doing runtime reflection on any given value. - -## Examples - -```rescript -test("test", String) == true -test(() => true, Function) == true -test("test", Boolean) == false -``` -*/ -@deprecated( - "This has been deprecated and will be removed in v13. Use functions and types from the `Type` module instead." -) -let test: ('a, t<'b>) => bool - -@deprecated( - "This has been deprecated and will be removed in v13. Use functions and types from the `Type` module instead." -) -type tagged_t = - | JSFalse - | JSTrue - | JSNull - | JSUndefined - | JSNumber(float) - | JSString(string) - | JSFunction(function_val) - | JSObject(obj_val) - | JSSymbol(symbol) - | JSBigInt(bigint) - -@deprecated( - "This has been deprecated and will be removed in v13. Use functions and types from the `Type` module instead." -) -let classify: 'a => tagged_t diff --git a/packages/@rescript/runtime/Js_undefined.res b/packages/@rescript/runtime/Js_undefined.res deleted file mode 100644 index e5300bd4871..00000000000 --- a/packages/@rescript/runtime/Js_undefined.res +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** Provides functionality for dealing with the `'a Js.undefined` type */ - -type t<+'a> = Primitive_js_extern.undefined<'a> - -let to_opt: t<'a> => option<'a> = Primitive_option.fromUndefined -let toOption: t<'a> => option<'a> = Primitive_option.fromUndefined - -external return: 'a => t<'a> = "%identity" - -external empty: t<'a> = "%undefined" -let test: t<'a> => bool = x => x == empty -let testAny: 'a => bool = x => Obj.magic(x) == empty -external getUnsafe: t<'a> => 'a = "%identity" - -let getExn = f => - switch toOption(f) { - | None => Stdlib_Exn.raiseError("Js.Undefined.getExn") - | Some(x) => x - } - -let bind = (x, f) => - switch to_opt(x) { - | None => empty - | Some(x) => return(f(x)) - } - -let iter = (x, f) => - switch to_opt(x) { - | None => () - | Some(x) => f(x) - } - -let fromOption = x => - switch x { - | None => empty - | Some(x) => return(x) - } - -let from_opt = fromOption diff --git a/packages/@rescript/runtime/Js_undefined.resi b/packages/@rescript/runtime/Js_undefined.resi deleted file mode 100644 index 1af85331153..00000000000 --- a/packages/@rescript/runtime/Js_undefined.resi +++ /dev/null @@ -1,123 +0,0 @@ -/* Copyright (C) 2015-2016 Bloomberg Finance L.P. - * Copyright (C) 2017- Hongbo Zhang, Authors of ReScript - * - * SPDX-License-Identifier: MIT - */ - -/*** Provides functionality for dealing with the `Js.undefined<'a>` type */ - -/** Local alias for `Js.undefined<'a>` */ -@deprecated({ - reason: "Use `undefined` directly instead.", - migrate: %replace.type(: undefined), -}) -type t<+'a> = Primitive_js_extern.undefined<'a> - -/** Constructs a value of `Js.undefined<'a>` containing a value of `'a`. */ -@deprecated({ - reason: "Use `Nullable.make` or `option` directly instead.", - migrate: Nullable.make(), -}) -external return: 'a => t<'a> = "%identity" - -/** Returns `true` if the given value is empty (undefined), `false` otherwise. */ -@deprecated -let test: t<'a> => bool - -/** -Returns `true` if the given value is empty (undefined). - -**since 1.6.1** -*/ -@deprecated -let testAny: 'a => bool - -/** The empty value, `undefined` */ -@deprecated({ - reason: "Use `Nullable.undefined` instead.", - migrate: Nullable.undefined, -}) -external empty: t<'a> = "%undefined" - -@deprecated({ - reason: "Use `Nullable.getUnsafe` instead.", - migrate: Nullable.getUnsafe(), -}) -external getUnsafe: t<'a> => 'a = "%identity" - -@deprecated({ - reason: "Use `Nullable.getOrThrow` instead.", - migrate: Nullable.getOrThrow(), -}) -let getExn: t<'a> => 'a - -/** -Maps the contained value using the given function. -If `Js.undefined<'a>` contains a value, that value is unwrapped, mapped to a -`'b` using the given function `a' => 'b`, then wrapped back up and returned as -`Js.undefined<'b>`. - -## Examples - -```rescript -let maybeGreetWorld = (maybeGreeting: Js.undefined) => - Js.Undefined.bind(maybeGreeting, greeting => greeting ++ " world!") -``` -*/ -@deprecated({ - reason: "Use `Nullable.map` instead.", - migrate: Nullable.map(), -}) -let bind: (t<'a>, 'a => 'b) => t<'b> - -/** -Iterates over the contained value with the given function. If -`Js.undefined<'a>` contains a value, that value is unwrapped and applied to the -given function. - -## Examples - -```rescript -let maybeSay = (maybeMessage: Js.undefined) => - Js.Undefined.iter(maybeMessage, message => Js.log(message)) -``` -*/ -@deprecated({ - reason: "Use `Nullable.forEach` instead.", - migrate: Nullable.forEach(), -}) -let iter: (t<'a>, 'a => unit) => unit - -/** -Maps `option<'a>` to `Js.undefined<'a>`. -`Some(a)` => `a` -`None` => `empty` -*/ -@deprecated({ - reason: "Use `Nullable.fromOption` instead.", - migrate: Nullable.fromOption(), -}) -let fromOption: option<'a> => t<'a> - -@deprecated({ - reason: "Use `Nullable.fromOption` instead.", - migrate: Nullable.fromOption(), -}) -let from_opt: option<'a> => t<'a> - -/** -Maps `Js.undefined<'a>` to `option<'a>` -`a` => `Some(a)` -`empty` => `None` -*/ -@deprecated({ - reason: "Use `Nullable.toOption` instead.", - migrate: Nullable.toOption(), -}) -let toOption: t<'a> => option<'a> - -@deprecated({ - reason: "Use `Nullable.toOption` instead.", - migrate: Nullable.toOption(), -}) -let to_opt: t<'a> => option<'a> diff --git a/packages/@rescript/runtime/Js_weakmap.res b/packages/@rescript/runtime/Js_weakmap.res deleted file mode 100644 index c034ba108ef..00000000000 --- a/packages/@rescript/runtime/Js_weakmap.res +++ /dev/null @@ -1,7 +0,0 @@ -/*** ES6 WeakMap API */ - -@deprecated({ - reason: "Use `WeakMap.t` instead.", - migrate: %replace.type(: WeakMap.t), -}) -type t<'k, 'v> = Stdlib_WeakMap.t<'k, 'v> diff --git a/packages/@rescript/runtime/Js_weakset.res b/packages/@rescript/runtime/Js_weakset.res deleted file mode 100644 index bb5851460f3..00000000000 --- a/packages/@rescript/runtime/Js_weakset.res +++ /dev/null @@ -1,7 +0,0 @@ -/*** ES6 WeakSet API */ - -@deprecated({ - reason: "Use `WeakSet.t` instead.", - migrate: %replace.type(: WeakSet.t), -}) -type t<'a> = Stdlib_WeakSet.t<'a> diff --git a/packages/@rescript/runtime/Primitive_curry.res b/packages/@rescript/runtime/Primitive_curry.res index 5d4ed8eb650..9bf7acb6fb2 100644 --- a/packages/@rescript/runtime/Primitive_curry.res +++ b/packages/@rescript/runtime/Primitive_curry.res @@ -6,14 +6,13 @@ module Array = Primitive_array_extern module Obj = Primitive_object_extern -module Js = Primitive_js_extern @@uncurried external function_arity: 'a => int = "%function_arity" -@send external apply_args: ('a => 'b, Js.null<_>, array<_>) => 'b = "apply" -let apply_args = (f, args) => apply_args(f, Js.null, args) +@send external apply_args: ('a => 'b, Primitive_js_extern.null<_>, array<_>) => 'b = "apply" +let apply_args = (f, args) => apply_args(f, Primitive_js_extern.null, args) /* Public */ let rec app = (f, args) => { diff --git a/packages/@rescript/runtime/Primitive_exceptions.res b/packages/@rescript/runtime/Primitive_exceptions.res index 07e5c5e441c..22d8384cad6 100644 --- a/packages/@rescript/runtime/Primitive_exceptions.res +++ b/packages/@rescript/runtime/Primitive_exceptions.res @@ -5,7 +5,6 @@ */ module Obj = Primitive_object_extern -module Js = Primitive_js_extern type t = {@as("RE_EXN_ID") id: string} @@ -25,12 +24,12 @@ type js_error = {cause: exn} {[ match toExn x : exn option with | Some _ - -> Js.log "Could be an OCaml exception or an open variant" + -> Console.log "Could be an OCaml exception or an open variant" (* If it is an Open variant, it will never pattern match, This is Okay, since exception could never have exhaustive pattern match *) - | None -> Js.log "Not an OCaml exception for sure" + | None -> Console.log "Not an OCaml exception for sure" ]} However, there is still something wrong, since if user write such code @@ -44,10 +43,10 @@ type js_error = {cause: exn} This is not a problem in `try .. with` since the logic above is not expressible, see more design in [destruct_exn.md] */ let isExtension = (type a, e: a): bool => - if Js.testAny(e) { + if Primitive_js_extern.testAny(e) { false } else { - Js.typeof((Obj.magic(e): t).id) == "string" + Primitive_js_extern.typeof((Obj.magic(e): t).id) == "string" } /** @@ -69,7 +68,7 @@ module Dict = { external set: (dict<'a>, string, 'a) => unit = "" /** - It's the same as `Js.Dict.get` but it doesn't have runtime overhead to check if the key exists. + It's the same as `Dict.get` but it doesn't have runtime overhead to check if the key exists. */ @get_index external dangerouslyGetNonOption: (dict<'a>, string) => option<'a> = "" diff --git a/packages/@rescript/runtime/Primitive_hash.res b/packages/@rescript/runtime/Primitive_hash.res index c99748909ad..7392af626b3 100644 --- a/packages/@rescript/runtime/Primitive_hash.res +++ b/packages/@rescript/runtime/Primitive_hash.res @@ -6,9 +6,12 @@ module Float = Primitive_float_extern module Obj = Primitive_object_extern -module Js = Primitive_js_extern module String = Primitive_string_extern +// Note: this only works as intended as long as the runtime is compiled +// with -bs-cross-module-opt. +let typeof = Primitive_js_extern.typeof + @send external charCodeAt: (string, int) => int = "charCodeAt" // Multiply int32 with C-style overflow behavior @@ -120,11 +123,11 @@ let hash_mix_string = (h, s) => { let hash = (count: int, _limit, seed: int, obj: Obj.t): int => { let s = ref(seed) - if Js.typeof(obj) == "number" { + if typeof(obj) == "number" { let u = Float.toInt(Obj.magic(obj)) s.contents = hash_mix_int(s.contents, u + u + 1) hash_final_mix(s.contents) - } else if Js.typeof(obj) == "string" { + } else if typeof(obj) == "string" { s.contents = hash_mix_string(s.contents, (Obj.magic(obj): string)) hash_final_mix(s.contents) } else { @@ -139,20 +142,20 @@ let hash = (count: int, _limit, seed: int, obj: Obj.t): int => { while !is_empty_queue(queue) && num.contents > 0 { let obj = unsafe_pop(queue) - if Js.typeof(obj) == "number" { + if typeof(obj) == "number" { let u = Float.toInt(Obj.magic(obj)) s.contents = hash_mix_int(s.contents, u + u + 1) num.contents = num.contents - 1 - } else if Js.typeof(obj) == "string" { + } else if typeof(obj) == "string" { s.contents = hash_mix_string(s.contents, (Obj.magic(obj): string)) num.contents = num.contents - 1 - } else if Js.typeof(obj) == "boolean" { + } else if typeof(obj) == "boolean" { () - } else if Js.typeof(obj) == "undefined" { + } else if typeof(obj) == "undefined" { () - } else if Js.typeof(obj) == "symbol" { + } else if typeof(obj) == "symbol" { () - } else if Js.typeof(obj) == "function" { + } else if typeof(obj) == "function" { () } else { let size = Obj.size(obj) diff --git a/packages/@rescript/runtime/Primitive_js_extern.res b/packages/@rescript/runtime/Primitive_js_extern.res index 2b9ea278b5e..3d028e71e86 100644 --- a/packages/@rescript/runtime/Primitive_js_extern.res +++ b/packages/@rescript/runtime/Primitive_js_extern.res @@ -1,3 +1,5 @@ +@@config({flags: ["-unboxed-types"]}) + @unboxed type null<+'a> = Value('a) | @as(null) Null @@ -30,3 +32,30 @@ external le: ('a, 'a) => bool = "%unsafe_le" external gt: ('a, 'a) => bool = "%unsafe_gt" external ge: ('a, 'a) => bool = "%unsafe_ge" + +external unsafe_to_method: 'a => 'a = "%unsafe_to_method" + +module Callback = { + type arity1<'a> = {@internal i1: 'a} + type arity2<'a> = {@internal i2: 'a} + type arity3<'a> = {@internal i3: 'a} + type arity4<'a> = {@internal i4: 'a} + type arity5<'a> = {@internal i5: 'a} + type arity6<'a> = {@internal i6: 'a} + type arity7<'a> = {@internal i7: 'a} + type arity8<'a> = {@internal i8: 'a} + type arity9<'a> = {@internal i9: 'a} + type arity10<'a> = {@internal i10: 'a} + type arity11<'a> = {@internal i11: 'a} + type arity12<'a> = {@internal i12: 'a} + type arity13<'a> = {@internal i13: 'a} + type arity14<'a> = {@internal i14: 'a} + type arity15<'a> = {@internal i15: 'a} + type arity16<'a> = {@internal i16: 'a} + type arity17<'a> = {@internal i17: 'a} + type arity18<'a> = {@internal i18: 'a} + type arity19<'a> = {@internal i19: 'a} + type arity20<'a> = {@internal i20: 'a} + type arity21<'a> = {@internal i21: 'a} + type arity22<'a> = {@internal i22: 'a} +} diff --git a/packages/@rescript/runtime/Primitive_object.res b/packages/@rescript/runtime/Primitive_object.res index 2973b283ad5..6e87a714042 100644 --- a/packages/@rescript/runtime/Primitive_object.res +++ b/packages/@rescript/runtime/Primitive_object.res @@ -5,7 +5,6 @@ */ module Array = Primitive_array_extern -module Js = Primitive_js_extern type t = Primitive_object_extern.t @@ -15,6 +14,7 @@ let repr = Primitive_object_extern.repr let magic = Primitive_object_extern.magic let tag = Primitive_object_extern.tag let size = Primitive_object_extern.size +let typeof = Primitive_js_extern.typeof module O = { @val external isArray: 'a => bool = "Array.isArray" @@ -60,8 +60,8 @@ let rec compare = (a: t, b: t): int => 0 } else { /* front and formoest, we do not compare function values */ - let a_type = Js.typeof(a) - let b_type = Js.typeof(b) + let a_type = typeof(a) + let b_type = typeof(b) switch (a_type, b_type) { | ("undefined", _) => -1 | (_, "undefined") => 1 @@ -82,27 +82,27 @@ let rec compare = (a: t, b: t): int => | ("number", "number") => Pervasives.compare((magic(a): float), (magic(b): float)) | ("number", _) => - if b === repr(Js.null) || Primitive_option.isNested(b) { + if b === repr(Primitive_js_extern.null) || Primitive_option.isNested(b) { 1 } else { /* Some (Some ..) < x */ -1 } /* Integer < Block in OCaml runtime GPR #1195, except Some.. */ | (_, "number") => - if a === repr(Js.null) || Primitive_option.isNested(a) { + if a === repr(Primitive_js_extern.null) || Primitive_option.isNested(a) { -1 } else { 1 } | _ => - if a === repr(Js.null) { + if a === repr(Primitive_js_extern.null) { /* [b] could not be null otherwise would equal */ if Primitive_option.isNested(b) { 1 } else { -1 } - } else if b === repr(Js.null) { + } else if b === repr(Primitive_js_extern.null) { if Primitive_option.isNested(a) { -1 } else { @@ -230,7 +230,7 @@ let rec equal = (a: t, b: t): bool => if a === b { true } else { - let a_type = Js.typeof(a) + let a_type = typeof(a) if ( a_type == "string" || (a_type == "number" || @@ -240,7 +240,7 @@ let rec equal = (a: t, b: t): bool => ) { false } else { - let b_type = Js.typeof(b) + let b_type = typeof(b) if a_type == "function" || b_type == "function" { throw(Invalid_argument("equal: functional value")) } /* first, check using reference equality */ @@ -262,7 +262,7 @@ let rec equal = (a: t, b: t): bool => if O.isArray(a) { aux_equal_length((magic(a): array), (magic(b): array), 0, len_a) } else if %raw(`a instanceof Date && b instanceof Date`) { - !(Js.gt(a, b) || Js.lt(a, b)) + !(Primitive_js_extern.gt(a, b) || Primitive_js_extern.lt(a, b)) } else { aux_obj_equal(a, b) } @@ -302,7 +302,7 @@ and aux_obj_equal = (a: t, b: t) => { } @inline -let isNumberOrBigInt = a => Js.typeof(a) == "number" || Js.typeof(a) == "bigint" +let isNumberOrBigInt = a => typeof(a) == "number" || typeof(a) == "bigint" @inline let canNumericCompare = (a, b) => isNumberOrBigInt(a) && isNumberOrBigInt(b) diff --git a/packages/@rescript/runtime/Primitive_option.res b/packages/@rescript/runtime/Primitive_option.res index c558085d631..058e70071d0 100644 --- a/packages/@rescript/runtime/Primitive_option.res +++ b/packages/@rescript/runtime/Primitive_option.res @@ -5,41 +5,40 @@ */ module Obj = Primitive_object_extern -module Js = Primitive_js_extern type nested = {@as("BS_PRIVATE_NESTED_SOME_NONE") depth: int} /* INPUT: [x] should not be nullable */ let isNested = (x: Obj.t): bool => { - Obj.repr((Obj.magic(x): nested).depth) !== Obj.repr(Js.undefined) + Obj.repr((Obj.magic(x): nested).depth) !== Obj.repr(Primitive_js_extern.undefined) } let some = (x: Obj.t): Obj.t => if Obj.magic(x) == None { Obj.repr({depth: 0}) } /* [x] is neither None nor null so it is safe to do property access */ - else if x !== Obj.repr(Js.null) && isNested(x) { + else if x !== Obj.repr(Primitive_js_extern.null) && isNested(x) { Obj.repr({depth: (Obj.magic(x): nested).depth + 1}) } else { x } -let fromNullable = (type t, x: Js.nullable): option => - if Js.isNullable(x) { +let fromNullable = (type t, x: Primitive_js_extern.nullable): option => + if Primitive_js_extern.isNullable(x) { None } else { Obj.magic(some((Obj.magic(x): 'a))) } -let fromUndefined = (type t, x: Js.undefined): option => - if Obj.magic(x) === Js.undefined { +let fromUndefined = (type t, x: Primitive_js_extern.undefined): option => + if Obj.magic(x) === Primitive_js_extern.undefined { None } else { Obj.magic(some((Obj.magic(x): 'a))) } -let fromNull = (type t, x: Js.null): option => - if Obj.magic(x) === Js.null { +let fromNull = (type t, x: Primitive_js_extern.null): option => + if Obj.magic(x) === Primitive_js_extern.null { None } else { Obj.magic(some((Obj.magic(x): 'a))) @@ -51,7 +50,7 @@ let fromNull = (type t, x: Js.null): option => /** Preserves `None`/`undefined` and unwraps one outer option layer. Nested `Some` values stay encoded one level deeper. */ let valFromOption = (x: Obj.t): Obj.t => - if x !== Obj.repr(Js.null) && isNested(x) { + if x !== Obj.repr(Primitive_js_extern.null) && isNested(x) { let {depth}: nested = Obj.magic(x) if depth == 0 { Obj.magic(None) diff --git a/packages/@rescript/runtime/Primitive_util.res b/packages/@rescript/runtime/Primitive_util.res index f2a5bd7e5c6..da11eb8a98c 100644 --- a/packages/@rescript/runtime/Primitive_util.res +++ b/packages/@rescript/runtime/Primitive_util.res @@ -1,7 +1,5 @@ -module Js = Primitive_js_extern - let raiseWhenNotFound = x => - if Js.testAny(x) { + if Primitive_js_extern.testAny(x) { throw(Not_found) } else { x diff --git a/packages/@rescript/runtime/Primitive_util.resi b/packages/@rescript/runtime/Primitive_util.resi new file mode 100644 index 00000000000..e31e2eb330c --- /dev/null +++ b/packages/@rescript/runtime/Primitive_util.resi @@ -0,0 +1 @@ +let raiseWhenNotFound: 'a => 'a diff --git a/packages/@rescript/runtime/Stdlib.res b/packages/@rescript/runtime/Stdlib.res index fdbda5b4639..20469035b87 100644 --- a/packages/@rescript/runtime/Stdlib.res +++ b/packages/@rescript/runtime/Stdlib.res @@ -2,6 +2,7 @@ include Stdlib_Global module Array = Stdlib_Array module BigInt = Stdlib_BigInt +module Blob = Stdlib_Blob module Bool = Stdlib_Bool module Console = Stdlib_Console module DataView = Stdlib_DataView @@ -9,6 +10,7 @@ module Date = Stdlib_Date module Dict = Stdlib_Dict module Exn = Stdlib_Exn module Error = Stdlib_Error +module File = Stdlib_File module Float = Stdlib_Float module Int = Stdlib_Int module Intl = Stdlib_Intl diff --git a/packages/@rescript/runtime/Stdlib_Array.resi b/packages/@rescript/runtime/Stdlib_Array.resi index 45ca887b6f3..bf61fa617ef 100644 --- a/packages/@rescript/runtime/Stdlib_Array.resi +++ b/packages/@rescript/runtime/Stdlib_Array.resi @@ -1688,7 +1688,7 @@ See [Array.prototype.entries](https://developer.mozilla.org/en-US/docs/Web/JavaS ```rescript let array = [5, 6, 7] let iterator: IteratorObject.t<(int, int), unit, unknown> = array->Array.entries -iterator->IteratorObject.toArray == [(0, 5), (1, 6), (2, 7)] +iterator->IteratorObject.asIterable->Array.fromIterable == [(0, 5), (1, 6), (2, 7)] ``` */ @send @@ -1704,7 +1704,7 @@ See [Array.prototype.values](https://developer.mozilla.org/en-US/docs/Web/JavaSc ```rescript let array = [5, 6, 7] let iterator: IteratorObject.t = array->Array.values -iterator->IteratorObject.toArray == [5, 6, 7] +iterator->IteratorObject.asIterable->Array.fromIterable == [5, 6, 7] ``` */ @send diff --git a/packages/@rescript/runtime/Stdlib_Blob.res b/packages/@rescript/runtime/Stdlib_Blob.res new file mode 100644 index 00000000000..78df7b6c531 --- /dev/null +++ b/packages/@rescript/runtime/Stdlib_Blob.res @@ -0,0 +1,2 @@ +/** JavaScript Blob API */ +type t diff --git a/packages/@rescript/runtime/Stdlib_File.res b/packages/@rescript/runtime/Stdlib_File.res new file mode 100644 index 00000000000..7eaf8e67f77 --- /dev/null +++ b/packages/@rescript/runtime/Stdlib_File.res @@ -0,0 +1,2 @@ +/** JavaScript File API */ +type t diff --git a/packages/@rescript/runtime/Stdlib_Intl_DateTimeFormat.res b/packages/@rescript/runtime/Stdlib_Intl_DateTimeFormat.res index 070390d4f3c..d7904bf02b8 100644 --- a/packages/@rescript/runtime/Stdlib_Intl_DateTimeFormat.res +++ b/packages/@rescript/runtime/Stdlib_Intl_DateTimeFormat.res @@ -119,7 +119,7 @@ See [`Intl.DateTimeFormat`](https://developer.mozilla.org/en-US/docs/Web/JavaScr ```rescript let formatter = Intl.DateTimeFormat.make(~locales=["en-US"], ~options={timeStyle: #short}) -let sampleDate = Js.Date.makeWithYMD(~year=2024, ~month=0, ~date=1) +let sampleDate = Date.makeWithYMD(~year=2024, ~month=0, ~day=1) formatter->Intl.DateTimeFormat.format(sampleDate)->String.length > 0 ``` */ @@ -161,7 +161,7 @@ Intl.DateTimeFormat.resolvedOptions(formatter).locale == "en-US" ```rescript let formatter = Intl.DateTimeFormat.make(~locales=["en"]) -let date = Js.Date.makeWithYMD(~year=2024, ~month=0, ~date=1) +let date = Date.makeWithYMD(~year=2024, ~month=0, ~day=1) formatter->Intl.DateTimeFormat.format(date)->String.length > 0 ``` */ @@ -176,7 +176,7 @@ See [`Intl.DateTimeFormat.prototype.formatToParts`](https://developer.mozilla.or ```rescript let formatter = Intl.DateTimeFormat.make(~locales=["en"]) -let date = Js.Date.makeWithYMD(~year=2024, ~month=0, ~date=1) +let date = Date.makeWithYMD(~year=2024, ~month=0, ~day=1) formatter->Intl.DateTimeFormat.formatToParts(date)->Array.length > 0 ``` */ @@ -191,8 +191,8 @@ See [`Intl.DateTimeFormat.prototype.formatRange`](https://developer.mozilla.org/ ```rescript let formatter = Intl.DateTimeFormat.make(~locales=["en-US"], ~options={dateStyle: #short}) -let startDate = Js.Date.makeWithYMD(~year=2024, ~month=0, ~date=1) -let endDate = Js.Date.makeWithYMD(~year=2024, ~month=1, ~date=1) +let startDate = Date.makeWithYMD(~year=2024, ~month=0, ~day=1) +let endDate = Date.makeWithYMD(~year=2024, ~month=1, ~day=1) formatter->Intl.DateTimeFormat.formatRange(~startDate=startDate, ~endDate=endDate)->String.length > 0 ``` */ @@ -209,8 +209,8 @@ See [`Intl.DateTimeFormat.prototype.formatRangeToParts`](https://developer.mozil ```rescript let formatter = Intl.DateTimeFormat.make(~locales=["en-US"], ~options={dateStyle: #short}) -let startDate = Js.Date.makeWithYMD(~year=2024, ~month=0, ~date=1) -let endDate = Js.Date.makeWithYMD(~year=2024, ~month=1, ~date=1) +let startDate = Date.makeWithYMD(~year=2024, ~month=0, ~day=1) +let endDate = Date.makeWithYMD(~year=2024, ~month=1, ~day=1) formatter->Intl.DateTimeFormat.formatRangeToParts(~startDate=startDate, ~endDate=endDate)->Array.length > 0 ``` */ diff --git a/packages/@rescript/runtime/Stdlib_Intl_NumberFormat_Grouping.res b/packages/@rescript/runtime/Stdlib_Intl_NumberFormat_Grouping.res index d527a4fc8b6..6503c224111 100644 --- a/packages/@rescript/runtime/Stdlib_Intl_NumberFormat_Grouping.res +++ b/packages/@rescript/runtime/Stdlib_Intl_NumberFormat_Grouping.res @@ -45,7 +45,7 @@ external fromString: [#always | #auto | #min2] => t = "%identity" ## Examples ```rescript -Intl.NumberFormat.Grouping.parseJsValue(Js.Json.string("auto")) == Some(#auto) +Intl.NumberFormat.Grouping.parseJsValue("auto") == Some(#auto) ``` */ let parseJsValue = value => diff --git a/packages/@rescript/runtime/Stdlib_List.res b/packages/@rescript/runtime/Stdlib_List.res index 3c8c3effacd..a01708736ce 100644 --- a/packages/@rescript/runtime/Stdlib_List.res +++ b/packages/@rescript/runtime/Stdlib_List.res @@ -13,7 +13,7 @@ mutable tail : 'a opt_cell } - and 'a opt_cell = 'a cell Js.null + and 'a opt_cell = 'a cell Primitive_js_extern.null and 'a t = { length : int ; diff --git a/packages/@rescript/runtime/lib/es6/Belt_internalBuckets.mjs b/packages/@rescript/runtime/lib/es6/Belt_internalBuckets.mjs index 78e952111bb..0ccc15c2f18 100644 --- a/packages/@rescript/runtime/lib/es6/Belt_internalBuckets.mjs +++ b/packages/@rescript/runtime/lib/es6/Belt_internalBuckets.mjs @@ -4,6 +4,19 @@ import * as Belt_Array from "./Belt_Array.mjs"; import * as Primitive_int from "./Primitive_int.mjs"; import * as Primitive_option from "./Primitive_option.mjs"; +function copyBucket(c) { + if (c === undefined) { + return c; + } + let head = { + key: c.key, + value: c.value, + next: undefined + }; + copyAuxCont(c.next, head); + return head; +} + function copyAuxCont(_c, _prec) { while (true) { let prec = _prec; @@ -23,19 +36,6 @@ function copyAuxCont(_c, _prec) { }; } -function copyBucket(c) { - if (c === undefined) { - return c; - } - let head = { - key: c.key, - value: c.value, - next: undefined - }; - copyAuxCont(c.next, head); - return head; -} - function copyBuckets(buckets) { let len = buckets.length; let newBuckets = new Array(len); diff --git a/packages/@rescript/runtime/lib/es6/Belt_internalSetBuckets.mjs b/packages/@rescript/runtime/lib/es6/Belt_internalSetBuckets.mjs index 0c2c0b83acf..d7a0b685873 100644 --- a/packages/@rescript/runtime/lib/es6/Belt_internalSetBuckets.mjs +++ b/packages/@rescript/runtime/lib/es6/Belt_internalSetBuckets.mjs @@ -3,18 +3,6 @@ import * as Belt_Array from "./Belt_Array.mjs"; import * as Primitive_int from "./Primitive_int.mjs"; -function copyBucket(c) { - if (c === undefined) { - return c; - } - let head = { - key: c.key, - next: undefined - }; - copyAuxCont(c.next, head); - return head; -} - function copyAuxCont(_c, _prec) { while (true) { let prec = _prec; @@ -33,6 +21,18 @@ function copyAuxCont(_c, _prec) { }; } +function copyBucket(c) { + if (c === undefined) { + return c; + } + let head = { + key: c.key, + next: undefined + }; + copyAuxCont(c.next, head); + return head; +} + function copyBuckets(buckets) { let len = buckets.length; let newBuckets = new Array(len); diff --git a/packages/@rescript/runtime/lib/es6/Js.mjs b/packages/@rescript/runtime/lib/es6/Js.mjs deleted file mode 100644 index a20d294d586..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js.mjs +++ /dev/null @@ -1,109 +0,0 @@ - - -import * as Primitive_option from "./Primitive_option.mjs"; - -let Null; - -let Undefined; - -let Nullable; - -let Null_undefined; - -let Exn; - -let $$Array; - -let Array2; - -let $$String; - -let String2; - -let Re; - -let $$Promise; - -let Promise2; - -let $$Date; - -let Dict; - -let Global; - -let Json; - -let $$Math; - -let Obj; - -let Typed_array; - -let TypedArray2; - -let Types; - -let Float; - -let Int; - -let $$BigInt; - -let File; - -let Blob; - -let Option; - -let Result; - -let Console; - -let $$Set; - -let $$WeakSet; - -let $$Map; - -let $$WeakMap; - -let undefinedToOption = Primitive_option.fromUndefined; - -export { - Null, - Undefined, - Nullable, - Null_undefined, - Exn, - $$Array, - Array2, - $$String, - String2, - Re, - $$Promise, - Promise2, - $$Date, - Dict, - Global, - Json, - $$Math, - Obj, - Typed_array, - TypedArray2, - Types, - Float, - Int, - $$BigInt, - File, - Blob, - Option, - Result, - Console, - $$Set, - $$WeakSet, - $$Map, - $$WeakMap, - undefinedToOption, -} -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Js_OO.mjs b/packages/@rescript/runtime/lib/es6/Js_OO.mjs deleted file mode 100644 index c6841bd6081..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_OO.mjs +++ /dev/null @@ -1,9 +0,0 @@ - - - -let Callback = {}; - -export { - Callback, -} -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Js_array.mjs b/packages/@rescript/runtime/lib/es6/Js_array.mjs deleted file mode 100644 index 8c5f4beca97..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_array.mjs +++ /dev/null @@ -1,216 +0,0 @@ - - - -function copyWithin(to_, obj) { - return obj.copyWithin(to_); -} - -function copyWithinFrom(to_, from, obj) { - return obj.copyWithin(to_, from); -} - -function copyWithinFromRange(to_, start, end_, obj) { - return obj.copyWithin(to_, start, end_); -} - -function fillInPlace(arg1, obj) { - return obj.fill(arg1); -} - -function fillFromInPlace(arg1, from, obj) { - return obj.fill(arg1, from); -} - -function fillRangeInPlace(arg1, start, end_, obj) { - return obj.fill(arg1, start, end_); -} - -function push(arg1, obj) { - return obj.push(arg1); -} - -function pushMany(arg1, obj) { - return obj.push(...arg1); -} - -function sortInPlaceWith(arg1, obj) { - return obj.sort(arg1); -} - -function spliceInPlace(pos, remove, add, obj) { - return obj.splice(pos, remove, ...add); -} - -function removeFromInPlace(pos, obj) { - return obj.splice(pos); -} - -function removeCountInPlace(pos, count, obj) { - return obj.splice(pos, count); -} - -function unshift(arg1, obj) { - return obj.unshift(arg1); -} - -function unshiftMany(arg1, obj) { - return obj.unshift(...arg1); -} - -function concat(arg1, obj) { - return obj.concat(arg1); -} - -function concatMany(arg1, obj) { - return obj.concat(...arg1); -} - -function includes(arg1, obj) { - return obj.includes(arg1); -} - -function indexOf(arg1, obj) { - return obj.indexOf(arg1); -} - -function indexOfFrom(arg1, from, obj) { - return obj.indexOf(arg1, from); -} - -function joinWith(arg1, obj) { - return obj.join(arg1); -} - -function lastIndexOf(arg1, obj) { - return obj.lastIndexOf(arg1); -} - -function lastIndexOfFrom(arg1, from, obj) { - return obj.lastIndexOf(arg1, from); -} - -function slice(start, end_, obj) { - return obj.slice(start, end_); -} - -function sliceFrom(arg1, obj) { - return obj.slice(arg1); -} - -function every(arg1, obj) { - return obj.every(arg1); -} - -function everyi(arg1, obj) { - return obj.every(arg1); -} - -function filter(arg1, obj) { - return obj.filter(arg1); -} - -function filteri(arg1, obj) { - return obj.filter(arg1); -} - -function find(arg1, obj) { - return obj.find(arg1); -} - -function findi(arg1, obj) { - return obj.find(arg1); -} - -function findIndex(arg1, obj) { - return obj.findIndex(arg1); -} - -function findIndexi(arg1, obj) { - return obj.findIndex(arg1); -} - -function forEach(arg1, obj) { - obj.forEach(arg1); -} - -function forEachi(arg1, obj) { - obj.forEach(arg1); -} - -function map(arg1, obj) { - return obj.map(arg1); -} - -function mapi(arg1, obj) { - return obj.map(arg1); -} - -function reduce(arg1, arg2, obj) { - return obj.reduce(arg1, arg2); -} - -function reducei(arg1, arg2, obj) { - return obj.reduce(arg1, arg2); -} - -function reduceRight(arg1, arg2, obj) { - return obj.reduceRight(arg1, arg2); -} - -function reduceRighti(arg1, arg2, obj) { - return obj.reduceRight(arg1, arg2); -} - -function some(arg1, obj) { - return obj.some(arg1); -} - -function somei(arg1, obj) { - return obj.some(arg1); -} - -export { - copyWithin, - copyWithinFrom, - copyWithinFromRange, - fillInPlace, - fillFromInPlace, - fillRangeInPlace, - push, - pushMany, - sortInPlaceWith, - spliceInPlace, - removeFromInPlace, - removeCountInPlace, - unshift, - unshiftMany, - concat, - concatMany, - includes, - indexOf, - indexOfFrom, - joinWith, - lastIndexOf, - lastIndexOfFrom, - slice, - sliceFrom, - every, - everyi, - filter, - filteri, - find, - findi, - findIndex, - findIndexi, - forEach, - forEachi, - map, - mapi, - reduce, - reducei, - reduceRight, - reduceRighti, - some, - somei, -} -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Js_bigint.mjs b/packages/@rescript/runtime/lib/es6/Js_bigint.mjs deleted file mode 100644 index c548d1a793b..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_bigint.mjs +++ /dev/null @@ -1,11 +0,0 @@ - - - -function lnot(x) { - return x ^ -1n; -} - -export { - lnot, -} -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Js_dict.mjs b/packages/@rescript/runtime/lib/es6/Js_dict.mjs deleted file mode 100644 index 3aeb38f8fab..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_dict.mjs +++ /dev/null @@ -1,84 +0,0 @@ - - -import * as Primitive_option from "./Primitive_option.mjs"; - -function get(dict, k) { - if ((k in dict)) { - return Primitive_option.some(dict[k]); - } -} - -let unsafeDeleteKey = (function (dict,key){ - delete dict[key]; - }); - -function entries(dict) { - let keys = Object.keys(dict); - let l = keys.length; - let values = new Array(l); - for (let i = 0; i < l; ++i) { - let key = keys[i]; - values[i] = [ - key, - dict[key] - ]; - } - return values; -} - -function values(dict) { - let keys = Object.keys(dict); - let l = keys.length; - let values$1 = new Array(l); - for (let i = 0; i < l; ++i) { - values$1[i] = dict[keys[i]]; - } - return values$1; -} - -function fromList(entries) { - let dict = {}; - let _x = entries; - while (true) { - let x = _x; - if (x === 0) { - return dict; - } - let match = x.hd; - dict[match[0]] = match[1]; - _x = x.tl; - continue; - }; -} - -function fromArray(entries) { - let dict = {}; - let l = entries.length; - for (let i = 0; i < l; ++i) { - let match = entries[i]; - dict[match[0]] = match[1]; - } - return dict; -} - -function map(f, source) { - let target = {}; - let keys = Object.keys(source); - let l = keys.length; - for (let i = 0; i < l; ++i) { - let key = keys[i]; - target[key] = f(source[key]); - } - return target; -} - -export { - get, - unsafeDeleteKey, - entries, - values, - fromList, - fromArray, - map, -} -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Js_extern.mjs b/packages/@rescript/runtime/lib/es6/Js_extern.mjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_extern.mjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/es6/Js_file.mjs b/packages/@rescript/runtime/lib/es6/Js_file.mjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_file.mjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/es6/Js_float.mjs b/packages/@rescript/runtime/lib/es6/Js_float.mjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_float.mjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/es6/Js_global.mjs b/packages/@rescript/runtime/lib/es6/Js_global.mjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_global.mjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/es6/Js_int.mjs b/packages/@rescript/runtime/lib/es6/Js_int.mjs deleted file mode 100644 index 53a2d18b850..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_int.mjs +++ /dev/null @@ -1,17 +0,0 @@ - - - -function equal(x, y) { - return x === y; -} - -let max = 2147483647; - -let min = -2147483648; - -export { - equal, - max, - min, -} -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Js_json.mjs b/packages/@rescript/runtime/lib/es6/Js_json.mjs deleted file mode 100644 index 100c7be78da..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_json.mjs +++ /dev/null @@ -1,167 +0,0 @@ - - - -let Kind = {}; - -function classify(x) { - let ty = typeof x; - if (ty === "string") { - return { - TAG: "JSONString", - _0: x - }; - } else if (ty === "number") { - return { - TAG: "JSONNumber", - _0: x - }; - } else if (ty === "boolean") { - if (x === true) { - return "JSONTrue"; - } else { - return "JSONFalse"; - } - } else if (x === null) { - return "JSONNull"; - } else if (Array.isArray(x)) { - return { - TAG: "JSONArray", - _0: x - }; - } else { - return { - TAG: "JSONObject", - _0: x - }; - } -} - -function test(x, v) { - switch (v) { - case "String" : - return typeof x === "string"; - case "Number" : - return typeof x === "number"; - case "Object" : - if (x !== null && typeof x === "object") { - return !Array.isArray(x); - } else { - return false; - } - case "Array" : - return Array.isArray(x); - case "Boolean" : - return typeof x === "boolean"; - case "Null" : - return x === null; - } -} - -function decodeString(json) { - if (typeof json === "string") { - return json; - } -} - -function decodeNumber(json) { - if (typeof json === "number") { - return json; - } -} - -function decodeObject(json) { - if (typeof json === "object" && !Array.isArray(json) && json !== null) { - return json; - } -} - -function decodeArray(json) { - if (Array.isArray(json)) { - return json; - } -} - -function decodeBoolean(json) { - if (typeof json === "boolean") { - return json; - } -} - -function decodeNull(json) { - if (json === null) { - return null; - } -} - -let patch = (function (json) { - var x = [json]; - var q = [{ kind: 0, i: 0, parent: x }]; - while (q.length !== 0) { - // begin pop the stack - var cur = q[q.length - 1]; - if (cur.kind === 0) { - cur.val = cur.parent[cur.i]; // patch the undefined value for array - if (++cur.i === cur.parent.length) { - q.pop(); - } - } else { - q.pop(); - } - // finish - var task = cur.val; - if (typeof task === "object") { - if (Array.isArray(task) && task.length !== 0) { - q.push({ kind: 0, i: 0, parent: task, val: undefined }); - } else { - for (var k in task) { - if (k === "RE_PRIVATE_NONE") { - if (cur.kind === 0) { - cur.parent[cur.i - 1] = undefined; - } else { - cur.parent[cur.i] = undefined; - } - continue; - } - q.push({ kind: 1, i: k, parent: task, val: task[k] }); - } - } - } - } - return x[0]; -}); - -function serializeExn(x) { - return (function(obj){ - var output= JSON.stringify(obj,function(_,value){ - if(value===undefined){ - return {RE_PRIVATE_NONE : true} - } - return value - }); - - if(output === undefined){ - // JSON.stringify will throw TypeError when it detects cylic objects - throw new TypeError("output is undefined") - } - return output - })(x); -} - -function deserializeUnsafe(s) { - return patch(JSON.parse(s)); -} - -export { - Kind, - classify, - test, - decodeString, - decodeNumber, - decodeObject, - decodeArray, - decodeBoolean, - decodeNull, - deserializeUnsafe, - serializeExn, -} -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Js_map.mjs b/packages/@rescript/runtime/lib/es6/Js_map.mjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_map.mjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/es6/Js_math.mjs b/packages/@rescript/runtime/lib/es6/Js_math.mjs deleted file mode 100644 index a62535ea0b5..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_math.mjs +++ /dev/null @@ -1,50 +0,0 @@ - - -import * as Js_int from "./Js_int.mjs"; - -function unsafe_ceil(prim) { - return Math.ceil(prim); -} - -function ceil_int(f) { - if (f > Js_int.max) { - return Js_int.max; - } else if (f < Js_int.min) { - return Js_int.min; - } else { - return Math.ceil(f); - } -} - -function unsafe_floor(prim) { - return Math.floor(prim); -} - -function floor_int(f) { - if (f > Js_int.max) { - return Js_int.max; - } else if (f < Js_int.min) { - return Js_int.min; - } else { - return Math.floor(f); - } -} - -function random_int(min, max) { - return floor_int(Math.random() * (max - min | 0)) + min | 0; -} - -let ceil = ceil_int; - -let floor = floor_int; - -export { - unsafe_ceil, - ceil_int, - ceil, - unsafe_floor, - floor_int, - floor, - random_int, -} -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Js_null.mjs b/packages/@rescript/runtime/lib/es6/Js_null.mjs deleted file mode 100644 index bb17000f68a..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_null.mjs +++ /dev/null @@ -1,48 +0,0 @@ - - -import * as Primitive_option from "./Primitive_option.mjs"; - -function test(x) { - return x === null; -} - -function getExn(f) { - if (f !== null) { - return f; - } - throw new Error("Js.Null.getExn"); -} - -function bind(x, f) { - if (x !== null) { - return f(x); - } else { - return null; - } -} - -function iter(x, f) { - if (x !== null) { - return f(x); - } -} - -function fromOption(x) { - if (x !== undefined) { - return Primitive_option.valFromOption(x); - } else { - return null; - } -} - -let from_opt = fromOption; - -export { - test, - getExn, - bind, - iter, - fromOption, - from_opt, -} -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Js_null_undefined.mjs b/packages/@rescript/runtime/lib/es6/Js_null_undefined.mjs deleted file mode 100644 index e5f142cad1f..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_null_undefined.mjs +++ /dev/null @@ -1,33 +0,0 @@ - - -import * as Primitive_option from "./Primitive_option.mjs"; - -function bind(x, f) { - if (x == null) { - return x; - } else { - return f(x); - } -} - -function iter(x, f) { - if (!(x == null)) { - return f(x); - } -} - -function fromOption(x) { - if (x !== undefined) { - return Primitive_option.valFromOption(x); - } -} - -let from_opt = fromOption; - -export { - bind, - iter, - fromOption, - from_opt, -} -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Js_obj.mjs b/packages/@rescript/runtime/lib/es6/Js_obj.mjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_obj.mjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/es6/Js_option.mjs b/packages/@rescript/runtime/lib/es6/Js_option.mjs deleted file mode 100644 index c030fcaf2f9..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_option.mjs +++ /dev/null @@ -1,100 +0,0 @@ - - -import * as Primitive_option from "./Primitive_option.mjs"; - -function some(x) { - return Primitive_option.some(x); -} - -function isSome(x) { - return x !== undefined; -} - -function isSomeValue(eq, v, x) { - if (x !== undefined) { - return eq(v, Primitive_option.valFromOption(x)); - } else { - return false; - } -} - -function isNone(x) { - return x === undefined; -} - -function getExn(x) { - if (x !== undefined) { - return Primitive_option.valFromOption(x); - } - throw new Error("getExn"); -} - -function equal(eq, a, b) { - if (a !== undefined) { - if (b !== undefined) { - return eq(Primitive_option.valFromOption(a), Primitive_option.valFromOption(b)); - } else { - return false; - } - } else { - return b === undefined; - } -} - -function andThen(f, x) { - if (x !== undefined) { - return f(Primitive_option.valFromOption(x)); - } -} - -function map(f, x) { - if (x !== undefined) { - return Primitive_option.some(f(Primitive_option.valFromOption(x))); - } -} - -function getWithDefault(a, x) { - if (x !== undefined) { - return Primitive_option.valFromOption(x); - } else { - return a; - } -} - -function filter(f, x) { - if (x === undefined) { - return; - } - let x$1 = Primitive_option.valFromOption(x); - if (f(x$1)) { - return Primitive_option.some(x$1); - } -} - -function firstSome(a, b) { - if (a !== undefined) { - return a; - } else if (b !== undefined) { - return b; - } else { - return; - } -} - -let $$default = getWithDefault; - -export { - some, - isSome, - isSomeValue, - isNone, - getExn, - equal, - andThen, - map, - getWithDefault, - $$default as default, - filter, - firstSome, -} -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Js_promise.mjs b/packages/@rescript/runtime/lib/es6/Js_promise.mjs deleted file mode 100644 index dd67694b076..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_promise.mjs +++ /dev/null @@ -1,16 +0,0 @@ - - - -function then_(arg1, obj) { - return obj.then(arg1); -} - -function $$catch(arg1, obj) { - return obj.catch(arg1); -} - -export { - then_, - $$catch, -} -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Js_promise2.mjs b/packages/@rescript/runtime/lib/es6/Js_promise2.mjs deleted file mode 100644 index 727ab7ea0c4..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_promise2.mjs +++ /dev/null @@ -1,16 +0,0 @@ - - - -let then = (function(p, cont) { - return Promise.resolve(p).then(cont) - }); - -let $$catch = (function(p, cont) { - return Promise.resolve(p).catch(cont) - }); - -export { - then, - $$catch, -} -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Js_re.mjs b/packages/@rescript/runtime/lib/es6/Js_re.mjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_re.mjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/es6/Js_result.mjs b/packages/@rescript/runtime/lib/es6/Js_result.mjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_result.mjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/es6/Js_set.mjs b/packages/@rescript/runtime/lib/es6/Js_set.mjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_set.mjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/es6/Js_string.mjs b/packages/@rescript/runtime/lib/es6/Js_string.mjs deleted file mode 100644 index e76320de635..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_string.mjs +++ /dev/null @@ -1,197 +0,0 @@ - - -import * as Primitive_option from "./Primitive_option.mjs"; - -function charAt(arg1, obj) { - return obj.charAt(arg1); -} - -function charCodeAt(arg1, obj) { - return obj.charCodeAt(arg1); -} - -function codePointAt(arg1, obj) { - return obj.codePointAt(arg1); -} - -function concat(arg1, obj) { - return obj.concat(arg1); -} - -function concatMany(arg1, obj) { - return obj.concat(...arg1); -} - -function endsWith(arg1, obj) { - return obj.endsWith(arg1); -} - -function endsWithFrom(arg1, arg2, obj) { - return obj.endsWith(arg1, arg2); -} - -function includes(arg1, obj) { - return obj.includes(arg1); -} - -function includesFrom(arg1, arg2, obj) { - return obj.includes(arg1, arg2); -} - -function indexOf(arg1, obj) { - return obj.indexOf(arg1); -} - -function indexOfFrom(arg1, arg2, obj) { - return obj.indexOf(arg1, arg2); -} - -function lastIndexOf(arg1, obj) { - return obj.lastIndexOf(arg1); -} - -function lastIndexOfFrom(arg1, arg2, obj) { - return obj.lastIndexOf(arg1, arg2); -} - -function localeCompare(arg1, obj) { - return obj.localeCompare(arg1); -} - -function match_(arg1, obj) { - return Primitive_option.fromNull(obj.match(arg1)); -} - -function normalizeByForm(arg1, obj) { - return obj.normalize(arg1); -} - -function repeat(arg1, obj) { - return obj.repeat(arg1); -} - -function replace(arg1, arg2, obj) { - return obj.replace(arg1, arg2); -} - -function replaceByRe(arg1, arg2, obj) { - return obj.replace(arg1, arg2); -} - -function unsafeReplaceBy0(arg1, arg2, obj) { - return obj.replace(arg1, arg2); -} - -function unsafeReplaceBy1(arg1, arg2, obj) { - return obj.replace(arg1, arg2); -} - -function unsafeReplaceBy2(arg1, arg2, obj) { - return obj.replace(arg1, arg2); -} - -function unsafeReplaceBy3(arg1, arg2, obj) { - return obj.replace(arg1, arg2); -} - -function search(arg1, obj) { - return obj.search(arg1); -} - -function slice(from, to_, obj) { - return obj.slice(from, to_); -} - -function sliceToEnd(from, obj) { - return obj.slice(from); -} - -function split(arg1, obj) { - return obj.split(arg1); -} - -function splitAtMost(arg1, limit, obj) { - return obj.split(arg1, limit); -} - -function splitByRe(arg1, obj) { - return obj.split(arg1); -} - -function splitByReAtMost(arg1, limit, obj) { - return obj.split(arg1, limit); -} - -function startsWith(arg1, obj) { - return obj.startsWith(arg1); -} - -function startsWithFrom(arg1, arg2, obj) { - return obj.startsWith(arg1, arg2); -} - -function substr(from, obj) { - return obj.substr(from); -} - -function substrAtMost(from, length, obj) { - return obj.substr(from, length); -} - -function substring(from, to_, obj) { - return obj.substring(from, to_); -} - -function substringToEnd(from, obj) { - return obj.substring(from); -} - -function anchor(arg1, obj) { - return obj.anchor(arg1); -} - -function link(arg1, obj) { - return obj.link(arg1); -} - -export { - charAt, - charCodeAt, - codePointAt, - concat, - concatMany, - endsWith, - endsWithFrom, - includes, - includesFrom, - indexOf, - indexOfFrom, - lastIndexOf, - lastIndexOfFrom, - localeCompare, - match_, - normalizeByForm, - repeat, - replace, - replaceByRe, - unsafeReplaceBy0, - unsafeReplaceBy1, - unsafeReplaceBy2, - unsafeReplaceBy3, - search, - slice, - sliceToEnd, - split, - splitAtMost, - splitByRe, - splitByReAtMost, - startsWith, - startsWithFrom, - substr, - substrAtMost, - substring, - substringToEnd, - anchor, - link, -} -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Js_string2.mjs b/packages/@rescript/runtime/lib/es6/Js_string2.mjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_string2.mjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/es6/Js_typed_array.mjs b/packages/@rescript/runtime/lib/es6/Js_typed_array.mjs deleted file mode 100644 index 5e2a72d2d99..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_typed_array.mjs +++ /dev/null @@ -1,48 +0,0 @@ - - - -let $$ArrayBuffer = {}; - -let $$Int8Array = {}; - -let $$Uint8Array = {}; - -let $$Uint8ClampedArray = {}; - -let $$Int16Array = {}; - -let $$Uint16Array = {}; - -let $$Int32Array = {}; - -let $$Uint32Array = {}; - -let $$Float32Array = {}; - -let $$Float64Array = {}; - -let $$DataView = {}; - -let Int32_array; - -let Float32_array; - -let Float64_array; - -export { - $$ArrayBuffer, - $$Int8Array, - $$Uint8Array, - $$Uint8ClampedArray, - $$Int16Array, - $$Uint16Array, - $$Int32Array, - Int32_array, - $$Uint32Array, - $$Float32Array, - Float32_array, - $$Float64Array, - Float64_array, - $$DataView, -} -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Js_typed_array2.mjs b/packages/@rescript/runtime/lib/es6/Js_typed_array2.mjs deleted file mode 100644 index 0ebdb875ecd..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_typed_array2.mjs +++ /dev/null @@ -1,39 +0,0 @@ - - - -let $$ArrayBuffer = {}; - -let $$Int8Array = {}; - -let $$Uint8Array = {}; - -let $$Uint8ClampedArray = {}; - -let $$Int16Array = {}; - -let $$Uint16Array = {}; - -let $$Int32Array = {}; - -let $$Uint32Array = {}; - -let $$Float32Array = {}; - -let $$Float64Array = {}; - -let $$DataView = {}; - -export { - $$ArrayBuffer, - $$Int8Array, - $$Uint8Array, - $$Uint8ClampedArray, - $$Int16Array, - $$Uint16Array, - $$Int32Array, - $$Uint32Array, - $$Float32Array, - $$Float64Array, - $$DataView, -} -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Js_types.mjs b/packages/@rescript/runtime/lib/es6/Js_types.mjs deleted file mode 100644 index a8a165b63ba..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_types.mjs +++ /dev/null @@ -1,76 +0,0 @@ - - - -function classify(x) { - let ty = typeof x; - if (ty === "undefined") { - return "JSUndefined"; - } else if (x === null) { - return "JSNull"; - } else if (ty === "number") { - return { - TAG: "JSNumber", - _0: x - }; - } else if (ty === "bigint") { - return { - TAG: "JSBigInt", - _0: x - }; - } else if (ty === "string") { - return { - TAG: "JSString", - _0: x - }; - } else if (ty === "boolean") { - if (x === true) { - return "JSTrue"; - } else { - return "JSFalse"; - } - } else if (ty === "symbol") { - return { - TAG: "JSSymbol", - _0: x - }; - } else if (ty === "function") { - return { - TAG: "JSFunction", - _0: x - }; - } else { - return { - TAG: "JSObject", - _0: x - }; - } -} - -function test(x, v) { - switch (v) { - case "Undefined" : - return typeof x === "undefined"; - case "Null" : - return x === null; - case "Boolean" : - return typeof x === "boolean"; - case "Number" : - return typeof x === "number"; - case "String" : - return typeof x === "string"; - case "Function" : - return typeof x === "function"; - case "Object" : - return typeof x === "object"; - case "Symbol" : - return typeof x === "symbol"; - case "BigInt" : - return typeof x === "bigint"; - } -} - -export { - test, - classify, -} -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Js_undefined.mjs b/packages/@rescript/runtime/lib/es6/Js_undefined.mjs deleted file mode 100644 index 88ac122fa99..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_undefined.mjs +++ /dev/null @@ -1,58 +0,0 @@ - - -import * as Primitive_option from "./Primitive_option.mjs"; - -function test(x) { - return x === undefined; -} - -function testAny(x) { - return x === undefined; -} - -function getExn(f) { - let x = Primitive_option.fromUndefined(f); - if (x !== undefined) { - return Primitive_option.valFromOption(x); - } - throw new Error("Js.Undefined.getExn"); -} - -function bind(x, f) { - let x$1 = Primitive_option.fromUndefined(x); - if (x$1 !== undefined) { - return f(Primitive_option.valFromOption(x$1)); - } -} - -function iter(x, f) { - let x$1 = Primitive_option.fromUndefined(x); - if (x$1 !== undefined) { - return f(Primitive_option.valFromOption(x$1)); - } -} - -function fromOption(x) { - if (x !== undefined) { - return Primitive_option.valFromOption(x); - } -} - -let from_opt = fromOption; - -let toOption = Primitive_option.fromUndefined; - -let to_opt = Primitive_option.fromUndefined; - -export { - test, - testAny, - getExn, - bind, - iter, - fromOption, - from_opt, - toOption, - to_opt, -} -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Js_weakmap.mjs b/packages/@rescript/runtime/lib/es6/Js_weakmap.mjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_weakmap.mjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/es6/Js_weakset.mjs b/packages/@rescript/runtime/lib/es6/Js_weakset.mjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/es6/Js_weakset.mjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/es6/Primitive_hash.mjs b/packages/@rescript/runtime/lib/es6/Primitive_hash.mjs index a89108b18e7..e085228b1b7 100644 --- a/packages/@rescript/runtime/lib/es6/Primitive_hash.mjs +++ b/packages/@rescript/runtime/lib/es6/Primitive_hash.mjs @@ -36,7 +36,7 @@ function unsafe_pop(q) { RE_EXN_ID: "Assert_failure", _1: [ "Primitive_hash.res", - 55, + 58, 12 ], Error: new Error() diff --git a/packages/@rescript/runtime/lib/es6/Primitive_js_extern.mjs b/packages/@rescript/runtime/lib/es6/Primitive_js_extern.mjs index ae1b9f17e65..c6841bd6081 100644 --- a/packages/@rescript/runtime/lib/es6/Primitive_js_extern.mjs +++ b/packages/@rescript/runtime/lib/es6/Primitive_js_extern.mjs @@ -1 +1,9 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ + + + +let Callback = {}; + +export { + Callback, +} +/* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Primitive_util.mjs b/packages/@rescript/runtime/lib/es6/Primitive_util.mjs index 6aef21e9238..a5299e3648a 100644 --- a/packages/@rescript/runtime/lib/es6/Primitive_util.mjs +++ b/packages/@rescript/runtime/lib/es6/Primitive_util.mjs @@ -11,10 +11,7 @@ function raiseWhenNotFound(x) { return x; } -let Js; - export { - Js, raiseWhenNotFound, } /* No side effect */ diff --git a/packages/@rescript/runtime/lib/es6/Stdlib.mjs b/packages/@rescript/runtime/lib/es6/Stdlib.mjs index 72da6171a31..a59df608684 100644 --- a/packages/@rescript/runtime/lib/es6/Stdlib.mjs +++ b/packages/@rescript/runtime/lib/es6/Stdlib.mjs @@ -12,7 +12,7 @@ function assertEqual(a, b) { RE_EXN_ID: "Assert_failure", _1: [ "Stdlib.res", - 161, + 163, 4 ], Error: new Error() @@ -27,6 +27,8 @@ let $$Array; let $$BigInt; +let Blob; + let Bool; let Console; @@ -41,6 +43,8 @@ let Exn; let $$Error; +let File; + let Float; let Int; @@ -144,6 +148,7 @@ export { IntervalId, $$Array, $$BigInt, + Blob, Bool, Console, $$DataView, @@ -151,6 +156,7 @@ export { Dict, Exn, $$Error, + File, Float, Int, $$Intl, diff --git a/packages/@rescript/runtime/lib/es6/Js_array2.mjs b/packages/@rescript/runtime/lib/es6/Stdlib_Blob.mjs similarity index 100% rename from packages/@rescript/runtime/lib/es6/Js_array2.mjs rename to packages/@rescript/runtime/lib/es6/Stdlib_Blob.mjs diff --git a/packages/@rescript/runtime/lib/es6/Js_blob.mjs b/packages/@rescript/runtime/lib/es6/Stdlib_File.mjs similarity index 100% rename from packages/@rescript/runtime/lib/es6/Js_blob.mjs rename to packages/@rescript/runtime/lib/es6/Stdlib_File.mjs diff --git a/packages/@rescript/runtime/lib/js/Belt_internalBuckets.cjs b/packages/@rescript/runtime/lib/js/Belt_internalBuckets.cjs index d0d328c385d..d257c24e91d 100644 --- a/packages/@rescript/runtime/lib/js/Belt_internalBuckets.cjs +++ b/packages/@rescript/runtime/lib/js/Belt_internalBuckets.cjs @@ -4,6 +4,19 @@ let Belt_Array = require("./Belt_Array.cjs"); let Primitive_int = require("./Primitive_int.cjs"); let Primitive_option = require("./Primitive_option.cjs"); +function copyBucket(c) { + if (c === undefined) { + return c; + } + let head = { + key: c.key, + value: c.value, + next: undefined + }; + copyAuxCont(c.next, head); + return head; +} + function copyAuxCont(_c, _prec) { while (true) { let prec = _prec; @@ -23,19 +36,6 @@ function copyAuxCont(_c, _prec) { }; } -function copyBucket(c) { - if (c === undefined) { - return c; - } - let head = { - key: c.key, - value: c.value, - next: undefined - }; - copyAuxCont(c.next, head); - return head; -} - function copyBuckets(buckets) { let len = buckets.length; let newBuckets = new Array(len); diff --git a/packages/@rescript/runtime/lib/js/Belt_internalSetBuckets.cjs b/packages/@rescript/runtime/lib/js/Belt_internalSetBuckets.cjs index d77d0c2dbb1..f79b21826e9 100644 --- a/packages/@rescript/runtime/lib/js/Belt_internalSetBuckets.cjs +++ b/packages/@rescript/runtime/lib/js/Belt_internalSetBuckets.cjs @@ -3,18 +3,6 @@ let Belt_Array = require("./Belt_Array.cjs"); let Primitive_int = require("./Primitive_int.cjs"); -function copyBucket(c) { - if (c === undefined) { - return c; - } - let head = { - key: c.key, - next: undefined - }; - copyAuxCont(c.next, head); - return head; -} - function copyAuxCont(_c, _prec) { while (true) { let prec = _prec; @@ -33,6 +21,18 @@ function copyAuxCont(_c, _prec) { }; } +function copyBucket(c) { + if (c === undefined) { + return c; + } + let head = { + key: c.key, + next: undefined + }; + copyAuxCont(c.next, head); + return head; +} + function copyBuckets(buckets) { let len = buckets.length; let newBuckets = new Array(len); diff --git a/packages/@rescript/runtime/lib/js/Js.cjs b/packages/@rescript/runtime/lib/js/Js.cjs deleted file mode 100644 index afc11ef51cd..00000000000 --- a/packages/@rescript/runtime/lib/js/Js.cjs +++ /dev/null @@ -1,107 +0,0 @@ -'use strict'; - -let Primitive_option = require("./Primitive_option.cjs"); - -let Null; - -let Undefined; - -let Nullable; - -let Null_undefined; - -let Exn; - -let $$Array; - -let Array2; - -let $$String; - -let String2; - -let Re; - -let $$Promise; - -let Promise2; - -let $$Date; - -let Dict; - -let Global; - -let Json; - -let $$Math; - -let Obj; - -let Typed_array; - -let TypedArray2; - -let Types; - -let Float; - -let Int; - -let $$BigInt; - -let File; - -let Blob; - -let Option; - -let Result; - -let Console; - -let $$Set; - -let $$WeakSet; - -let $$Map; - -let $$WeakMap; - -let undefinedToOption = Primitive_option.fromUndefined; - -exports.Null = Null; -exports.Undefined = Undefined; -exports.Nullable = Nullable; -exports.Null_undefined = Null_undefined; -exports.Exn = Exn; -exports.$$Array = $$Array; -exports.Array2 = Array2; -exports.$$String = $$String; -exports.String2 = String2; -exports.Re = Re; -exports.$$Promise = $$Promise; -exports.Promise2 = Promise2; -exports.$$Date = $$Date; -exports.Dict = Dict; -exports.Global = Global; -exports.Json = Json; -exports.$$Math = $$Math; -exports.Obj = Obj; -exports.Typed_array = Typed_array; -exports.TypedArray2 = TypedArray2; -exports.Types = Types; -exports.Float = Float; -exports.Int = Int; -exports.$$BigInt = $$BigInt; -exports.File = File; -exports.Blob = Blob; -exports.Option = Option; -exports.Result = Result; -exports.Console = Console; -exports.$$Set = $$Set; -exports.$$WeakSet = $$WeakSet; -exports.$$Map = $$Map; -exports.$$WeakMap = $$WeakMap; -exports.undefinedToOption = undefinedToOption; -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Js_OO.cjs b/packages/@rescript/runtime/lib/js/Js_OO.cjs deleted file mode 100644 index d7a97adee6b..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_OO.cjs +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - - -let Callback = {}; - -exports.Callback = Callback; -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Js_array.cjs b/packages/@rescript/runtime/lib/js/Js_array.cjs deleted file mode 100644 index a9c75f24c4e..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_array.cjs +++ /dev/null @@ -1,214 +0,0 @@ -'use strict'; - - -function copyWithin(to_, obj) { - return obj.copyWithin(to_); -} - -function copyWithinFrom(to_, from, obj) { - return obj.copyWithin(to_, from); -} - -function copyWithinFromRange(to_, start, end_, obj) { - return obj.copyWithin(to_, start, end_); -} - -function fillInPlace(arg1, obj) { - return obj.fill(arg1); -} - -function fillFromInPlace(arg1, from, obj) { - return obj.fill(arg1, from); -} - -function fillRangeInPlace(arg1, start, end_, obj) { - return obj.fill(arg1, start, end_); -} - -function push(arg1, obj) { - return obj.push(arg1); -} - -function pushMany(arg1, obj) { - return obj.push(...arg1); -} - -function sortInPlaceWith(arg1, obj) { - return obj.sort(arg1); -} - -function spliceInPlace(pos, remove, add, obj) { - return obj.splice(pos, remove, ...add); -} - -function removeFromInPlace(pos, obj) { - return obj.splice(pos); -} - -function removeCountInPlace(pos, count, obj) { - return obj.splice(pos, count); -} - -function unshift(arg1, obj) { - return obj.unshift(arg1); -} - -function unshiftMany(arg1, obj) { - return obj.unshift(...arg1); -} - -function concat(arg1, obj) { - return obj.concat(arg1); -} - -function concatMany(arg1, obj) { - return obj.concat(...arg1); -} - -function includes(arg1, obj) { - return obj.includes(arg1); -} - -function indexOf(arg1, obj) { - return obj.indexOf(arg1); -} - -function indexOfFrom(arg1, from, obj) { - return obj.indexOf(arg1, from); -} - -function joinWith(arg1, obj) { - return obj.join(arg1); -} - -function lastIndexOf(arg1, obj) { - return obj.lastIndexOf(arg1); -} - -function lastIndexOfFrom(arg1, from, obj) { - return obj.lastIndexOf(arg1, from); -} - -function slice(start, end_, obj) { - return obj.slice(start, end_); -} - -function sliceFrom(arg1, obj) { - return obj.slice(arg1); -} - -function every(arg1, obj) { - return obj.every(arg1); -} - -function everyi(arg1, obj) { - return obj.every(arg1); -} - -function filter(arg1, obj) { - return obj.filter(arg1); -} - -function filteri(arg1, obj) { - return obj.filter(arg1); -} - -function find(arg1, obj) { - return obj.find(arg1); -} - -function findi(arg1, obj) { - return obj.find(arg1); -} - -function findIndex(arg1, obj) { - return obj.findIndex(arg1); -} - -function findIndexi(arg1, obj) { - return obj.findIndex(arg1); -} - -function forEach(arg1, obj) { - obj.forEach(arg1); -} - -function forEachi(arg1, obj) { - obj.forEach(arg1); -} - -function map(arg1, obj) { - return obj.map(arg1); -} - -function mapi(arg1, obj) { - return obj.map(arg1); -} - -function reduce(arg1, arg2, obj) { - return obj.reduce(arg1, arg2); -} - -function reducei(arg1, arg2, obj) { - return obj.reduce(arg1, arg2); -} - -function reduceRight(arg1, arg2, obj) { - return obj.reduceRight(arg1, arg2); -} - -function reduceRighti(arg1, arg2, obj) { - return obj.reduceRight(arg1, arg2); -} - -function some(arg1, obj) { - return obj.some(arg1); -} - -function somei(arg1, obj) { - return obj.some(arg1); -} - -exports.copyWithin = copyWithin; -exports.copyWithinFrom = copyWithinFrom; -exports.copyWithinFromRange = copyWithinFromRange; -exports.fillInPlace = fillInPlace; -exports.fillFromInPlace = fillFromInPlace; -exports.fillRangeInPlace = fillRangeInPlace; -exports.push = push; -exports.pushMany = pushMany; -exports.sortInPlaceWith = sortInPlaceWith; -exports.spliceInPlace = spliceInPlace; -exports.removeFromInPlace = removeFromInPlace; -exports.removeCountInPlace = removeCountInPlace; -exports.unshift = unshift; -exports.unshiftMany = unshiftMany; -exports.concat = concat; -exports.concatMany = concatMany; -exports.includes = includes; -exports.indexOf = indexOf; -exports.indexOfFrom = indexOfFrom; -exports.joinWith = joinWith; -exports.lastIndexOf = lastIndexOf; -exports.lastIndexOfFrom = lastIndexOfFrom; -exports.slice = slice; -exports.sliceFrom = sliceFrom; -exports.every = every; -exports.everyi = everyi; -exports.filter = filter; -exports.filteri = filteri; -exports.find = find; -exports.findi = findi; -exports.findIndex = findIndex; -exports.findIndexi = findIndexi; -exports.forEach = forEach; -exports.forEachi = forEachi; -exports.map = map; -exports.mapi = mapi; -exports.reduce = reduce; -exports.reducei = reducei; -exports.reduceRight = reduceRight; -exports.reduceRighti = reduceRighti; -exports.some = some; -exports.somei = somei; -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Js_array2.cjs b/packages/@rescript/runtime/lib/js/Js_array2.cjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_array2.cjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/js/Js_bigint.cjs b/packages/@rescript/runtime/lib/js/Js_bigint.cjs deleted file mode 100644 index f66be3837c0..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_bigint.cjs +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - - -function lnot(x) { - return x ^ -1n; -} - -exports.lnot = lnot; -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Js_blob.cjs b/packages/@rescript/runtime/lib/js/Js_blob.cjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_blob.cjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/js/Js_console.cjs b/packages/@rescript/runtime/lib/js/Js_console.cjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_console.cjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/js/Js_date.cjs b/packages/@rescript/runtime/lib/js/Js_date.cjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_date.cjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/js/Js_dict.cjs b/packages/@rescript/runtime/lib/js/Js_dict.cjs deleted file mode 100644 index ae23159e38a..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_dict.cjs +++ /dev/null @@ -1,82 +0,0 @@ -'use strict'; - -let Primitive_option = require("./Primitive_option.cjs"); - -function get(dict, k) { - if ((k in dict)) { - return Primitive_option.some(dict[k]); - } -} - -let unsafeDeleteKey = (function (dict,key){ - delete dict[key]; - }); - -function entries(dict) { - let keys = Object.keys(dict); - let l = keys.length; - let values = new Array(l); - for (let i = 0; i < l; ++i) { - let key = keys[i]; - values[i] = [ - key, - dict[key] - ]; - } - return values; -} - -function values(dict) { - let keys = Object.keys(dict); - let l = keys.length; - let values$1 = new Array(l); - for (let i = 0; i < l; ++i) { - values$1[i] = dict[keys[i]]; - } - return values$1; -} - -function fromList(entries) { - let dict = {}; - let _x = entries; - while (true) { - let x = _x; - if (x === 0) { - return dict; - } - let match = x.hd; - dict[match[0]] = match[1]; - _x = x.tl; - continue; - }; -} - -function fromArray(entries) { - let dict = {}; - let l = entries.length; - for (let i = 0; i < l; ++i) { - let match = entries[i]; - dict[match[0]] = match[1]; - } - return dict; -} - -function map(f, source) { - let target = {}; - let keys = Object.keys(source); - let l = keys.length; - for (let i = 0; i < l; ++i) { - let key = keys[i]; - target[key] = f(source[key]); - } - return target; -} - -exports.get = get; -exports.unsafeDeleteKey = unsafeDeleteKey; -exports.entries = entries; -exports.values = values; -exports.fromList = fromList; -exports.fromArray = fromArray; -exports.map = map; -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Js_extern.cjs b/packages/@rescript/runtime/lib/js/Js_extern.cjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_extern.cjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/js/Js_file.cjs b/packages/@rescript/runtime/lib/js/Js_file.cjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_file.cjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/js/Js_float.cjs b/packages/@rescript/runtime/lib/js/Js_float.cjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_float.cjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/js/Js_global.cjs b/packages/@rescript/runtime/lib/js/Js_global.cjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_global.cjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/js/Js_int.cjs b/packages/@rescript/runtime/lib/js/Js_int.cjs deleted file mode 100644 index 95dcd37e777..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_int.cjs +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - - -function equal(x, y) { - return x === y; -} - -let max = 2147483647; - -let min = -2147483648; - -exports.equal = equal; -exports.max = max; -exports.min = min; -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Js_json.cjs b/packages/@rescript/runtime/lib/js/Js_json.cjs deleted file mode 100644 index d074c4cfb6b..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_json.cjs +++ /dev/null @@ -1,165 +0,0 @@ -'use strict'; - - -let Kind = {}; - -function classify(x) { - let ty = typeof x; - if (ty === "string") { - return { - TAG: "JSONString", - _0: x - }; - } else if (ty === "number") { - return { - TAG: "JSONNumber", - _0: x - }; - } else if (ty === "boolean") { - if (x === true) { - return "JSONTrue"; - } else { - return "JSONFalse"; - } - } else if (x === null) { - return "JSONNull"; - } else if (Array.isArray(x)) { - return { - TAG: "JSONArray", - _0: x - }; - } else { - return { - TAG: "JSONObject", - _0: x - }; - } -} - -function test(x, v) { - switch (v) { - case "String" : - return typeof x === "string"; - case "Number" : - return typeof x === "number"; - case "Object" : - if (x !== null && typeof x === "object") { - return !Array.isArray(x); - } else { - return false; - } - case "Array" : - return Array.isArray(x); - case "Boolean" : - return typeof x === "boolean"; - case "Null" : - return x === null; - } -} - -function decodeString(json) { - if (typeof json === "string") { - return json; - } -} - -function decodeNumber(json) { - if (typeof json === "number") { - return json; - } -} - -function decodeObject(json) { - if (typeof json === "object" && !Array.isArray(json) && json !== null) { - return json; - } -} - -function decodeArray(json) { - if (Array.isArray(json)) { - return json; - } -} - -function decodeBoolean(json) { - if (typeof json === "boolean") { - return json; - } -} - -function decodeNull(json) { - if (json === null) { - return null; - } -} - -let patch = (function (json) { - var x = [json]; - var q = [{ kind: 0, i: 0, parent: x }]; - while (q.length !== 0) { - // begin pop the stack - var cur = q[q.length - 1]; - if (cur.kind === 0) { - cur.val = cur.parent[cur.i]; // patch the undefined value for array - if (++cur.i === cur.parent.length) { - q.pop(); - } - } else { - q.pop(); - } - // finish - var task = cur.val; - if (typeof task === "object") { - if (Array.isArray(task) && task.length !== 0) { - q.push({ kind: 0, i: 0, parent: task, val: undefined }); - } else { - for (var k in task) { - if (k === "RE_PRIVATE_NONE") { - if (cur.kind === 0) { - cur.parent[cur.i - 1] = undefined; - } else { - cur.parent[cur.i] = undefined; - } - continue; - } - q.push({ kind: 1, i: k, parent: task, val: task[k] }); - } - } - } - } - return x[0]; -}); - -function serializeExn(x) { - return (function(obj){ - var output= JSON.stringify(obj,function(_,value){ - if(value===undefined){ - return {RE_PRIVATE_NONE : true} - } - return value - }); - - if(output === undefined){ - // JSON.stringify will throw TypeError when it detects cylic objects - throw new TypeError("output is undefined") - } - return output - })(x); -} - -function deserializeUnsafe(s) { - return patch(JSON.parse(s)); -} - -exports.Kind = Kind; -exports.classify = classify; -exports.test = test; -exports.decodeString = decodeString; -exports.decodeNumber = decodeNumber; -exports.decodeObject = decodeObject; -exports.decodeArray = decodeArray; -exports.decodeBoolean = decodeBoolean; -exports.decodeNull = decodeNull; -exports.deserializeUnsafe = deserializeUnsafe; -exports.serializeExn = serializeExn; -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Js_map.cjs b/packages/@rescript/runtime/lib/js/Js_map.cjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_map.cjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/js/Js_math.cjs b/packages/@rescript/runtime/lib/js/Js_math.cjs deleted file mode 100644 index 675ac434d0f..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_math.cjs +++ /dev/null @@ -1,48 +0,0 @@ -'use strict'; - -let Js_int = require("./Js_int.cjs"); - -function unsafe_ceil(prim) { - return Math.ceil(prim); -} - -function ceil_int(f) { - if (f > Js_int.max) { - return Js_int.max; - } else if (f < Js_int.min) { - return Js_int.min; - } else { - return Math.ceil(f); - } -} - -function unsafe_floor(prim) { - return Math.floor(prim); -} - -function floor_int(f) { - if (f > Js_int.max) { - return Js_int.max; - } else if (f < Js_int.min) { - return Js_int.min; - } else { - return Math.floor(f); - } -} - -function random_int(min, max) { - return floor_int(Math.random() * (max - min | 0)) + min | 0; -} - -let ceil = ceil_int; - -let floor = floor_int; - -exports.unsafe_ceil = unsafe_ceil; -exports.ceil_int = ceil_int; -exports.ceil = ceil; -exports.unsafe_floor = unsafe_floor; -exports.floor_int = floor_int; -exports.floor = floor; -exports.random_int = random_int; -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Js_null.cjs b/packages/@rescript/runtime/lib/js/Js_null.cjs deleted file mode 100644 index df623efc040..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_null.cjs +++ /dev/null @@ -1,46 +0,0 @@ -'use strict'; - -let Primitive_option = require("./Primitive_option.cjs"); - -function test(x) { - return x === null; -} - -function getExn(f) { - if (f !== null) { - return f; - } - throw new Error("Js.Null.getExn"); -} - -function bind(x, f) { - if (x !== null) { - return f(x); - } else { - return null; - } -} - -function iter(x, f) { - if (x !== null) { - return f(x); - } -} - -function fromOption(x) { - if (x !== undefined) { - return Primitive_option.valFromOption(x); - } else { - return null; - } -} - -let from_opt = fromOption; - -exports.test = test; -exports.getExn = getExn; -exports.bind = bind; -exports.iter = iter; -exports.fromOption = fromOption; -exports.from_opt = from_opt; -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Js_null_undefined.cjs b/packages/@rescript/runtime/lib/js/Js_null_undefined.cjs deleted file mode 100644 index 324cf03d9ce..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_null_undefined.cjs +++ /dev/null @@ -1,31 +0,0 @@ -'use strict'; - -let Primitive_option = require("./Primitive_option.cjs"); - -function bind(x, f) { - if (x == null) { - return x; - } else { - return f(x); - } -} - -function iter(x, f) { - if (!(x == null)) { - return f(x); - } -} - -function fromOption(x) { - if (x !== undefined) { - return Primitive_option.valFromOption(x); - } -} - -let from_opt = fromOption; - -exports.bind = bind; -exports.iter = iter; -exports.fromOption = fromOption; -exports.from_opt = from_opt; -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Js_obj.cjs b/packages/@rescript/runtime/lib/js/Js_obj.cjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_obj.cjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/js/Js_option.cjs b/packages/@rescript/runtime/lib/js/Js_option.cjs deleted file mode 100644 index 61b4f600256..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_option.cjs +++ /dev/null @@ -1,99 +0,0 @@ -'use strict'; - -let Primitive_option = require("./Primitive_option.cjs"); - -function some(x) { - return Primitive_option.some(x); -} - -function isSome(x) { - return x !== undefined; -} - -function isSomeValue(eq, v, x) { - if (x !== undefined) { - return eq(v, Primitive_option.valFromOption(x)); - } else { - return false; - } -} - -function isNone(x) { - return x === undefined; -} - -function getExn(x) { - if (x !== undefined) { - return Primitive_option.valFromOption(x); - } - throw new Error("getExn"); -} - -function equal(eq, a, b) { - if (a !== undefined) { - if (b !== undefined) { - return eq(Primitive_option.valFromOption(a), Primitive_option.valFromOption(b)); - } else { - return false; - } - } else { - return b === undefined; - } -} - -function andThen(f, x) { - if (x !== undefined) { - return f(Primitive_option.valFromOption(x)); - } -} - -function map(f, x) { - if (x !== undefined) { - return Primitive_option.some(f(Primitive_option.valFromOption(x))); - } -} - -function getWithDefault(a, x) { - if (x !== undefined) { - return Primitive_option.valFromOption(x); - } else { - return a; - } -} - -function filter(f, x) { - if (x === undefined) { - return; - } - let x$1 = Primitive_option.valFromOption(x); - if (f(x$1)) { - return Primitive_option.some(x$1); - } -} - -function firstSome(a, b) { - if (a !== undefined) { - return a; - } else if (b !== undefined) { - return b; - } else { - return; - } -} - -let $$default = getWithDefault; - -exports.some = some; -exports.isSome = isSome; -exports.isSomeValue = isSomeValue; -exports.isNone = isNone; -exports.getExn = getExn; -exports.equal = equal; -exports.andThen = andThen; -exports.map = map; -exports.getWithDefault = getWithDefault; -exports.default = $$default; -exports.__esModule = true; -exports.filter = filter; -exports.firstSome = firstSome; -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Js_promise.cjs b/packages/@rescript/runtime/lib/js/Js_promise.cjs deleted file mode 100644 index f4ade6ef7f9..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_promise.cjs +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - - -function then_(arg1, obj) { - return obj.then(arg1); -} - -function $$catch(arg1, obj) { - return obj.catch(arg1); -} - -exports.then_ = then_; -exports.$$catch = $$catch; -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Js_promise2.cjs b/packages/@rescript/runtime/lib/js/Js_promise2.cjs deleted file mode 100644 index e5b902e114d..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_promise2.cjs +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - - -let then = (function(p, cont) { - return Promise.resolve(p).then(cont) - }); - -let $$catch = (function(p, cont) { - return Promise.resolve(p).catch(cont) - }); - -exports.then = then; -exports.$$catch = $$catch; -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Js_re.cjs b/packages/@rescript/runtime/lib/js/Js_re.cjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_re.cjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/js/Js_result.cjs b/packages/@rescript/runtime/lib/js/Js_result.cjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_result.cjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/js/Js_set.cjs b/packages/@rescript/runtime/lib/js/Js_set.cjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_set.cjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/js/Js_string.cjs b/packages/@rescript/runtime/lib/js/Js_string.cjs deleted file mode 100644 index 93e718d3db4..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_string.cjs +++ /dev/null @@ -1,195 +0,0 @@ -'use strict'; - -let Primitive_option = require("./Primitive_option.cjs"); - -function charAt(arg1, obj) { - return obj.charAt(arg1); -} - -function charCodeAt(arg1, obj) { - return obj.charCodeAt(arg1); -} - -function codePointAt(arg1, obj) { - return obj.codePointAt(arg1); -} - -function concat(arg1, obj) { - return obj.concat(arg1); -} - -function concatMany(arg1, obj) { - return obj.concat(...arg1); -} - -function endsWith(arg1, obj) { - return obj.endsWith(arg1); -} - -function endsWithFrom(arg1, arg2, obj) { - return obj.endsWith(arg1, arg2); -} - -function includes(arg1, obj) { - return obj.includes(arg1); -} - -function includesFrom(arg1, arg2, obj) { - return obj.includes(arg1, arg2); -} - -function indexOf(arg1, obj) { - return obj.indexOf(arg1); -} - -function indexOfFrom(arg1, arg2, obj) { - return obj.indexOf(arg1, arg2); -} - -function lastIndexOf(arg1, obj) { - return obj.lastIndexOf(arg1); -} - -function lastIndexOfFrom(arg1, arg2, obj) { - return obj.lastIndexOf(arg1, arg2); -} - -function localeCompare(arg1, obj) { - return obj.localeCompare(arg1); -} - -function match_(arg1, obj) { - return Primitive_option.fromNull(obj.match(arg1)); -} - -function normalizeByForm(arg1, obj) { - return obj.normalize(arg1); -} - -function repeat(arg1, obj) { - return obj.repeat(arg1); -} - -function replace(arg1, arg2, obj) { - return obj.replace(arg1, arg2); -} - -function replaceByRe(arg1, arg2, obj) { - return obj.replace(arg1, arg2); -} - -function unsafeReplaceBy0(arg1, arg2, obj) { - return obj.replace(arg1, arg2); -} - -function unsafeReplaceBy1(arg1, arg2, obj) { - return obj.replace(arg1, arg2); -} - -function unsafeReplaceBy2(arg1, arg2, obj) { - return obj.replace(arg1, arg2); -} - -function unsafeReplaceBy3(arg1, arg2, obj) { - return obj.replace(arg1, arg2); -} - -function search(arg1, obj) { - return obj.search(arg1); -} - -function slice(from, to_, obj) { - return obj.slice(from, to_); -} - -function sliceToEnd(from, obj) { - return obj.slice(from); -} - -function split(arg1, obj) { - return obj.split(arg1); -} - -function splitAtMost(arg1, limit, obj) { - return obj.split(arg1, limit); -} - -function splitByRe(arg1, obj) { - return obj.split(arg1); -} - -function splitByReAtMost(arg1, limit, obj) { - return obj.split(arg1, limit); -} - -function startsWith(arg1, obj) { - return obj.startsWith(arg1); -} - -function startsWithFrom(arg1, arg2, obj) { - return obj.startsWith(arg1, arg2); -} - -function substr(from, obj) { - return obj.substr(from); -} - -function substrAtMost(from, length, obj) { - return obj.substr(from, length); -} - -function substring(from, to_, obj) { - return obj.substring(from, to_); -} - -function substringToEnd(from, obj) { - return obj.substring(from); -} - -function anchor(arg1, obj) { - return obj.anchor(arg1); -} - -function link(arg1, obj) { - return obj.link(arg1); -} - -exports.charAt = charAt; -exports.charCodeAt = charCodeAt; -exports.codePointAt = codePointAt; -exports.concat = concat; -exports.concatMany = concatMany; -exports.endsWith = endsWith; -exports.endsWithFrom = endsWithFrom; -exports.includes = includes; -exports.includesFrom = includesFrom; -exports.indexOf = indexOf; -exports.indexOfFrom = indexOfFrom; -exports.lastIndexOf = lastIndexOf; -exports.lastIndexOfFrom = lastIndexOfFrom; -exports.localeCompare = localeCompare; -exports.match_ = match_; -exports.normalizeByForm = normalizeByForm; -exports.repeat = repeat; -exports.replace = replace; -exports.replaceByRe = replaceByRe; -exports.unsafeReplaceBy0 = unsafeReplaceBy0; -exports.unsafeReplaceBy1 = unsafeReplaceBy1; -exports.unsafeReplaceBy2 = unsafeReplaceBy2; -exports.unsafeReplaceBy3 = unsafeReplaceBy3; -exports.search = search; -exports.slice = slice; -exports.sliceToEnd = sliceToEnd; -exports.split = split; -exports.splitAtMost = splitAtMost; -exports.splitByRe = splitByRe; -exports.splitByReAtMost = splitByReAtMost; -exports.startsWith = startsWith; -exports.startsWithFrom = startsWithFrom; -exports.substr = substr; -exports.substrAtMost = substrAtMost; -exports.substring = substring; -exports.substringToEnd = substringToEnd; -exports.anchor = anchor; -exports.link = link; -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Js_string2.cjs b/packages/@rescript/runtime/lib/js/Js_string2.cjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_string2.cjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/js/Js_typed_array.cjs b/packages/@rescript/runtime/lib/js/Js_typed_array.cjs deleted file mode 100644 index e0a5cdac2d3..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_typed_array.cjs +++ /dev/null @@ -1,46 +0,0 @@ -'use strict'; - - -let $$ArrayBuffer = {}; - -let $$Int8Array = {}; - -let $$Uint8Array = {}; - -let $$Uint8ClampedArray = {}; - -let $$Int16Array = {}; - -let $$Uint16Array = {}; - -let $$Int32Array = {}; - -let $$Uint32Array = {}; - -let $$Float32Array = {}; - -let $$Float64Array = {}; - -let $$DataView = {}; - -let Int32_array; - -let Float32_array; - -let Float64_array; - -exports.$$ArrayBuffer = $$ArrayBuffer; -exports.$$Int8Array = $$Int8Array; -exports.$$Uint8Array = $$Uint8Array; -exports.$$Uint8ClampedArray = $$Uint8ClampedArray; -exports.$$Int16Array = $$Int16Array; -exports.$$Uint16Array = $$Uint16Array; -exports.$$Int32Array = $$Int32Array; -exports.Int32_array = Int32_array; -exports.$$Uint32Array = $$Uint32Array; -exports.$$Float32Array = $$Float32Array; -exports.Float32_array = Float32_array; -exports.$$Float64Array = $$Float64Array; -exports.Float64_array = Float64_array; -exports.$$DataView = $$DataView; -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Js_typed_array2.cjs b/packages/@rescript/runtime/lib/js/Js_typed_array2.cjs deleted file mode 100644 index a54929d49cd..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_typed_array2.cjs +++ /dev/null @@ -1,37 +0,0 @@ -'use strict'; - - -let $$ArrayBuffer = {}; - -let $$Int8Array = {}; - -let $$Uint8Array = {}; - -let $$Uint8ClampedArray = {}; - -let $$Int16Array = {}; - -let $$Uint16Array = {}; - -let $$Int32Array = {}; - -let $$Uint32Array = {}; - -let $$Float32Array = {}; - -let $$Float64Array = {}; - -let $$DataView = {}; - -exports.$$ArrayBuffer = $$ArrayBuffer; -exports.$$Int8Array = $$Int8Array; -exports.$$Uint8Array = $$Uint8Array; -exports.$$Uint8ClampedArray = $$Uint8ClampedArray; -exports.$$Int16Array = $$Int16Array; -exports.$$Uint16Array = $$Uint16Array; -exports.$$Int32Array = $$Int32Array; -exports.$$Uint32Array = $$Uint32Array; -exports.$$Float32Array = $$Float32Array; -exports.$$Float64Array = $$Float64Array; -exports.$$DataView = $$DataView; -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Js_types.cjs b/packages/@rescript/runtime/lib/js/Js_types.cjs deleted file mode 100644 index 47520c60762..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_types.cjs +++ /dev/null @@ -1,74 +0,0 @@ -'use strict'; - - -function classify(x) { - let ty = typeof x; - if (ty === "undefined") { - return "JSUndefined"; - } else if (x === null) { - return "JSNull"; - } else if (ty === "number") { - return { - TAG: "JSNumber", - _0: x - }; - } else if (ty === "bigint") { - return { - TAG: "JSBigInt", - _0: x - }; - } else if (ty === "string") { - return { - TAG: "JSString", - _0: x - }; - } else if (ty === "boolean") { - if (x === true) { - return "JSTrue"; - } else { - return "JSFalse"; - } - } else if (ty === "symbol") { - return { - TAG: "JSSymbol", - _0: x - }; - } else if (ty === "function") { - return { - TAG: "JSFunction", - _0: x - }; - } else { - return { - TAG: "JSObject", - _0: x - }; - } -} - -function test(x, v) { - switch (v) { - case "Undefined" : - return typeof x === "undefined"; - case "Null" : - return x === null; - case "Boolean" : - return typeof x === "boolean"; - case "Number" : - return typeof x === "number"; - case "String" : - return typeof x === "string"; - case "Function" : - return typeof x === "function"; - case "Object" : - return typeof x === "object"; - case "Symbol" : - return typeof x === "symbol"; - case "BigInt" : - return typeof x === "bigint"; - } -} - -exports.test = test; -exports.classify = classify; -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Js_undefined.cjs b/packages/@rescript/runtime/lib/js/Js_undefined.cjs deleted file mode 100644 index 132d9a4b4d5..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_undefined.cjs +++ /dev/null @@ -1,56 +0,0 @@ -'use strict'; - -let Primitive_option = require("./Primitive_option.cjs"); - -function test(x) { - return x === undefined; -} - -function testAny(x) { - return x === undefined; -} - -function getExn(f) { - let x = Primitive_option.fromUndefined(f); - if (x !== undefined) { - return Primitive_option.valFromOption(x); - } - throw new Error("Js.Undefined.getExn"); -} - -function bind(x, f) { - let x$1 = Primitive_option.fromUndefined(x); - if (x$1 !== undefined) { - return f(Primitive_option.valFromOption(x$1)); - } -} - -function iter(x, f) { - let x$1 = Primitive_option.fromUndefined(x); - if (x$1 !== undefined) { - return f(Primitive_option.valFromOption(x$1)); - } -} - -function fromOption(x) { - if (x !== undefined) { - return Primitive_option.valFromOption(x); - } -} - -let from_opt = fromOption; - -let toOption = Primitive_option.fromUndefined; - -let to_opt = Primitive_option.fromUndefined; - -exports.test = test; -exports.testAny = testAny; -exports.getExn = getExn; -exports.bind = bind; -exports.iter = iter; -exports.fromOption = fromOption; -exports.from_opt = from_opt; -exports.toOption = toOption; -exports.to_opt = to_opt; -/* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Js_weakmap.cjs b/packages/@rescript/runtime/lib/js/Js_weakmap.cjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_weakmap.cjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/js/Js_weakset.cjs b/packages/@rescript/runtime/lib/js/Js_weakset.cjs deleted file mode 100644 index ae1b9f17e65..00000000000 --- a/packages/@rescript/runtime/lib/js/Js_weakset.cjs +++ /dev/null @@ -1 +0,0 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/packages/@rescript/runtime/lib/js/Primitive_hash.cjs b/packages/@rescript/runtime/lib/js/Primitive_hash.cjs index 97c342fba64..cc87d555314 100644 --- a/packages/@rescript/runtime/lib/js/Primitive_hash.cjs +++ b/packages/@rescript/runtime/lib/js/Primitive_hash.cjs @@ -36,7 +36,7 @@ function unsafe_pop(q) { RE_EXN_ID: "Assert_failure", _1: [ "Primitive_hash.res", - 55, + 58, 12 ], Error: new Error() diff --git a/packages/@rescript/runtime/lib/js/Primitive_js_extern.cjs b/packages/@rescript/runtime/lib/js/Primitive_js_extern.cjs index ae1b9f17e65..d7a97adee6b 100644 --- a/packages/@rescript/runtime/lib/js/Primitive_js_extern.cjs +++ b/packages/@rescript/runtime/lib/js/Primitive_js_extern.cjs @@ -1 +1,7 @@ -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ +'use strict'; + + +let Callback = {}; + +exports.Callback = Callback; +/* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Primitive_util.cjs b/packages/@rescript/runtime/lib/js/Primitive_util.cjs index 5641a5a9485..0f0f4175e32 100644 --- a/packages/@rescript/runtime/lib/js/Primitive_util.cjs +++ b/packages/@rescript/runtime/lib/js/Primitive_util.cjs @@ -11,8 +11,5 @@ function raiseWhenNotFound(x) { return x; } -let Js; - -exports.Js = Js; exports.raiseWhenNotFound = raiseWhenNotFound; /* No side effect */ diff --git a/packages/@rescript/runtime/lib/js/Stdlib.cjs b/packages/@rescript/runtime/lib/js/Stdlib.cjs index 04699b52158..a8136f07d3b 100644 --- a/packages/@rescript/runtime/lib/js/Stdlib.cjs +++ b/packages/@rescript/runtime/lib/js/Stdlib.cjs @@ -12,7 +12,7 @@ function assertEqual(a, b) { RE_EXN_ID: "Assert_failure", _1: [ "Stdlib.res", - 161, + 163, 4 ], Error: new Error() @@ -27,6 +27,8 @@ let $$Array; let $$BigInt; +let Blob; + let Bool; let Console; @@ -41,6 +43,8 @@ let Exn; let $$Error; +let File; + let Float; let Int; @@ -143,6 +147,7 @@ exports.TimeoutId = TimeoutId; exports.IntervalId = IntervalId; exports.$$Array = $$Array; exports.$$BigInt = $$BigInt; +exports.Blob = Blob; exports.Bool = Bool; exports.Console = Console; exports.$$DataView = $$DataView; @@ -150,6 +155,7 @@ exports.$$Date = $$Date; exports.Dict = Dict; exports.Exn = Exn; exports.$$Error = $$Error; +exports.File = File; exports.Float = Float; exports.Int = Int; exports.$$Intl = $$Intl; diff --git a/packages/@rescript/runtime/lib/es6/Js_console.mjs b/packages/@rescript/runtime/lib/js/Stdlib_Blob.cjs similarity index 100% rename from packages/@rescript/runtime/lib/es6/Js_console.mjs rename to packages/@rescript/runtime/lib/js/Stdlib_Blob.cjs diff --git a/packages/@rescript/runtime/lib/es6/Js_date.mjs b/packages/@rescript/runtime/lib/js/Stdlib_File.cjs similarity index 100% rename from packages/@rescript/runtime/lib/es6/Js_date.mjs rename to packages/@rescript/runtime/lib/js/Stdlib_File.cjs diff --git a/packages/artifacts.json b/packages/artifacts.json index 19fd3e0e5ec..1158b170112 100644 --- a/packages/artifacts.json +++ b/packages/artifacts.json @@ -65,40 +65,6 @@ "lib/es6/Dom.mjs", "lib/es6/Dom_storage.mjs", "lib/es6/Dom_storage2.mjs", - "lib/es6/Js.mjs", - "lib/es6/Js_OO.mjs", - "lib/es6/Js_array.mjs", - "lib/es6/Js_array2.mjs", - "lib/es6/Js_bigint.mjs", - "lib/es6/Js_blob.mjs", - "lib/es6/Js_console.mjs", - "lib/es6/Js_date.mjs", - "lib/es6/Js_dict.mjs", - "lib/es6/Js_extern.mjs", - "lib/es6/Js_file.mjs", - "lib/es6/Js_float.mjs", - "lib/es6/Js_global.mjs", - "lib/es6/Js_int.mjs", - "lib/es6/Js_json.mjs", - "lib/es6/Js_map.mjs", - "lib/es6/Js_math.mjs", - "lib/es6/Js_null.mjs", - "lib/es6/Js_null_undefined.mjs", - "lib/es6/Js_obj.mjs", - "lib/es6/Js_option.mjs", - "lib/es6/Js_promise.mjs", - "lib/es6/Js_promise2.mjs", - "lib/es6/Js_re.mjs", - "lib/es6/Js_result.mjs", - "lib/es6/Js_set.mjs", - "lib/es6/Js_string.mjs", - "lib/es6/Js_string2.mjs", - "lib/es6/Js_typed_array.mjs", - "lib/es6/Js_typed_array2.mjs", - "lib/es6/Js_types.mjs", - "lib/es6/Js_undefined.mjs", - "lib/es6/Js_weakmap.mjs", - "lib/es6/Js_weakset.mjs", "lib/es6/Jsx.mjs", "lib/es6/JsxDOM.mjs", "lib/es6/JsxDOMStyle.mjs", @@ -140,6 +106,7 @@ "lib/es6/Stdlib_BigInt.mjs", "lib/es6/Stdlib_BigInt64Array.mjs", "lib/es6/Stdlib_BigUint64Array.mjs", + "lib/es6/Stdlib_Blob.mjs", "lib/es6/Stdlib_Bool.mjs", "lib/es6/Stdlib_Console.mjs", "lib/es6/Stdlib_DataView.mjs", @@ -147,6 +114,7 @@ "lib/es6/Stdlib_Dict.mjs", "lib/es6/Stdlib_Error.mjs", "lib/es6/Stdlib_Exn.mjs", + "lib/es6/Stdlib_File.mjs", "lib/es6/Stdlib_Float.mjs", "lib/es6/Stdlib_Float32Array.mjs", "lib/es6/Stdlib_Float64Array.mjs", @@ -247,40 +215,6 @@ "lib/js/Dom.cjs", "lib/js/Dom_storage.cjs", "lib/js/Dom_storage2.cjs", - "lib/js/Js.cjs", - "lib/js/Js_OO.cjs", - "lib/js/Js_array.cjs", - "lib/js/Js_array2.cjs", - "lib/js/Js_bigint.cjs", - "lib/js/Js_blob.cjs", - "lib/js/Js_console.cjs", - "lib/js/Js_date.cjs", - "lib/js/Js_dict.cjs", - "lib/js/Js_extern.cjs", - "lib/js/Js_file.cjs", - "lib/js/Js_float.cjs", - "lib/js/Js_global.cjs", - "lib/js/Js_int.cjs", - "lib/js/Js_json.cjs", - "lib/js/Js_map.cjs", - "lib/js/Js_math.cjs", - "lib/js/Js_null.cjs", - "lib/js/Js_null_undefined.cjs", - "lib/js/Js_obj.cjs", - "lib/js/Js_option.cjs", - "lib/js/Js_promise.cjs", - "lib/js/Js_promise2.cjs", - "lib/js/Js_re.cjs", - "lib/js/Js_result.cjs", - "lib/js/Js_set.cjs", - "lib/js/Js_string.cjs", - "lib/js/Js_string2.cjs", - "lib/js/Js_typed_array.cjs", - "lib/js/Js_typed_array2.cjs", - "lib/js/Js_types.cjs", - "lib/js/Js_undefined.cjs", - "lib/js/Js_weakmap.cjs", - "lib/js/Js_weakset.cjs", "lib/js/Jsx.cjs", "lib/js/JsxDOM.cjs", "lib/js/JsxDOMStyle.cjs", @@ -322,6 +256,7 @@ "lib/js/Stdlib_BigInt.cjs", "lib/js/Stdlib_BigInt64Array.cjs", "lib/js/Stdlib_BigUint64Array.cjs", + "lib/js/Stdlib_Blob.cjs", "lib/js/Stdlib_Bool.cjs", "lib/js/Stdlib_Console.cjs", "lib/js/Stdlib_DataView.cjs", @@ -329,6 +264,7 @@ "lib/js/Stdlib_Dict.cjs", "lib/js/Stdlib_Error.cjs", "lib/js/Stdlib_Exn.cjs", + "lib/js/Stdlib_File.cjs", "lib/js/Stdlib_Float.cjs", "lib/js/Stdlib_Float32Array.cjs", "lib/js/Stdlib_Float64Array.cjs", @@ -648,162 +584,6 @@ "lib/ocaml/Dom_storage2.cmj", "lib/ocaml/Dom_storage2.cmt", "lib/ocaml/Dom_storage2.res", - "lib/ocaml/Js.cmi", - "lib/ocaml/Js.cmj", - "lib/ocaml/Js.cmt", - "lib/ocaml/Js.res", - "lib/ocaml/Js_OO.cmi", - "lib/ocaml/Js_OO.cmj", - "lib/ocaml/Js_OO.cmt", - "lib/ocaml/Js_OO.res", - "lib/ocaml/Js_array.cmi", - "lib/ocaml/Js_array.cmj", - "lib/ocaml/Js_array.cmt", - "lib/ocaml/Js_array.res", - "lib/ocaml/Js_array2.cmi", - "lib/ocaml/Js_array2.cmj", - "lib/ocaml/Js_array2.cmt", - "lib/ocaml/Js_array2.res", - "lib/ocaml/Js_bigint.cmi", - "lib/ocaml/Js_bigint.cmj", - "lib/ocaml/Js_bigint.cmt", - "lib/ocaml/Js_bigint.res", - "lib/ocaml/Js_blob.cmi", - "lib/ocaml/Js_blob.cmj", - "lib/ocaml/Js_blob.cmt", - "lib/ocaml/Js_blob.res", - "lib/ocaml/Js_console.cmi", - "lib/ocaml/Js_console.cmj", - "lib/ocaml/Js_console.cmt", - "lib/ocaml/Js_console.res", - "lib/ocaml/Js_date.cmi", - "lib/ocaml/Js_date.cmj", - "lib/ocaml/Js_date.cmt", - "lib/ocaml/Js_date.res", - "lib/ocaml/Js_dict.cmi", - "lib/ocaml/Js_dict.cmj", - "lib/ocaml/Js_dict.cmt", - "lib/ocaml/Js_dict.cmti", - "lib/ocaml/Js_dict.res", - "lib/ocaml/Js_dict.resi", - "lib/ocaml/Js_extern.cmi", - "lib/ocaml/Js_extern.cmj", - "lib/ocaml/Js_extern.cmt", - "lib/ocaml/Js_extern.res", - "lib/ocaml/Js_file.cmi", - "lib/ocaml/Js_file.cmj", - "lib/ocaml/Js_file.cmt", - "lib/ocaml/Js_file.res", - "lib/ocaml/Js_float.cmi", - "lib/ocaml/Js_float.cmj", - "lib/ocaml/Js_float.cmt", - "lib/ocaml/Js_float.res", - "lib/ocaml/Js_global.cmi", - "lib/ocaml/Js_global.cmj", - "lib/ocaml/Js_global.cmt", - "lib/ocaml/Js_global.res", - "lib/ocaml/Js_int.cmi", - "lib/ocaml/Js_int.cmj", - "lib/ocaml/Js_int.cmt", - "lib/ocaml/Js_int.res", - "lib/ocaml/Js_json.cmi", - "lib/ocaml/Js_json.cmj", - "lib/ocaml/Js_json.cmt", - "lib/ocaml/Js_json.cmti", - "lib/ocaml/Js_json.res", - "lib/ocaml/Js_json.resi", - "lib/ocaml/Js_map.cmi", - "lib/ocaml/Js_map.cmj", - "lib/ocaml/Js_map.cmt", - "lib/ocaml/Js_map.res", - "lib/ocaml/Js_math.cmi", - "lib/ocaml/Js_math.cmj", - "lib/ocaml/Js_math.cmt", - "lib/ocaml/Js_math.res", - "lib/ocaml/Js_null.cmi", - "lib/ocaml/Js_null.cmj", - "lib/ocaml/Js_null.cmt", - "lib/ocaml/Js_null.cmti", - "lib/ocaml/Js_null.res", - "lib/ocaml/Js_null.resi", - "lib/ocaml/Js_null_undefined.cmi", - "lib/ocaml/Js_null_undefined.cmj", - "lib/ocaml/Js_null_undefined.cmt", - "lib/ocaml/Js_null_undefined.cmti", - "lib/ocaml/Js_null_undefined.res", - "lib/ocaml/Js_null_undefined.resi", - "lib/ocaml/Js_obj.cmi", - "lib/ocaml/Js_obj.cmj", - "lib/ocaml/Js_obj.cmt", - "lib/ocaml/Js_obj.res", - "lib/ocaml/Js_option.cmi", - "lib/ocaml/Js_option.cmj", - "lib/ocaml/Js_option.cmt", - "lib/ocaml/Js_option.cmti", - "lib/ocaml/Js_option.res", - "lib/ocaml/Js_option.resi", - "lib/ocaml/Js_promise.cmi", - "lib/ocaml/Js_promise.cmj", - "lib/ocaml/Js_promise.cmt", - "lib/ocaml/Js_promise.cmti", - "lib/ocaml/Js_promise.res", - "lib/ocaml/Js_promise.resi", - "lib/ocaml/Js_promise2.cmi", - "lib/ocaml/Js_promise2.cmj", - "lib/ocaml/Js_promise2.cmt", - "lib/ocaml/Js_promise2.cmti", - "lib/ocaml/Js_promise2.res", - "lib/ocaml/Js_promise2.resi", - "lib/ocaml/Js_re.cmi", - "lib/ocaml/Js_re.cmj", - "lib/ocaml/Js_re.cmt", - "lib/ocaml/Js_re.res", - "lib/ocaml/Js_result.cmi", - "lib/ocaml/Js_result.cmj", - "lib/ocaml/Js_result.cmt", - "lib/ocaml/Js_result.cmti", - "lib/ocaml/Js_result.res", - "lib/ocaml/Js_result.resi", - "lib/ocaml/Js_set.cmi", - "lib/ocaml/Js_set.cmj", - "lib/ocaml/Js_set.cmt", - "lib/ocaml/Js_set.res", - "lib/ocaml/Js_string.cmi", - "lib/ocaml/Js_string.cmj", - "lib/ocaml/Js_string.cmt", - "lib/ocaml/Js_string.res", - "lib/ocaml/Js_string2.cmi", - "lib/ocaml/Js_string2.cmj", - "lib/ocaml/Js_string2.cmt", - "lib/ocaml/Js_string2.res", - "lib/ocaml/Js_typed_array.cmi", - "lib/ocaml/Js_typed_array.cmj", - "lib/ocaml/Js_typed_array.cmt", - "lib/ocaml/Js_typed_array.res", - "lib/ocaml/Js_typed_array2.cmi", - "lib/ocaml/Js_typed_array2.cmj", - "lib/ocaml/Js_typed_array2.cmt", - "lib/ocaml/Js_typed_array2.res", - "lib/ocaml/Js_types.cmi", - "lib/ocaml/Js_types.cmj", - "lib/ocaml/Js_types.cmt", - "lib/ocaml/Js_types.cmti", - "lib/ocaml/Js_types.res", - "lib/ocaml/Js_types.resi", - "lib/ocaml/Js_undefined.cmi", - "lib/ocaml/Js_undefined.cmj", - "lib/ocaml/Js_undefined.cmt", - "lib/ocaml/Js_undefined.cmti", - "lib/ocaml/Js_undefined.res", - "lib/ocaml/Js_undefined.resi", - "lib/ocaml/Js_weakmap.cmi", - "lib/ocaml/Js_weakmap.cmj", - "lib/ocaml/Js_weakmap.cmt", - "lib/ocaml/Js_weakmap.res", - "lib/ocaml/Js_weakset.cmi", - "lib/ocaml/Js_weakset.cmj", - "lib/ocaml/Js_weakset.cmt", - "lib/ocaml/Js_weakset.res", "lib/ocaml/Jsx.cmi", "lib/ocaml/Jsx.cmj", "lib/ocaml/Jsx.cmt", @@ -927,7 +707,9 @@ "lib/ocaml/Primitive_util.cmi", "lib/ocaml/Primitive_util.cmj", "lib/ocaml/Primitive_util.cmt", + "lib/ocaml/Primitive_util.cmti", "lib/ocaml/Primitive_util.res", + "lib/ocaml/Primitive_util.resi", "lib/ocaml/RescriptTools.cmi", "lib/ocaml/RescriptTools.cmj", "lib/ocaml/RescriptTools.cmt", @@ -996,6 +778,10 @@ "lib/ocaml/Stdlib_BigUint64Array.cmj", "lib/ocaml/Stdlib_BigUint64Array.cmt", "lib/ocaml/Stdlib_BigUint64Array.res", + "lib/ocaml/Stdlib_Blob.cmi", + "lib/ocaml/Stdlib_Blob.cmj", + "lib/ocaml/Stdlib_Blob.cmt", + "lib/ocaml/Stdlib_Blob.res", "lib/ocaml/Stdlib_Bool.cmi", "lib/ocaml/Stdlib_Bool.cmj", "lib/ocaml/Stdlib_Bool.cmt", @@ -1038,6 +824,10 @@ "lib/ocaml/Stdlib_Exn.cmti", "lib/ocaml/Stdlib_Exn.res", "lib/ocaml/Stdlib_Exn.resi", + "lib/ocaml/Stdlib_File.cmi", + "lib/ocaml/Stdlib_File.cmj", + "lib/ocaml/Stdlib_File.cmt", + "lib/ocaml/Stdlib_File.res", "lib/ocaml/Stdlib_Float.cmi", "lib/ocaml/Stdlib_Float.cmj", "lib/ocaml/Stdlib_Float.cmt", diff --git a/rewatch/testrepo/.yarn/patches/rescript-bun-npm-2.1.0-d9adc91a04.patch b/rewatch/testrepo/.yarn/patches/rescript-bun-npm-2.1.0-d9adc91a04.patch index ee5e4963794..c0cb5691a85 100644 --- a/rewatch/testrepo/.yarn/patches/rescript-bun-npm-2.1.0-d9adc91a04.patch +++ b/rewatch/testrepo/.yarn/patches/rescript-bun-npm-2.1.0-d9adc91a04.patch @@ -1,7 +1,25 @@ diff --git a/src/Bun.res b/src/Bun.res -index c5dbb6b991d19dd138aec65e4208ff4aec194e3c..2c313b1ff7c08f71aa64159ed430bd1872786f14 100644 +index c5dbb6b991d19dd138aec65e4208ff4aec194e3c..35ec921f3cefce21746eedbfc5bb2361ba1209f7 100644 --- a/src/Bun.res +++ b/src/Bun.res +@@ -327,7 +327,7 @@ module BunFile = { + @get + external size: t => float = "size" + +- external asBlob: t => Js.Blob.t = "%identity" ++ external asBlob: t => Stdlib.Blob.t = "%identity" + } + + type tlsOptions = { +@@ -646,7 +646,7 @@ external fileFromArrayBuffer: (ArrayBuffer.t, ~options: Blob.blobPropertyBag=?) + external fileFromFileDescriptor: (fileDescriptor, ~options: Blob.blobPropertyBag=?) => BunFile.t = + "Bun.file" + +-external fileFromFile: (Js.File.t, ~options: Blob.blobPropertyBag=?) => BunFile.t = "Bun.file" ++external fileFromFile: (Stdlib.File.t, ~options: Blob.blobPropertyBag=?) => BunFile.t = "Bun.file" + + /** + * Synchronously resolve a `moduleId` as though it were imported from `parent` @@ -3159,7 +3159,7 @@ module Glob = { * ``` */ @@ -68,7 +86,7 @@ index a71a6648ed36cb57849fc77a050117da8d6e438f..a253551552458d668d8ace7013f9ee16 +@send external values: t => IteratorObject.t = "entries" @send external forEach: (t, (string, string, t) => unit) => unit = "forEach" diff --git a/src/Globals.res b/src/Globals.res -index 8a19eb175c173d06fc19686f3f7171210960a6b8..d001c984dc2109ef89d2a8964a6e3856adbd2a93 100644 +index 8a19eb175c173d06fc19686f3f7171210960a6b8..60b2f0a5a5c92f9718fd2a825e5632bc2cbec028 100644 --- a/src/Globals.res +++ b/src/Globals.res @@ -145,9 +145,9 @@ module Headers = { @@ -84,6 +102,23 @@ index 8a19eb175c173d06fc19686f3f7171210960a6b8..d001c984dc2109ef89d2a8964a6e3856 @send external forEach: (t, (string, string, t) => unit) => unit = "forEach" /** +@@ -192,14 +192,14 @@ module FormData = { + + @new external make: unit => t = "FormData" + +- @unboxed type formDataEntryValue = String(string) | File(Js.File.t) ++ @unboxed type formDataEntryValue = String(string) | File(Stdlib.File.t) + @unboxed type formDataValueResult = | ...formDataEntryValue | @as(null) Null + + @send external get: (t, string) => formDataValueResult = "get" + @send external getAll: (t, string) => array = "getAll" + + @unboxed +- type stringOrBlob = String(string) | Blob(Js.Blob.t) ++ type stringOrBlob = String(string) | Blob(Stdlib.Blob.t) + + /** + * Appends a new value onto an existing key inside a FormData object, or adds @@ -222,9 +222,10 @@ module FormData = { @send external delete: (t, string) => unit = "delete" @send external has: (t, string) => bool = "has" @@ -109,6 +144,24 @@ index 8a19eb175c173d06fc19686f3f7171210960a6b8..d001c984dc2109ef89d2a8964a6e3856 @new external make: ( +@@ -504,7 +507,7 @@ module TransformStream = { + } + + module Blob = { +- type t = Js.Blob.t ++ type t = Stdlib.Blob.t + + /** + * Create a new view **without 🚫 copying** the underlying data. +@@ -577,7 +580,7 @@ module Blob = { + } + + module File = { +- type t = Js.File.t ++ type t = Stdlib.File.t + + /** + * Create a new view **without 🚫 copying** the underlying data. @@ -689,15 +692,15 @@ module URLSearchParams = { /** Returns an iterator allowing to go through all entries of the key/value pairs. */ @@ -163,3 +216,27 @@ index 5260b585d144bd1a51074f5f3811501ba4efc47e..8e2cbdc5b5ab1e3516be81b56dd952bf removed: bool, /** Whether the element is explicitly self-closing, e.g. `` */ selfClosing: bool, +diff --git a/src/Redis.res b/src/Redis.res +index 2327cdbe8f9c02709d5f3cd4ac3c48644ee155c1..6f19c405d80486a1b3b492cc6ec236ea60933ec8 100644 +--- a/src/Redis.res ++++ b/src/Redis.res +@@ -7,7 +7,7 @@ module RedisClient = { + type keyLike = + | String(string) + | ArrayBufferView(Types.ArrayBufferView.t) +- | Blob(Js.Blob.t) ++ | Blob(Stdlib.Blob.t) + + type redisOptions = { + connectionTimeout?: int, +diff --git a/src/Timers.res b/src/Timers.res +index 76d8dd579740d5a1b0d21b2818093b06061f031f..b6e40acd97b1e52b44a18725619da86e7bed6441 100644 +--- a/src/Timers.res ++++ b/src/Timers.res +@@ -29,5 +29,5 @@ module Promises = { + external setImmediate: 'a => promise<'a> = "setImmediate" + // setInterval is not a promise, it's an async iterator + // @module("node:timers/promises") +- // external setInterval: (int, 'a) => Js.Promise.t<'a> = "setTimeout" ++ // external setInterval: (int, 'a) => promise<'a> = "setTimeout" + } diff --git a/rewatch/testrepo/.yarn/patches/rescript-nodejs-npm-16.1.0-1841fa6174.patch b/rewatch/testrepo/.yarn/patches/rescript-nodejs-npm-16.1.0-1841fa6174.patch deleted file mode 100644 index 5428b38f20a..00000000000 --- a/rewatch/testrepo/.yarn/patches/rescript-nodejs-npm-16.1.0-1841fa6174.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff --git a/src/Zlib.res b/src/Zlib.res -index af800a0fa8751d49a56c9fcf98feec5f778e2e06..29ca39958e0349a4e0564faf103e0ce5e12ed3d0 100644 ---- a/src/Zlib.res -+++ b/src/Zlib.res -@@ -1,4 +1,4 @@ - @module("node:zlib") external deflateRawSync: Buffer.t => Buffer.t = "deflateRawSync" --@module("node:zlib") external deflateRaw: (Buffer.t, (. Buffer.t) => unit) => unit = "deflateRaw" -+@module("node:zlib") external deflateRaw: (Buffer.t, Buffer.t => unit) => unit = "deflateRaw" - @module("node:zlib") external inflateRawSync: Buffer.t => Buffer.t = "inflateRawSync" --@module("node:zlib") external inflateRaw: (Buffer.t, (. Buffer.t) => unit) => unit = "inflateRaw" -+@module("node:zlib") external inflateRaw: (Buffer.t, Buffer.t => unit) => unit = "inflateRaw" -diff --git a/test/atomic/BigInt.test.res b/test/atomic/BigInt.test.res -index fa3288442176de12af6911f6cde96dadab52ff9c..c751b6e77e85a040957a7e31396323170a144446 100644 ---- a/test/atomic/BigInt.test.res -+++ b/test/atomic/BigInt.test.res -@@ -9,7 +9,7 @@ zoraBlock("BigInt", t => { - t->block( - "'BigInt.fromInt' and 'BigInt.toInt' are associative operations for all 32-bit integers", - t => { -- let arrA = Belt.Array.makeByU(1000, (. _) => Random.int(1000000)) -+ let arrA = Belt.Array.makeByU(1000, _ => Random.int(1000000)) - let arrB = Belt.Array.map(arrA, BigInt.fromInt) - let arrC = Belt.Array.map(arrB, BigInt.toInt) - t->equal(arrA, arrC, "") diff --git a/rewatch/testrepo/packages/main/src/Main.mjs b/rewatch/testrepo/packages/main/src/Main.mjs index e4df550c4bf..d263cb67a24 100644 --- a/rewatch/testrepo/packages/main/src/Main.mjs +++ b/rewatch/testrepo/packages/main/src/Main.mjs @@ -11,10 +11,7 @@ console.log(InternalDep.value); let $$Array; -let $$String; - export { $$Array, - $$String, } /* Not a pure module */ diff --git a/rewatch/testrepo/packages/main/src/Main.res b/rewatch/testrepo/packages/main/src/Main.res index 3182ad4c755..09064d199ef 100644 --- a/rewatch/testrepo/packages/main/src/Main.res +++ b/rewatch/testrepo/packages/main/src/Main.res @@ -4,4 +4,3 @@ Dep01.log() Console.log(InternalDep.value) module Array = Belt.Array -module String = Js.String diff --git a/rewatch/testrepo/packages/standalone/src/Standalone.res b/rewatch/testrepo/packages/standalone/src/Standalone.res index 202c4f430a9..8bb4e24bc94 100644 --- a/rewatch/testrepo/packages/standalone/src/Standalone.res +++ b/rewatch/testrepo/packages/standalone/src/Standalone.res @@ -1,4 +1,4 @@ let standalone = () => { Dep01.log() - Js.log("standalone") + Console.log("standalone") } \ No newline at end of file diff --git a/rewatch/testrepo/packages/with-dev-deps/package.json b/rewatch/testrepo/packages/with-dev-deps/package.json index 612bc3627f9..160c569034c 100644 --- a/rewatch/testrepo/packages/with-dev-deps/package.json +++ b/rewatch/testrepo/packages/with-dev-deps/package.json @@ -10,6 +10,6 @@ "@rescript/webapi": "patch:@rescript/webapi@npm%3A0.1.0-experimental-73e6a0d#~/.yarn/patches/@rescript-webapi-npm-0.1.0-experimental-73e6a0d-288a2072f7.patch" }, "dependencies": { - "rescript-nodejs": "patch:rescript-nodejs@npm%3A16.1.0#~/.yarn/patches/rescript-nodejs-npm-16.1.0-1841fa6174.patch" + "rescript-nodejs": "17.0.0" } } diff --git a/rewatch/testrepo/packages/with-ppx/package.json b/rewatch/testrepo/packages/with-ppx/package.json index 8bd50de2c13..42daade8995 100644 --- a/rewatch/testrepo/packages/with-ppx/package.json +++ b/rewatch/testrepo/packages/with-ppx/package.json @@ -7,8 +7,8 @@ "author": "", "license": "MIT", "dependencies": { - "rescript-nodejs": "patch:rescript-nodejs@npm%3A16.1.0#~/.yarn/patches/rescript-nodejs-npm-16.1.0-1841fa6174.patch", - "sury": "^11.0.0-alpha.2", - "sury-ppx": "^11.0.0-alpha.2" + "rescript-nodejs": "17.0.0", + "sury": "11.0.0-rc.0", + "sury-ppx": "11.0.0-rc.0" } } diff --git a/rewatch/testrepo/packages/with-ppx/src/FileWithPpx.mjs b/rewatch/testrepo/packages/with-ppx/src/FileWithPpx.mjs index 659456d11f1..c22264d45d3 100644 --- a/rewatch/testrepo/packages/with-ppx/src/FileWithPpx.mjs +++ b/rewatch/testrepo/packages/with-ppx/src/FileWithPpx.mjs @@ -1,9 +1,10 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as S from "sury/src/S.mjs"; +import * as Sury from "sury"; -let schema = S.schema(s => ({ - foo: s.m(S.string) +let schema = Sury.$res_schema(s => ({ + foo: s.m(Sury.string) })); let foo = S.parseOrThrow(`{ "foo": "bar" }`, schema); diff --git a/rewatch/testrepo/packages/with-ppx/src/FileWithPpx.res b/rewatch/testrepo/packages/with-ppx/src/FileWithPpx.res index 1d80e5b98a9..09ba51efa89 100644 --- a/rewatch/testrepo/packages/with-ppx/src/FileWithPpx.res +++ b/rewatch/testrepo/packages/with-ppx/src/FileWithPpx.res @@ -1,6 +1,6 @@ @schema type t = {foo: string} -let foo = S.parseOrThrow(`{ "foo": "bar" }`, schema) +let foo = S.parseOrThrow(`{ "foo": "bar" }`, ~to=schema) -Console.log(foo) \ No newline at end of file +Console.log(foo) diff --git a/rewatch/testrepo/yarn.lock b/rewatch/testrepo/yarn.lock index 8776749aac1..69575e5643e 100644 --- a/rewatch/testrepo/yarn.lock +++ b/rewatch/testrepo/yarn.lock @@ -179,7 +179,7 @@ __metadata: resolution: "@testrepo/with-dev-deps@workspace:packages/with-dev-deps" dependencies: "@rescript/webapi": "patch:@rescript/webapi@npm%3A0.1.0-experimental-73e6a0d#~/.yarn/patches/@rescript-webapi-npm-0.1.0-experimental-73e6a0d-288a2072f7.patch" - rescript-nodejs: "patch:rescript-nodejs@npm%3A16.1.0#~/.yarn/patches/rescript-nodejs-npm-16.1.0-1841fa6174.patch" + rescript-nodejs: "npm:17.0.0" languageName: unknown linkType: soft @@ -187,9 +187,9 @@ __metadata: version: 0.0.0-use.local resolution: "@testrepo/with-ppx@workspace:packages/with-ppx" dependencies: - rescript-nodejs: "patch:rescript-nodejs@npm%3A16.1.0#~/.yarn/patches/rescript-nodejs-npm-16.1.0-1841fa6174.patch" - sury: "npm:^11.0.0-alpha.2" - sury-ppx: "npm:^11.0.0-alpha.2" + rescript-nodejs: "npm:17.0.0" + sury: "npm:11.0.0-rc.0" + sury-ppx: "npm:11.0.0-rc.0" languageName: unknown linkType: soft @@ -204,24 +204,17 @@ __metadata: "rescript-bun@patch:rescript-bun@npm%3A2.1.0#~/.yarn/patches/rescript-bun-npm-2.1.0-d9adc91a04.patch": version: 2.1.0 - resolution: "rescript-bun@patch:rescript-bun@npm%3A2.1.0#~/.yarn/patches/rescript-bun-npm-2.1.0-d9adc91a04.patch::version=2.1.0&hash=05b3ce" + resolution: "rescript-bun@patch:rescript-bun@npm%3A2.1.0#~/.yarn/patches/rescript-bun-npm-2.1.0-d9adc91a04.patch::version=2.1.0&hash=cc7d77" peerDependencies: rescript: ">= 12.0.0-alpha.4" - checksum: 10c0/bbc6b65d58a6bbfa556d915d2a43a76e8abbf2cae6d90ce8ffd1dad8d8d02f87b83936a8243393584667a6dd45ea8869150e4ef90b34ea63394fdc2e47ce3716 + checksum: 10c0/e58a68cc5cc0b3aef0198ad44ad80535f962c4a50d1085b9aaa2d8454fa4203907aa2b4e14939e909778b0c52ba6767175469ec51ddc5238d2674fe6d65f6a79 languageName: node linkType: hard -"rescript-nodejs@npm:16.1.0": - version: 16.1.0 - resolution: "rescript-nodejs@npm:16.1.0" - checksum: 10c0/2ea271dbddebdceec79bf5ee6089c15474f2c014cb22c1cc39d43ef27fd363fcb1cd8e1244d0cb998cd6b426d7474e3055e41277951fb01ee1eeecf68bbe01ab - languageName: node - linkType: hard - -"rescript-nodejs@patch:rescript-nodejs@npm%3A16.1.0#~/.yarn/patches/rescript-nodejs-npm-16.1.0-1841fa6174.patch": - version: 16.1.0 - resolution: "rescript-nodejs@patch:rescript-nodejs@npm%3A16.1.0#~/.yarn/patches/rescript-nodejs-npm-16.1.0-1841fa6174.patch::version=16.1.0&hash=8a6725" - checksum: 10c0/5ac79b6ff832413bc448fc139c139e0703e1f41f6eb3c0d58937630794e18081185f93c69781503530d635a4d6721c94064d54c49ecfaa67c9150ca1b0d27752 +"rescript-nodejs@npm:17.0.0": + version: 17.0.0 + resolution: "rescript-nodejs@npm:17.0.0" + checksum: 10c0/2c35fb20a208e4e62b462b588253457a66841201ecddb703ab4cdfb1119d4d496ee8663c6224114bcb5216cdbff8f33832f3fd22fa47c058a164db97a7b8a007 languageName: node linkType: hard @@ -285,24 +278,24 @@ __metadata: languageName: node linkType: hard -"sury-ppx@npm:^11.0.0-alpha.2": - version: 11.0.0-alpha.2 - resolution: "sury-ppx@npm:11.0.0-alpha.2" +"sury-ppx@npm:11.0.0-rc.0": + version: 11.0.0-rc.0 + resolution: "sury-ppx@npm:11.0.0-rc.0" peerDependencies: - sury: ^11.0.0-alpha.2 - checksum: 10c0/ae9190fa4e406de46e88b67db233e757db36f5377301227cf5b084b5b81d360725d6fc4781e24c56cb87476cd3a42af5acc0cfc49f0c7ea17435caf065ba22ab + sury: ^11.0.0-rc.0 + checksum: 10c0/18111b21004481103501171b913433531804071de161e6fd51083a4bae3988648d5d52a88ccba77f2f7429c60375cfc5fd7797476867e52b71cdb983bcec603e languageName: node linkType: hard -"sury@npm:^11.0.0-alpha.2": - version: 11.0.0-alpha.2 - resolution: "sury@npm:11.0.0-alpha.2" +"sury@npm:11.0.0-rc.0": + version: 11.0.0-rc.0 + resolution: "sury@npm:11.0.0-rc.0" peerDependencies: - rescript: 11.x + rescript: 12.x peerDependenciesMeta: rescript: optional: true - checksum: 10c0/254dd708608b125defc6b4be0f038df0f6704290df60504b70b7cd613f1e840d150ff65a3f23dbc7213f2b18b86fdc60400b4361ca46f5c86bbe7360eff9c84a + checksum: 10c0/0fa5cb3404f436205fcf87fb0b0003f64c1e4e90fab78cf029e276ed7ea76aa1683ac9e740cabbf9e95de33adf287a7706ce8d4c2552c045a0f7c2b5bcc95a5d languageName: node linkType: hard diff --git a/rewatch/tests/format/01-format-all-files.sh b/rewatch/tests/format/01-format-all-files.sh index ece245beab3..1b1ece46b6b 100755 --- a/rewatch/tests/format/01-format-all-files.sh +++ b/rewatch/tests/format/01-format-all-files.sh @@ -8,13 +8,13 @@ bold "Test: It should format all files" git diff --name-only ./ error_output=$("$REWATCH_EXECUTABLE" format) git_diff_file_count=$(git diff --name-only ./ | wc -l | xargs) -if [ $? -eq 0 ] && [ $git_diff_file_count -eq 9 ]; +if [ $? -eq 0 ] && [ $git_diff_file_count -eq 8 ]; then success "Test package formatted. Got $git_diff_file_count changed files." git restore . else error "Error formatting test package" - echo "Expected 9 files to be changed, got $git_diff_file_count" + echo "Expected 8 files to be changed, got $git_diff_file_count" echo $error_output exit 1 fi diff --git a/rewatch/tests/snapshots/clean-rebuild.txt b/rewatch/tests/snapshots/clean-rebuild.txt index 5d6736b3b05..078429af4f3 100644 --- a/rewatch/tests/snapshots/clean-rebuild.txt +++ b/rewatch/tests/snapshots/clean-rebuild.txt @@ -1,6 +1,6 @@ Cleaned 0/0 -Parsed 430 source files -Compiled 430 modules +Parsed 429 source files +Compiled 429 modules Warning number 32 /packages/watch-warnings/src/ModuleA.res:1:5-15 @@ -21,13 +21,3 @@ Package '@testrepo/deprecated-config' uses deprecated config (support will be re The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-config' is not supported by ReScript 12's new build system. Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. - -Package 'rescript-nodejs' uses deprecated config (support will be removed in a future version): - - field 'bs-dependencies' — use 'dependencies' instead - - field 'bs-dev-dependencies' — use 'dev-dependencies' instead - - filename 'bsconfig.json' — rename to 'rescript.json' -Please report this to the package maintainer: https://github.com/TheSpyder/rescript-nodejs/issues - -Package 'sury' uses deprecated config (support will be removed in a future version): - - field 'bs-dev-dependencies' — use 'dev-dependencies' instead -Please report this to the package maintainer: https://github.com/DZakh/sury/issues diff --git a/rewatch/tests/snapshots/dependency-cycle.txt b/rewatch/tests/snapshots/dependency-cycle.txt index eca324b9ed8..de1c236b403 100644 --- a/rewatch/tests/snapshots/dependency-cycle.txt +++ b/rewatch/tests/snapshots/dependency-cycle.txt @@ -1,4 +1,4 @@ -Cleaned 0/432 +Cleaned 0/429 Parsed 2 source files Compiled 1 modules @@ -22,16 +22,6 @@ The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-co Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. -Package 'rescript-nodejs' uses deprecated config (support will be removed in a future version): - - field 'bs-dependencies' — use 'dependencies' instead - - field 'bs-dev-dependencies' — use 'dev-dependencies' instead - - filename 'bsconfig.json' — rename to 'rescript.json' -Please report this to the package maintainer: https://github.com/TheSpyder/rescript-nodejs/issues - -Package 'sury' uses deprecated config (support will be removed in a future version): - - field 'bs-dev-dependencies' — use 'dev-dependencies' instead -Please report this to the package maintainer: https://github.com/DZakh/sury/issues - Can't continue... Found a circular dependency in your code: Dep01 (packages/dep01/src/Dep01.res) → Dep02 (packages/dep02/src/Dep02.res) diff --git a/rewatch/tests/snapshots/dev-dependency-used-by-non-dev-source.txt b/rewatch/tests/snapshots/dev-dependency-used-by-non-dev-source.txt index 3f5bf7f5404..142123ab1b9 100644 --- a/rewatch/tests/snapshots/dev-dependency-used-by-non-dev-source.txt +++ b/rewatch/tests/snapshots/dev-dependency-used-by-non-dev-source.txt @@ -1,4 +1,4 @@ -Cleaned 0/432 +Cleaned 0/429 Parsed 2 source files Compiled 2 modules @@ -22,16 +22,6 @@ The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-co Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. -Package 'rescript-nodejs' uses deprecated config (support will be removed in a future version): - - field 'bs-dependencies' — use 'dependencies' instead - - field 'bs-dev-dependencies' — use 'dev-dependencies' instead - - filename 'bsconfig.json' — rename to 'rescript.json' -Please report this to the package maintainer: https://github.com/TheSpyder/rescript-nodejs/issues - -Package 'sury' uses deprecated config (support will be removed in a future version): - - field 'bs-dev-dependencies' — use 'dev-dependencies' instead -Please report this to the package maintainer: https://github.com/DZakh/sury/issues - We've found a bug for you! /packages/with-dev-deps/src/FileToTest.res:2:6-11 diff --git a/rewatch/tests/snapshots/remove-file.txt b/rewatch/tests/snapshots/remove-file.txt index ff4d3970ac4..4c622363304 100644 --- a/rewatch/tests/snapshots/remove-file.txt +++ b/rewatch/tests/snapshots/remove-file.txt @@ -1,4 +1,4 @@ -Cleaned 1/432 +Cleaned 1/429 Parsed 1 source files Compiled 2 modules @@ -22,16 +22,6 @@ The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-co Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. -Package 'rescript-nodejs' uses deprecated config (support will be removed in a future version): - - field 'bs-dependencies' — use 'dependencies' instead - - field 'bs-dev-dependencies' — use 'dev-dependencies' instead - - filename 'bsconfig.json' — rename to 'rescript.json' -Please report this to the package maintainer: https://github.com/TheSpyder/rescript-nodejs/issues - -Package 'sury' uses deprecated config (support will be removed in a future version): - - field 'bs-dev-dependencies' — use 'dev-dependencies' instead -Please report this to the package maintainer: https://github.com/DZakh/sury/issues - We've found a bug for you! /packages/dep01/src/Dep01.res:3:9-17 diff --git a/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt b/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt index 6e0311b7589..e3f50855e36 100644 --- a/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt +++ b/rewatch/tests/snapshots/rename-file-internal-dep-namespace.txt @@ -1,4 +1,4 @@ -Cleaned 1/432 +Cleaned 1/429 Parsed 2 source files Compiled 3 modules @@ -22,16 +22,6 @@ The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-co Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. -Package 'rescript-nodejs' uses deprecated config (support will be removed in a future version): - - field 'bs-dependencies' — use 'dependencies' instead - - field 'bs-dev-dependencies' — use 'dev-dependencies' instead - - filename 'bsconfig.json' — rename to 'rescript.json' -Please report this to the package maintainer: https://github.com/TheSpyder/rescript-nodejs/issues - -Package 'sury' uses deprecated config (support will be removed in a future version): - - field 'bs-dev-dependencies' — use 'dev-dependencies' instead -Please report this to the package maintainer: https://github.com/DZakh/sury/issues - We've found a bug for you! /packages/new-namespace/src/NS_alias.res:2:1-16 diff --git a/rewatch/tests/snapshots/rename-file-internal-dep.txt b/rewatch/tests/snapshots/rename-file-internal-dep.txt index 68215bf2153..da66be5aafa 100644 --- a/rewatch/tests/snapshots/rename-file-internal-dep.txt +++ b/rewatch/tests/snapshots/rename-file-internal-dep.txt @@ -1,4 +1,4 @@ -Cleaned 1/432 +Cleaned 1/429 Parsed 2 source files Compiled 3 modules @@ -22,16 +22,6 @@ The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-co Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. -Package 'rescript-nodejs' uses deprecated config (support will be removed in a future version): - - field 'bs-dependencies' — use 'dependencies' instead - - field 'bs-dev-dependencies' — use 'dev-dependencies' instead - - filename 'bsconfig.json' — rename to 'rescript.json' -Please report this to the package maintainer: https://github.com/TheSpyder/rescript-nodejs/issues - -Package 'sury' uses deprecated config (support will be removed in a future version): - - field 'bs-dev-dependencies' — use 'dev-dependencies' instead -Please report this to the package maintainer: https://github.com/DZakh/sury/issues - We've found a bug for you! /packages/main/src/Main.res:4:13-29 diff --git a/rewatch/tests/snapshots/rename-file-with-interface.txt b/rewatch/tests/snapshots/rename-file-with-interface.txt index f26462d8151..18f72c6c17a 100644 --- a/rewatch/tests/snapshots/rename-file-with-interface.txt +++ b/rewatch/tests/snapshots/rename-file-with-interface.txt @@ -1,5 +1,5 @@  No implementation file found for interface file (skipping): src/ModuleWithInterface.resi -Cleaned 2/432 +Cleaned 2/429 Parsed 2 source files Compiled 2 modules @@ -22,13 +22,3 @@ Package '@testrepo/deprecated-config' uses deprecated config (support will be re The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-config' is not supported by ReScript 12's new build system. Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. - -Package 'rescript-nodejs' uses deprecated config (support will be removed in a future version): - - field 'bs-dependencies' — use 'dependencies' instead - - field 'bs-dev-dependencies' — use 'dev-dependencies' instead - - filename 'bsconfig.json' — rename to 'rescript.json' -Please report this to the package maintainer: https://github.com/TheSpyder/rescript-nodejs/issues - -Package 'sury' uses deprecated config (support will be removed in a future version): - - field 'bs-dev-dependencies' — use 'dev-dependencies' instead -Please report this to the package maintainer: https://github.com/DZakh/sury/issues diff --git a/rewatch/tests/snapshots/rename-file.txt b/rewatch/tests/snapshots/rename-file.txt index 347bc002df3..24664e6638b 100644 --- a/rewatch/tests/snapshots/rename-file.txt +++ b/rewatch/tests/snapshots/rename-file.txt @@ -1,4 +1,4 @@ -Cleaned 1/432 +Cleaned 1/429 Parsed 2 source files Compiled 2 modules @@ -21,13 +21,3 @@ Package '@testrepo/deprecated-config' uses deprecated config (support will be re The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-config' is not supported by ReScript 12's new build system. Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. - -Package 'rescript-nodejs' uses deprecated config (support will be removed in a future version): - - field 'bs-dependencies' — use 'dependencies' instead - - field 'bs-dev-dependencies' — use 'dev-dependencies' instead - - filename 'bsconfig.json' — rename to 'rescript.json' -Please report this to the package maintainer: https://github.com/TheSpyder/rescript-nodejs/issues - -Package 'sury' uses deprecated config (support will be removed in a future version): - - field 'bs-dev-dependencies' — use 'dev-dependencies' instead -Please report this to the package maintainer: https://github.com/DZakh/sury/issues diff --git a/rewatch/tests/snapshots/rename-interface-file.txt b/rewatch/tests/snapshots/rename-interface-file.txt index b7c694c4c33..d818b4f72f5 100644 --- a/rewatch/tests/snapshots/rename-interface-file.txt +++ b/rewatch/tests/snapshots/rename-interface-file.txt @@ -1,5 +1,5 @@  No implementation file found for interface file (skipping): src/ModuleWithInterface2.resi -Cleaned 1/432 +Cleaned 1/429 Parsed 2 source files Compiled 2 modules @@ -22,13 +22,3 @@ Package '@testrepo/deprecated-config' uses deprecated config (support will be re The field 'ignored-dirs' found in the package config of '@testrepo/deprecated-config' is not supported by ReScript 12's new build system. Unknown field 'some-new-field' found in the package config of '@testrepo/deprecated-config'. This option will be ignored. - -Package 'rescript-nodejs' uses deprecated config (support will be removed in a future version): - - field 'bs-dependencies' — use 'dependencies' instead - - field 'bs-dev-dependencies' — use 'dev-dependencies' instead - - filename 'bsconfig.json' — rename to 'rescript.json' -Please report this to the package maintainer: https://github.com/TheSpyder/rescript-nodejs/issues - -Package 'sury' uses deprecated config (support will be removed in a future version): - - field 'bs-dev-dependencies' — use 'dev-dependencies' instead -Please report this to the package maintainer: https://github.com/DZakh/sury/issues diff --git a/rewatch/tests/suite.sh b/rewatch/tests/suite.sh index 70b2fd54403..7c7eb518be4 100755 --- a/rewatch/tests/suite.sh +++ b/rewatch/tests/suite.sh @@ -62,6 +62,53 @@ else exit 1 fi +# sury-ppx 11.0.0-rc.0 only ships an arm64 binary for macOS. Temporarily +# disable the PPX fixture on Intel Macs until the package ships an x64 binary. +if [[ "$(uname -s)" == "Darwin" && "$(uname -m)" == "x86_64" ]]; then + PPX_CONFIG=../testrepo/packages/with-ppx/rescript.json + PPX_SOURCE=../testrepo/packages/with-ppx/src/FileWithPpx.res + PPX_OUTPUT=../testrepo/packages/with-ppx/src/FileWithPpx.mjs + PPX_BACKUP_DIR=$(mktemp -d) + PPX_FIXTURE_SHELL_PID=$BASHPID + + cp "$PPX_CONFIG" "$PPX_BACKUP_DIR/rescript.json" + cp "$PPX_SOURCE" "$PPX_BACKUP_DIR/FileWithPpx.res" + cp "$PPX_OUTPUT" "$PPX_BACKUP_DIR/FileWithPpx.mjs" + cp "$(git rev-parse --git-path index)" "$PPX_BACKUP_DIR/index" + export GIT_INDEX_FILE="$PPX_BACKUP_DIR/index" + + restore_ppx_fixture() { + if [ "$BASHPID" != "$PPX_FIXTURE_SHELL_PID" ]; then + return + fi + cp "$PPX_BACKUP_DIR/rescript.json" "$PPX_CONFIG" + cp "$PPX_BACKUP_DIR/FileWithPpx.res" "$PPX_SOURCE" + cp "$PPX_BACKUP_DIR/FileWithPpx.mjs" "$PPX_OUTPUT" + unset GIT_INDEX_FILE + rm -rf "$PPX_BACKUP_DIR" + } + trap restore_ppx_fixture EXIT + + bold "Disable sury-ppx fixture on Intel macOS" + node -e ' + const fs = require("fs"); + const path = process.argv[1]; + const config = JSON.parse(fs.readFileSync(path, "utf8")); + delete config["ppx-flags"]; + fs.writeFileSync(path, `${JSON.stringify(config, null, 2)}\n`); + ' "$PPX_CONFIG" + printf "\n" > "$PPX_SOURCE" + + if ! error_output=$(cd ../testrepo && "$REWATCH_EXECUTABLE" clean 2>&1 && "$REWATCH_EXECUTABLE" build 2>&1); then + error "Error preparing testrepo without sury-ppx" + printf "%s\n" "$error_output" >&2 + exit 1 + fi + + git add "$PPX_CONFIG" "$PPX_SOURCE" "$PPX_OUTPUT" + success "sury-ppx fixture disabled" +fi + # Individual test files # Comment out any test to skip it diff --git a/rewatch/tests/watch/01-watch-recompile.sh b/rewatch/tests/watch/01-watch-recompile.sh index 1d668e1d78d..626df386161 100755 --- a/rewatch/tests/watch/01-watch-recompile.sh +++ b/rewatch/tests/watch/01-watch-recompile.sh @@ -20,7 +20,7 @@ rewatch_bg watch > rewatch.log 2>&1 & success "Watcher Started" # Trigger a recompilation -echo 'Js.log("added-by-test")' >> ./packages/main/src/Main.res +echo 'Console.log("added-by-test")' >> ./packages/main/src/Main.res # Wait for the compiled JS to show up (can be slow in CI) target=./packages/main/src/Main.mjs @@ -43,7 +43,7 @@ fi sleep 1 -replace '/Js.log("added-by-test")/d' ./packages/main/src/Main.res; +replace '/Console.log("added-by-test")/d' ./packages/main/src/Main.res; sleep 5 diff --git a/rewatch/tests/watch/03-watch-new-file.sh b/rewatch/tests/watch/03-watch-new-file.sh index a7215725e28..1d4cfa19ea5 100755 --- a/rewatch/tests/watch/03-watch-new-file.sh +++ b/rewatch/tests/watch/03-watch-new-file.sh @@ -33,7 +33,7 @@ sleep 1 # Create a new file in the source directory cat > ./src/NewWatchTestFile.res << 'EOF' let greeting = "hello from new file" -let () = Js.log(greeting) +let () = Console.log(greeting) EOF # Wait for the new file to be compiled diff --git a/scripts/res/GenApiDocs.res b/scripts/res/GenApiDocs.res index f47f12723cd..49d8323a91e 100644 --- a/scripts/res/GenApiDocs.res +++ b/scripts/res/GenApiDocs.res @@ -23,9 +23,9 @@ if !Fs.existsSync(dirVersion) { } -let entryPointFiles = ["Belt.res", "Dom.res", "Js.res", "Stdlib.res"] +let entryPointFiles = ["Belt.res", "Dom.res", "Stdlib.res"] -let hiddenModules = ["Js.Internal", "Js.MapperRt"] +let hiddenModules = [] type module_ = { id: string, diff --git a/scripts/test_syntax.sh b/scripts/test_syntax.sh index d6e11166b54..2d873c42e2e 100755 --- a/scripts/test_syntax.sh +++ b/scripts/test_syntax.sh @@ -23,6 +23,12 @@ function maybeWait { pushd tests +legacyJsReferences=$(find syntax_tests/data syntax_benchmarks/data \( -name "*.res" -o -name "*.resi" \) -exec grep -nHE '(^|[^[:alnum:]_])Js\.' {} + || true) +if [[ $legacyJsReferences != "" ]]; then + printf "Legacy Js. references remain in syntax fixtures:\n%s\n" "$legacyJsReferences" + exit 1 +fi + rm -rf temp mkdir temp @@ -65,7 +71,7 @@ diff=$(cat temp/diff.txt) if [[ $diff = "" ]]; then printf "${successGreen}✅ No unstaged tests difference.${reset}\n" else - printf "${warningYellow}âš ï¸ There are unstaged differences in syntax_tests/data/! Did you break a test?\n${diff}\n${reset}" + printf "${warningYellow}âš ï¸ There are unstaged differences in syntax_tests/data/! Did you break a test?\n%s\n${reset}" "$diff" rm -r temp/ exit 1 fi diff --git a/tests/analysis_tests/tests-incremental-typechecking/src/ConstructorCompletion__Json.res b/tests/analysis_tests/tests-incremental-typechecking/src/ConstructorCompletion__Json.res index 5173fefec00..c8ffb986bb9 100644 --- a/tests/analysis_tests/tests-incremental-typechecking/src/ConstructorCompletion__Json.res +++ b/tests/analysis_tests/tests-incremental-typechecking/src/ConstructorCompletion__Json.res @@ -1,2 +1,2 @@ -let x = Js.Json.Array() -// ^com +let x = JSON.Array() +// ^com diff --git a/tests/analysis_tests/tests-incremental-typechecking/src/expected/ConstructorCompletion__Json.res.txt b/tests/analysis_tests/tests-incremental-typechecking/src/expected/ConstructorCompletion__Json.res.txt index a5c176baecd..ff11904f0d4 100644 --- a/tests/analysis_tests/tests-incremental-typechecking/src/expected/ConstructorCompletion__Json.res.txt +++ b/tests/analysis_tests/tests-incremental-typechecking/src/expected/ConstructorCompletion__Json.res.txt @@ -1,8 +1,7 @@ -Complete src/ConstructorCompletion__Json.res 0:22 -posCursor:[0:22] posNoWhite:[0:21] Found expr:[0:8->0:23] -Pexp_construct Js -Json -Array:[0:8->0:21] [0:21->0:23] +Complete src/ConstructorCompletion__Json.res 0:19 +posCursor:[0:19] posNoWhite:[0:18] Found expr:[0:8->0:20] +Pexp_construct JSON +Array:[0:8->0:18] [0:18->0:20] Completable: Cexpression CTypeAtPos()->variantPayload::Array($0) Package opens Stdlib.place holder Pervasives.JsxModules.place holder Resolved opens 1 Stdlib diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt b/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt index 10c70d7cd19..dafbaffeb6f 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt +++ b/tests/analysis_tests/tests-reanalyze/deadcode/expected/deadcode.txt @@ -56,7 +56,7 @@ addTypeReference DeadExn.res:8:16 --> DeadExn.res:1:0 addValueReference DeadExn.res:10:4 --> DeadExn.res:4:2 addTypeReference DeadExn.res:10:14 --> DeadExn.res:4:2 - addValueReference DeadExn.res:12:7 --> DeadExn.res:10:4 + addValueReference DeadExn.res:12:12 --> DeadExn.res:10:4 Scanning DeadExn.cmti Source:DeadExn.resi Scanning DeadRT.cmt Source:DeadRT.res addValueDeclaration +emitModuleAccessPath DeadRT.res:5:8 path:+DeadRT @@ -64,7 +64,7 @@ addVariantCaseDeclaration Kaboom DeadRT.res:3:2 path:+DeadRT.moduleAccessPath addValueReference DeadRT.res:5:8 --> DeadRT.res:7:9 addValueReference DeadRT.res:5:8 --> DeadRT.res:5:31 - addTypeReference DeadRT.res:11:16 --> DeadRT.res:3:2 + addTypeReference DeadRT.res:11:21 --> DeadRT.res:3:2 Scanning DeadRT.cmti Source:DeadRT.resi addVariantCaseDeclaration Root DeadRT.resi:2:2 path:DeadRT.moduleAccessPath addVariantCaseDeclaration Kaboom DeadRT.resi:3:2 path:DeadRT.moduleAccessPath @@ -102,7 +102,7 @@ addValueDeclaration +funWithInnerVars DeadTest.res:151:4 path:+DeadTest addValueDeclaration +deadIncorrect DeadTest.res:160:4 path:+DeadTest addValueDeclaration +ira DeadTest.res:166:4 path:+DeadTest - addValueReference DeadTest.res:1:15 --> ImmutableArray.resi:9:0 + addValueReference DeadTest.res:1:20 --> ImmutableArray.resi:9:0 addValueReference DeadTest.res:8:7 --> DeadTest.res:7:4 addValueReference DeadTest.res:11:7 --> DeadTest.res:10:4 addValueReference DeadTest.res:12:7 --> DeadTest.res:10:4 @@ -131,8 +131,8 @@ addValueDeclaration +x DeadTest.res:64:6 path:+DeadTest.MM addValueReference DeadTest.res:64:6 --> DeadTest.res:63:6 addValueDeclaration +valueOnlyInImplementation DeadTest.res:65:6 path:+DeadTest.MM - addValueReference DeadTest.res:69:9 --> DeadTest.res:60:2 - addValueReference DeadTest.res:73:16 --> DeadValueTest.resi:1:0 + addValueReference DeadTest.res:69:14 --> DeadTest.res:60:2 + addValueReference DeadTest.res:73:21 --> DeadValueTest.resi:1:0 addValueReference DeadTest.res:75:8 --> DeadTest.res:75:8 addValueReference DeadTest.res:77:8 --> DeadTest.res:77:20 addValueReference DeadTest.res:77:8 --> DeadTest.res:77:8 @@ -148,21 +148,21 @@ addValueReference DeadTest.res:96:4 --> DeadTest.res:96:42 addValueReference DeadTest.res:96:4 --> DeadTest.res:96:24 addValueReference DeadTest.res:96:4 --> DeadTest.res:96:45 - addTypeReference DeadTest.res:98:16 --> DeadRT.resi:2:2 + addTypeReference DeadTest.res:98:21 --> DeadRT.resi:2:2 addValueDeclaration +a1 DeadTest.res:105:6 path:+DeadTest addValueDeclaration +a2 DeadTest.res:106:6 path:+DeadTest addValueDeclaration +a3 DeadTest.res:107:6 path:+DeadTest - addValueReference DeadTest.res:110:17 --> DynamicallyLoadedComponent.res:2:4 + addValueReference DeadTest.res:110:22 --> DynamicallyLoadedComponent.res:2:4 addRecordLabelDeclaration s DeadTest.res:117:12 path:+DeadTest.props addValueReference DeadTest.res:117:32 --> DeadTest.res:117:12 addValueReference DeadTest.res:117:19 --> React.res:7:0 addTypeReference _none_:1:-1 --> DeadTest.res:117:12 addValueReference DeadTest.res:117:4 --> React.res:16:0 - addValueReference DeadTest.res:119:16 --> DeadTest.res:117:4 + addValueReference DeadTest.res:119:21 --> DeadTest.res:117:4 addVariantCaseDeclaration A DeadTest.res:140:11 path:+DeadTest.WithInclude.t addVariantCaseDeclaration A DeadTest.res:143:13 path:+DeadTest.WithInclude.T.t addVariantCaseDeclaration A DeadTest.res:143:13 path:+DeadTest.WithInclude.t - addTypeReference DeadTest.res:148:7 --> DeadTest.res:140:11 + addTypeReference DeadTest.res:148:12 --> DeadTest.res:140:11 addValueDeclaration +x DeadTest.res:152:6 path:+DeadTest addValueDeclaration +y DeadTest.res:153:6 path:+DeadTest addValueReference DeadTest.res:151:4 --> DeadTest.res:152:6 @@ -992,7 +992,7 @@ addValueDeclaration +ddjdj ModuleExceptionBug.res:7:4 path:+ModuleExceptionBug addValueReference ModuleExceptionBug.res:2:6 --> ModuleExceptionBug.res:2:21 addExceptionDeclaration MyOtherException ModuleExceptionBug.res:5:0 path:+ModuleExceptionBug - addValueReference ModuleExceptionBug.res:8:7 --> ModuleExceptionBug.res:7:4 + addValueReference ModuleExceptionBug.res:8:12 --> ModuleExceptionBug.res:7:4 Scanning NestedModules.cmt Source:NestedModules.res addValueDeclaration +notNested NestedModules.res:2:4 path:+NestedModules addValueDeclaration +theAnswer NestedModules.res:6:6 path:+NestedModules.Universe @@ -1094,9 +1094,9 @@ addValueReference Newton.res:29:4 --> Newton.res:25:4 addValueReference Newton.res:29:4 --> Newton.res:27:4 addValueReference Newton.res:29:4 --> Newton.res:6:4 - addValueReference Newton.res:31:8 --> Newton.res:29:4 - addValueReference Newton.res:31:18 --> Newton.res:29:4 - addValueReference Newton.res:31:16 --> Newton.res:25:4 + addValueReference Newton.res:31:13 --> Newton.res:29:4 + addValueReference Newton.res:31:23 --> Newton.res:29:4 + addValueReference Newton.res:31:21 --> Newton.res:25:4 Scanning OcamlWarningSuppressToplevel.cmt Source:OcamlWarningSuppressToplevel.res addValueDeclaration +suppressed1 OcamlWarningSuppressToplevel.res:3:4 path:+OcamlWarningSuppressToplevel addValueDeclaration +suppressed2 OcamlWarningSuppressToplevel.res:4:4 path:+OcamlWarningSuppressToplevel @@ -1126,10 +1126,10 @@ addValueReference OptArg.res:1:4 --> OptArg.res:1:29 addValueReference OptArg.res:3:4 --> OptArg.res:3:17 addValueReference OptArg.res:3:4 --> OptArg.res:3:27 - DeadOptionalArgs.addReferences foo called with optional argNames:x argNamesMaybe: OptArg.res:5:7 - addValueReference OptArg.res:5:7 --> OptArg.res:1:4 - DeadOptionalArgs.addReferences bar called with optional argNames: argNamesMaybe: OptArg.res:7:7 - addValueReference OptArg.res:7:7 --> OptArg.res:3:4 + DeadOptionalArgs.addReferences foo called with optional argNames:x argNamesMaybe: OptArg.res:5:12 + addValueReference OptArg.res:5:12 --> OptArg.res:1:4 + DeadOptionalArgs.addReferences bar called with optional argNames: argNamesMaybe: OptArg.res:7:12 + addValueReference OptArg.res:7:12 --> OptArg.res:3:4 addValueReference OptArg.res:9:4 --> OptArg.res:9:20 addValueReference OptArg.res:9:4 --> OptArg.res:9:26 addValueReference OptArg.res:9:4 --> OptArg.res:9:32 @@ -1137,17 +1137,17 @@ addValueReference OptArg.res:9:4 --> OptArg.res:9:23 addValueReference OptArg.res:9:4 --> OptArg.res:9:29 addValueReference OptArg.res:9:4 --> OptArg.res:9:35 - DeadOptionalArgs.addReferences threeArgs called with optional argNames:c, a argNamesMaybe: OptArg.res:11:7 - addValueReference OptArg.res:11:7 --> OptArg.res:9:4 - DeadOptionalArgs.addReferences threeArgs called with optional argNames:a argNamesMaybe: OptArg.res:12:7 - addValueReference OptArg.res:12:7 --> OptArg.res:9:4 + DeadOptionalArgs.addReferences threeArgs called with optional argNames:c, a argNamesMaybe: OptArg.res:11:12 + addValueReference OptArg.res:11:12 --> OptArg.res:9:4 + DeadOptionalArgs.addReferences threeArgs called with optional argNames:a argNamesMaybe: OptArg.res:12:12 + addValueReference OptArg.res:12:12 --> OptArg.res:9:4 addValueReference OptArg.res:14:4 --> OptArg.res:14:18 addValueReference OptArg.res:14:4 --> OptArg.res:14:24 addValueReference OptArg.res:14:4 --> OptArg.res:14:15 addValueReference OptArg.res:14:4 --> OptArg.res:14:21 addValueReference OptArg.res:14:4 --> OptArg.res:14:27 - DeadOptionalArgs.addReferences twoArgs called with optional argNames: argNamesMaybe: OptArg.res:16:7 - addValueReference OptArg.res:16:10 --> OptArg.res:14:4 + DeadOptionalArgs.addReferences twoArgs called with optional argNames: argNamesMaybe: OptArg.res:16:12 + addValueReference OptArg.res:16:15 --> OptArg.res:14:4 addValueReference OptArg.res:18:4 --> OptArg.res:18:17 addValueReference OptArg.res:18:4 --> OptArg.res:18:14 addValueReference OptArg.res:18:4 --> OptArg.res:18:24 @@ -1155,8 +1155,8 @@ addValueReference OptArg.res:20:4 --> OptArg.res:20:18 addValueReference OptArg.res:20:4 --> OptArg.res:20:24 addValueReference OptArg.res:20:4 --> OptArg.res:18:4 - DeadOptionalArgs.addReferences wrapOneArg called with optional argNames:a argNamesMaybe: OptArg.res:22:7 - addValueReference OptArg.res:22:7 --> OptArg.res:20:4 + DeadOptionalArgs.addReferences wrapOneArg called with optional argNames:a argNamesMaybe: OptArg.res:22:12 + addValueReference OptArg.res:22:12 --> OptArg.res:20:4 addValueReference OptArg.res:24:4 --> OptArg.res:24:19 addValueReference OptArg.res:24:4 --> OptArg.res:24:25 addValueReference OptArg.res:24:4 --> OptArg.res:24:31 @@ -1172,10 +1172,10 @@ addValueReference OptArg.res:26:4 --> OptArg.res:26:32 addValueReference OptArg.res:26:4 --> OptArg.res:26:38 addValueReference OptArg.res:26:4 --> OptArg.res:24:4 - DeadOptionalArgs.addReferences wrapfourArgs called with optional argNames:c, a argNamesMaybe: OptArg.res:28:7 - addValueReference OptArg.res:28:7 --> OptArg.res:26:4 - DeadOptionalArgs.addReferences wrapfourArgs called with optional argNames:c, b argNamesMaybe: OptArg.res:29:7 - addValueReference OptArg.res:29:7 --> OptArg.res:26:4 + DeadOptionalArgs.addReferences wrapfourArgs called with optional argNames:c, a argNamesMaybe: OptArg.res:28:12 + addValueReference OptArg.res:28:12 --> OptArg.res:26:4 + DeadOptionalArgs.addReferences wrapfourArgs called with optional argNames:c, b argNamesMaybe: OptArg.res:29:12 + addValueReference OptArg.res:29:12 --> OptArg.res:26:4 addValueReference OptArg.resi:1:0 --> OptArg.res:1:4 OptionalArgs.addFunctionReference OptArg.resi:1:0 OptArg.res:1:4 addValueReference OptArg.resi:2:0 --> OptArg.res:3:4 @@ -1280,12 +1280,12 @@ addRecordLabelDeclaration address2 Records.res:92:2 path:+Records.business2 addTypeReference Records.res:97:2 --> Records.res:92:2 addValueReference Records.res:96:4 --> Records.res:96:20 - addValueReference Records.res:96:4 --> Records.res:97:58 + addValueReference Records.res:96:4 --> Records.res:97:55 addValueReference Records.res:96:4 --> Records.res:36:4 addValueReference Records.res:107:4 --> Records.res:107:20 addValueReference Records.res:107:4 --> Records.res:107:20 addValueReference Records.res:107:4 --> Records.res:107:20 - addValueReference Records.res:107:4 --> Records.res:108:75 + addValueReference Records.res:107:4 --> Records.res:108:72 addValueReference Records.res:111:4 --> Records.res:111:20 addValueReference Records.res:111:4 --> Records.res:111:20 addValueReference Records.res:111:4 --> Records.res:111:20 @@ -1342,7 +1342,7 @@ addValueReference RepeatedLabel.res:12:4 --> RepeatedLabel.res:12:20 addTypeReference RepeatedLabel.res:12:16 --> RepeatedLabel.res:7:2 addTypeReference RepeatedLabel.res:12:16 --> RepeatedLabel.res:8:2 - addValueReference RepeatedLabel.res:14:7 --> RepeatedLabel.res:12:4 + addValueReference RepeatedLabel.res:14:12 --> RepeatedLabel.res:12:4 Scanning RequireCond.cmt Source:RequireCond.res Scanning ScopedAnnotationsLiveVsDead.cmt Source:ScopedAnnotationsLiveVsDead.res addValueDeclaration +leafLive ScopedAnnotationsLiveVsDead.res:1:4 path:+ScopedAnnotationsLiveVsDead @@ -1420,14 +1420,14 @@ addValueDeclaration +bar TestOptArg.res:5:4 path:+TestOptArg addValueDeclaration +notSuppressesOptArgs TestOptArg.res:9:4 path:+TestOptArg addValueDeclaration +liveSuppressesOptArgs TestOptArg.res:14:4 path:+TestOptArg - DeadOptionalArgs.addReferences OptArg.bar called with optional argNames:z argNamesMaybe: TestOptArg.res:1:7 - addValueReference TestOptArg.res:1:7 --> OptArg.resi:2:0 + DeadOptionalArgs.addReferences OptArg.bar called with optional argNames:z argNamesMaybe: TestOptArg.res:1:12 + addValueReference TestOptArg.res:1:12 --> OptArg.resi:2:0 addValueReference TestOptArg.res:3:4 --> TestOptArg.res:3:14 addValueReference TestOptArg.res:3:4 --> TestOptArg.res:3:11 addValueReference TestOptArg.res:3:4 --> TestOptArg.res:3:17 DeadOptionalArgs.addReferences foo called with optional argNames:x argNamesMaybe: TestOptArg.res:5:16 addValueReference TestOptArg.res:5:4 --> TestOptArg.res:3:4 - addValueReference TestOptArg.res:7:7 --> TestOptArg.res:5:4 + addValueReference TestOptArg.res:7:12 --> TestOptArg.res:5:4 addValueReference TestOptArg.res:9:4 --> TestOptArg.res:9:31 addValueReference TestOptArg.res:9:4 --> TestOptArg.res:9:37 addValueReference TestOptArg.res:9:4 --> TestOptArg.res:9:43 @@ -1451,8 +1451,9 @@ addRecordLabelDeclaration x TestPromise.res:6:2 path:+TestPromise.fromPayload addRecordLabelDeclaration s TestPromise.res:7:2 path:+TestPromise.fromPayload addRecordLabelDeclaration result TestPromise.res:11:18 path:+TestPromise.toPayload - addValueReference TestPromise.res:14:4 --> TestPromise.res:14:33 - addTypeReference TestPromise.res:14:32 --> TestPromise.res:7:2 + addValueReference TestPromise.res:14:4 --> TestPromise.res:14:14 + addValueReference TestPromise.res:14:4 --> TestPromise.res:14:49 + addTypeReference TestPromise.res:14:48 --> TestPromise.res:7:2 Scanning ToSuppress.cmt Source:ToSuppress.res addValueDeclaration +toSuppress ToSuppress.res:1:4 path:+ToSuppress Scanning TransitiveType1.cmt Source:TransitiveType1.res @@ -1570,16 +1571,14 @@ addValueDeclaration +selfRecursiveConverter Types.res:42:4 path:+Types addValueDeclaration +mutuallyRecursiveConverter Types.res:49:4 path:+Types addValueDeclaration +testFunctionOnOptionsAsArgument Types.res:52:4 path:+Types - addValueDeclaration +jsStringT Types.res:60:4 path:+Types - addValueDeclaration +jsString2T Types.res:63:4 path:+Types - addValueDeclaration +jsonStringify Types.res:75:4 path:+Types - addValueDeclaration +testConvertNull Types.res:89:4 path:+Types - addValueDeclaration +testMarshalFields Types.res:109:4 path:+Types - addValueDeclaration +setMatch Types.res:125:4 path:+Types - addValueDeclaration +testInstantiateTypeParameter Types.res:135:4 path:+Types - addValueDeclaration +currentTime Types.res:144:4 path:+Types - addValueDeclaration +i64Const Types.res:153:4 path:+Types - addValueDeclaration +optFunction Types.res:156:4 path:+Types + addValueDeclaration +jsonStringify Types.res:69:4 path:+Types + addValueDeclaration +testConvertNull Types.res:83:4 path:+Types + addValueDeclaration +testMarshalFields Types.res:103:4 path:+Types + addValueDeclaration +setMatch Types.res:119:4 path:+Types + addValueDeclaration +testInstantiateTypeParameter Types.res:129:4 path:+Types + addValueDeclaration +currentTime Types.res:138:4 path:+Types + addValueDeclaration +i64Const Types.res:147:4 path:+Types + addValueDeclaration +optFunction Types.res:150:4 path:+Types addVariantCaseDeclaration A Types.res:12:2 path:+Types.typeWithVars addVariantCaseDeclaration B Types.res:13:2 path:+Types.typeWithVars addValueReference Types.res:23:8 --> Types.res:23:16 @@ -1599,14 +1598,14 @@ addValueReference Types.res:52:4 --> Types.res:52:54 addVariantCaseDeclaration A Types.res:56:2 path:+Types.opaqueVariant addVariantCaseDeclaration B Types.res:57:2 path:+Types.opaqueVariant - addRecordLabelDeclaration i Types.res:84:2 path:+Types.record - addRecordLabelDeclaration s Types.res:85:2 path:+Types.record - addValueReference Types.res:89:4 --> Types.res:89:23 - addValueReference Types.res:109:4 --> Types.res:109:39 - addValueReference Types.res:125:4 --> Types.res:125:16 - addRecordLabelDeclaration id Types.res:130:19 path:+Types.someRecord - addValueReference Types.res:135:4 --> Types.res:135:36 - addValueDeclaration +x Types.res:163:6 path:+Types.ObjectId + addRecordLabelDeclaration i Types.res:78:2 path:+Types.record + addRecordLabelDeclaration s Types.res:79:2 path:+Types.record + addValueReference Types.res:83:4 --> Types.res:83:23 + addValueReference Types.res:103:4 --> Types.res:103:39 + addValueReference Types.res:119:4 --> Types.res:119:16 + addRecordLabelDeclaration id Types.res:124:19 path:+Types.someRecord + addValueReference Types.res:129:4 --> Types.res:129:36 + addValueDeclaration +x Types.res:157:6 path:+Types.ObjectId Scanning Unboxed.cmt Source:Unboxed.res addValueDeclaration +testV1 Unboxed.res:8:4 path:+Unboxed addValueDeclaration +r2Test Unboxed.res:17:4 path:+Unboxed @@ -1770,18 +1769,18 @@ addRecordLabelDeclaration x VariantsWithPayload.res:2:2 path:+VariantsWithPayload.payload addRecordLabelDeclaration y VariantsWithPayload.res:3:2 path:+VariantsWithPayload.payload addValueReference VariantsWithPayload.res:16:4 --> VariantsWithPayload.res:16:23 - addTypeReference VariantsWithPayload.res:26:57 --> VariantsWithPayload.res:2:2 + addTypeReference VariantsWithPayload.res:26:62 --> VariantsWithPayload.res:2:2 addValueReference VariantsWithPayload.res:19:4 --> VariantsWithPayload.res:26:7 - addTypeReference VariantsWithPayload.res:26:74 --> VariantsWithPayload.res:3:2 + addTypeReference VariantsWithPayload.res:26:79 --> VariantsWithPayload.res:3:2 addValueReference VariantsWithPayload.res:19:4 --> VariantsWithPayload.res:26:7 addValueReference VariantsWithPayload.res:19:4 --> VariantsWithPayload.res:19:31 addValueReference VariantsWithPayload.res:37:4 --> VariantsWithPayload.res:37:24 addValueReference VariantsWithPayload.res:40:4 --> VariantsWithPayload.res:42:9 addValueReference VariantsWithPayload.res:40:4 --> VariantsWithPayload.res:43:9 addValueReference VariantsWithPayload.res:40:4 --> VariantsWithPayload.res:43:13 - addTypeReference VariantsWithPayload.res:44:55 --> VariantsWithPayload.res:2:2 + addTypeReference VariantsWithPayload.res:44:60 --> VariantsWithPayload.res:2:2 addValueReference VariantsWithPayload.res:40:4 --> VariantsWithPayload.res:44:11 - addTypeReference VariantsWithPayload.res:44:72 --> VariantsWithPayload.res:3:2 + addTypeReference VariantsWithPayload.res:44:77 --> VariantsWithPayload.res:3:2 addValueReference VariantsWithPayload.res:40:4 --> VariantsWithPayload.res:44:11 addValueReference VariantsWithPayload.res:40:4 --> VariantsWithPayload.res:40:25 addVariantCaseDeclaration A VariantsWithPayload.res:49:2 path:+VariantsWithPayload.simpleVariant @@ -1954,11 +1953,11 @@ addTypeReference TypeReexport.res:28:4 --> TypeReexport.res:33:4 extendTypeDependencies TypeReexport.res:28:4 --> TypeReexport.res:33:4 addTypeReference TypeReexport.res:33:4 --> TypeReexport.res:28:4 - addValueReference TestDeadExn.res:1:7 --> DeadExn.res:1:0 + addValueReference TestDeadExn.res:1:12 --> DeadExn.res:1:0 Forward Liveness Analysis - decls: 702 + decls: 700 roots(external targets): 137 decl-deps: decls_with_out=411 edges_to_decls=289 @@ -1966,48 +1965,47 @@ Forward Liveness Analysis Root (external ref): VariantCase DeadRT.moduleAccessPath.Root Root (external ref): Value +TypeReexport.VariantUseOriginal.+value Root (annotated): Value +NestedModules.Universe.Nested2.Nested3.+nested3Function + Root (annotated): Value +Records.+someBusiness2 + Root (annotated): Value +Types.+setMatch + Root (annotated): Value +Uncurried.+sumCurried Root (annotated): Value +ImportJsValue.+areaValue + Root (annotated): Value +Types.+testConvertNull Root (external ref): Value +CreateErrorHandler2.Error2.+notification - Root (annotated): Value +DeadTest.+fortyTwoButExported Root (annotated): Value +ScopedAnnotationsOverride.M.+live1 + Root (annotated): Value +VariantsWithPayload.+testSimpleVariant Root (annotated): Value +Docstrings.+twoU Root (external ref): RecordLabel +TypeReexportCrossFileB.reexportedRecord.usedField Root (annotated): Value +NestedModules.Universe.Nested2.+nested2Function - Root (annotated): Value +Tuples.+marry + Root (external ref): Value +OptArg.+wrapfourArgs Root (annotated): Value +Docstrings.+unitArgWithoutConversionU - Root (annotated): Value +Types.+i64Const Root (external ref): VariantCase +DeadTypeTest.deadType.OnlyInImplementation Root (annotated): Value +TestImport.+valueStartingWithUpperCaseLetter Root (external ref): Value +TypeReexport.VariantUseReexported.+value - Root (annotated): RecordLabel +DeadTest.inlineRecord.IR.e Root (external ref): Value +OptionalArgsLiveDead.+liveCaller + Root (annotated): Value +Types.+testInstantiateTypeParameter Root (annotated): RecordLabel +ImportHookDefault.props.renderMe Root (annotated): Value +TypeParams3.+test + Root (annotated): Value +Types.+optFunction Root (annotated): Value +Variants.+sunday Root (annotated): Value +NestedModules.Universe.Nested2.Nested3.+nested3Value Root (external ref): RecordLabel +Unison.t.doc Root (annotated): Value +Tuples.+computeAreaWithIdent Root (annotated): Value +LetPrivate.+y Root (annotated): Value +TestImport.+innerStuffContentsAsEmptyObject - Root (external ref): Value +TestOptArg.+notSuppressesOptArgs Root (annotated): Value +Types.+testFunctionOnOptionsAsArgument Root (annotated): Value +Docstrings.+two - Root (annotated): Value +Tuples.+getFirstName Root (annotated): Value +Uncurried.+uncurried3 Root (external ref): Value +Newton.+f Root (external ref): RecordLabel +Records.record.v - Root (external ref): VariantCase +DeadTest.VariantUsedOnlyInImplementation.t.A Root (external ref): RecordLabel +Records.person.address Root (annotated): Value +Variants.+testConvert2 Root (annotated): Value +Tuples.+coord2d Root (external ref): Value +CreateErrorHandler1.Error1.+notification - Root (annotated): Value +Uncurried.+sumU2 Root (annotated): Value +TransitiveType3.+convertT3 Root (annotated): Value +Variants.+swap Root (annotated): Value +Shadow.+test Root (annotated): Value +Uncurried.+uncurried1 Root (annotated): Value +Variants.+testConvert3 - Root (annotated): Value +DeadTest.+thisIsMarkedLive Root (annotated): Value +NestedModules.+notNested Root (annotated): Value +Records.+computeArea Root (external ref): RecordLabel +TypeReexport.UseOriginal.reexportedType.directlyUsed @@ -2018,41 +2016,45 @@ Forward Liveness Analysis Root (annotated): RecordLabel +ImportIndex.props.method Root (annotated): Value +Docstrings.+unnamed2U Root (external ref): RecordLabel +RecordRest.config.name + Root (annotated): Value +Records.+testMyRecBsAs Root (external ref): Value +FirstClassModules.M.Z.+u Root (annotated): Value +Uncurried.+callback2U Root (annotated): Value +ImportJsValue.+default - Root (annotated): Value +VariantsWithPayload.+testVariant1Int Root (external ref): Value +DynamicallyLoadedComponent.+make Root (annotated): Value +Hooks.RenderPropRequiresConversion.+make Root (annotated): Value +Uncurried.+uncurried2 Root (annotated): Value +UseImportJsValue.+useTypeImportedInOtherModule Root (annotated): Value +Hooks.Inner.+make + Root (external ref): RecordLabel +DeadTest.inlineRecord.IR.c Root (external ref): Value +OptArg.+foo Root (annotated): Value +Variants.+fortytwoOK + Root (annotated): Value +TestOptArg.+liveSuppressesOptArgs + Root (annotated): Value +Uncurried.+sumU2 Root (external ref): Value OptArg.+bar Root (annotated): Value +Records.+payloadValue - Root (external ref): RecordLabel +DeadTest.props.s Root (annotated): Value +Hooks.+default + Root (annotated): Value +Types.+currentTime + Root (annotated): Value +VariantsWithPayload.+testVariant1Object Root (external ref): VariantCase +Unison.break_.Never + Root (annotated): Value +Records.+computeArea3 Root (annotated): Value +TestEmitInnerModules.Inner.+y Root (external ref): VariantCase InnerModuleTypes.I.t.Foo Root (annotated): Value +Types.+selfRecursiveConverter - Root (external ref): Value +DeadTest.+thisIsUsedTwice Root (annotated): Value +Opaque.+testConvertNestedRecordFromOtherFile + Root (external ref): RecordLabel +DeadTest.inlineRecord.IR.b Root (external ref): Value +OptArg.+bar Root (annotated): Value +TestFirstClassModules.+convertRecord + Root (external ref): RecordLabel +TestPromise.fromPayload.s Root (external ref): VariantCase DeadTypeTest.deadType.OnlyInInterface - Root (external ref): RecordLabel +Records.myRecBsAs.type_ Root (annotated): Value +ImportJsValue.+higherOrder Root (annotated): Value +Variants.+restResult3 - Root (external ref): RecordLabel +Tuples.person.name Root (external ref): Value +FirstClassModules.M.InnerModule3.+k3 + Root (annotated): Value +DeadTest.+fortyTwoButExported + Root (external ref): VariantCase +DeadTest.VariantUsedOnlyInImplementation.t.A Root (external ref): RecordLabel +Records.coord.x Root (annotated): RecordLabel +DeadTypeTest.record.y Root (annotated): Value +TestImport.+defaultValue - Root (external ref): Value +OptArg.+threeArgs - Root (annotated): Value +Types.+setMatch - Root (external ref): Value +DeadTest.+deadIncorrect + Root (annotated): Value +DeadTest.GloobLive.+globallyLive2 Root (external ref): RecordLabel +TypeReexport.UseReexported.reexportedType.usedField Root (annotated): Value +Docstrings.+signMessage Root (external ref): RecordLabel +Hooks.Inner.Inner2.props.vehicle @@ -2064,25 +2066,25 @@ Forward Liveness Analysis Root (annotated): Value +TransitiveType1.+convert Root (annotated): Value +ImportHooks.+make Root (external ref): VariantCase +Unison.break_.IfNeed - Root (external ref): Value +DeadTest.+make - Root (annotated): Value +Records.+testMyRecBsAs - Root (external ref): RecordLabel +DeadTest.inlineRecord.IR.c + Root (external ref): VariantCase +DeadTest.WithInclude.t.A Root (annotated): Value +Records.+origin Root (annotated): Value +Variants.+onlySunday Root (annotated): Value +Docstrings.+treeU Root (annotated): Value +Docstrings.+unnamed1 Root (annotated): Value +TypeParams3.+test2 Root (annotated): Value +Tuples.+origin - Root (annotated): Value +Uncurried.+sumCurried Root (annotated): Value +Docstrings.+unitArgWithConversionU + Root (annotated): Value +Records.+computeArea4 Root (annotated): Value +Tuples.+computeArea Root (annotated): Value +References.+get Root (annotated): Value +ModuleAliases.+testNested + Root (external ref): Value +OptArg.+threeArgs + Root (annotated): Value +Types.+jsonStringify Root (external ref): Value +FirstClassModules.SomeFunctor.+ww + Root (annotated): Value +Types.+testMarshalFields Root (annotated): Value +Hooks.Inner.Inner2.+make Root (annotated): Value +ImportJsValue.+area - Root (annotated): Value +Records.+testMyRec - Root (annotated): Value +DeadTest.GloobLive.+globallyLive3 + Root (external ref): Value +DeadTest.MM.+x Root (external ref): RecordLabel +Uncurried.auth.login Root (annotated): Value +ImportJsValue.+roundedNumber Root (external ref): RecordLabel +RepeatedLabel.tabState.a @@ -2091,7 +2093,6 @@ Forward Liveness Analysis Root (annotated): Value +Shadow.+test Root (external ref): RecordLabel +Types.mutuallyRecursiveA.b Root (annotated): RecordLabel +ImportHooks.props.renderMe - Root (annotated): Value +TestPromise.+convert Root (external ref): Value +EmptyArray.Z.+make Root (annotated): Value +ScopedAnnotationsLiveVsDead.LiveScope.+root Root (external ref): Value +Newton.+result @@ -2100,135 +2101,130 @@ Forward Liveness Analysis Root (annotated): Value +ImportJsValue.+useGetProp Root (annotated): Value +Variants.+id2 Root (annotated): Value +Uncurried.+sumU - Root (external ref): Value +TestOptArg.+bar - Root (external ref): RecordLabel +DeadTest.record.yyy + Root (annotated): Value +DeadTest.+thisIsMarkedLive Root (annotated): Value +Docstrings.+one - Root (external ref): Value +OptArg.+twoArgs Root (annotated): Value +OcamlWarningSuppressToplevel.+suppressed1 - Root (external ref): RecordLabel +Records.business2.address2 Root (annotated): Value +Tuples.+testTuple - Root (annotated): Value +Records.+testMyObj2 + Root (external ref): Value +OptArg.+wrapOneArg Root (annotated): Value +Uncurried.+callback2 - Root (external ref): Value +DeadTest.VariantUsedOnlyInImplementation.+a Root (annotated): Value +ImportMyBanner.+make + Root (annotated): Value +VariantsWithPayload.+testVariantWithPayloads Root (external ref): RecordLabel +Records.payload.payload + Root (annotated): Value +Tuples.+marry Root (annotated): Value +ImportJsValue.+returnMixedArray Root (annotated): Value +TestEmitInnerModules.Outer.Medium.Inner.+y Root (annotated): Value +TestEmitInnerModules.Inner.+x - Root (external ref): Value +OptArg.+wrapOneArg + Root (annotated): Value +Tuples.+changeSecondAge Root (external ref): RecordLabel +ComponentAsProp.props.title Root (annotated): Value +Records.+findAddress Root (annotated): Value +Uncurried.+callback + Root (external ref): Value +DeadTest.+thisIsUsedTwice Root (annotated): Value +VariantsWithPayload.+printVariantWithPayload Root (annotated): Value +TestImmutableArray.+testImmutableArrayGet + Root (annotated): Value +VariantsWithPayload.+printManyPayloads Root (external ref): Value +TypeReexport.UseOriginal.+value Root (annotated): Value +Docstrings.+unnamed2 Root (annotated): Value +LetPrivate.local_1.+x Root (annotated): Value +TestImport.+make - Root (annotated): Value +DeadTest.GloobLive.+globallyLive1 Root (annotated): Value +Docstrings.+grouped Root (annotated): Value +OcamlWarningSuppressToplevel.M.+suppressed4 - Root (annotated): Value +Types.+optFunction - Root (annotated): Value +Records.+getPayloadRecordPlusOne Root (external ref): VariantCase +DeadTest.inlineRecord.IR + Root (annotated): Value +Records.+getPayloadRecordPlusOne Root (annotated): Value +Types.+swap - Root (annotated): Value +Types.+jsonStringify Root (annotated): RecordLabel +ImportHookDefault.props.person Root (annotated): Value +Variants.+saturday Root (external ref): VariantCase +Docstrings.t.A Root (annotated): Value +OcamlWarningSuppressToplevel.M.+suppressed3 - Root (annotated): Value +Records.+findAddress2 Root (annotated): Value +Uncurried.+uncurried0 Root (annotated): Value +Records.+someBusiness Root (external ref): RecordLabel +Hooks.vehicle.name - Root (annotated): Value +Uncurried.+sumLblCurried + Root (external ref): RecordLabel +Tuples.person.age Root (annotated): Value +RecordRest.+getRest Root (annotated): Value +References.+preserveRefIdentity - Root (annotated): Value +Types.+jsStringT Root (annotated): Value +Variants.+restResult1 + Root (external ref): Value +TestOptArg.+notSuppressesOptArgs + Root (external ref): RecordLabel +Records.myRecBsAs.type_ Root (external ref): VariantCase +TypeReexport.VariantUseReexported.reexportedType.A Root (external ref): Value +Unison.+toString Root (annotated): Value +ImportJsValue.+polymorphic Root (annotated): Value +References.+set - Root (external ref): Value +DeadTest.MM.+x + Root (annotated): Value +Records.+testMyRecBsAs2 Root (annotated): Value +ModuleAliases.+testInner Root (external ref): RecordLabel +ComponentAsProp.props.description Root (annotated): Value +Docstrings.+useParamU Root (annotated): Value +ImportJsValue.+useColor - Root (annotated): Value +Tuples.+changeSecondAge Root (external ref): Value +Unison.+group Root (external ref): RecordLabel +RecordRest.SubConfig.t.version Root (annotated): Value +Docstrings.+unnamed1U Root (annotated): Value +Records.+recordValue Root (annotated): Value +ImportHookDefault.+make Root (annotated): Value +Types.+map - Root (annotated): Value +Types.+testInstantiateTypeParameter Root (annotated): RecordLabel +DeadTypeTest.record.x + Root (external ref): Value +TestOptArg.+bar Root (external ref): RecordLabel +Records.myRec.type_ - Root (annotated): Value +TestOptArg.+liveSuppressesOptArgs + Root (external ref): Value +DeadTest.+make Root (annotated): Value NestedModulesInSignature.Universe.+theAnswer Root (annotated): Value +Docstrings.+unitArgWithoutConversion Root (annotated): Value +References.+create - Root (annotated): Value +Types.+currentTime - Root (annotated): Value +Records.+someBusiness2 - Root (external ref): Value +DeadTest.+ira Root (annotated): Value +FirstClassModules.+testConvert Root (external ref): RecordLabel +Records.coord.z Root (annotated): Value +Types.+someIntList - Root (annotated): Value +Types.+jsString2T + Root (annotated): Value +Types.+i64Const Root (external ref): VariantCase +Unison.stack.Empty Root (annotated): Value +Records.+coord2d Root (external ref): RecordLabel +DynamicallyLoadedComponent.props.s - Root (external ref): RecordLabel +Tuples.person.age Root (annotated): Value +NestedModules.Universe.+someString Root (external ref): VariantCase +Unison.break_.Always + Root (external ref): RecordLabel +DeadTest.record.xxx + Root (external ref): RecordLabel +DeadTest.record.yyy Root (annotated): Value +TestFirstClassModules.+convertInterface - Root (external ref): RecordLabel +TestPromise.fromPayload.s - Root (annotated): Value +Types.+testMarshalFields Root (external ref): RecordLabel +VariantsWithPayload.payload.x + Root (annotated): RecordLabel +DeadTest.inlineRecord.IR.e Root (annotated): RecordLabel +ImportHooks.props.children + Root (external ref): RecordLabel +DeadTest.props.s Root (external ref): VariantCase +DeadTypeTest.t.A Root (annotated): Value +Docstrings.+oneU Root (annotated): RecordLabel +DeadTypeTest.record.z + Root (annotated): Value +Records.+testMyObj2 Root (annotated): Value +Docstrings.+flat Root (annotated): Value +NestedModules.Universe.Nested2.+nested2Value - Root (annotated): Value +Records.+testMyObj + Root (external ref): RecordLabel +Records.business2.address2 Root (external ref): VariantCase DeadTypeTest.deadType.InBoth Root (annotated): Value +ScopedAnnotationsOverride.M.+live2 - Root (annotated): Value +Records.+testMyRecBsAs2 - Root (annotated): Value +VariantsWithPayload.+testManyPayloads Root (annotated): Value +FirstClassModules.+someFunctorAsFunction - Root (annotated): Value +Records.+computeArea3 Root (annotated): Value +Variants.+fortytwoBAD - Root (external ref): Value +DeadTest.+thisIsUsedOnce Root (external ref): RecordLabel +Unison.t.break_ Root (external ref): RecordLabel +Hooks.Inner.props.vehicle Root (external ref): Value ImmutableArray.+fromArray Root (external ref): Value +RepeatedLabel.+userData Root (annotated): Value +Variants.+testConvert2to3 - Root (external ref): Value +OptArg.+wrapfourArgs + Root (external ref): Value +DeadTest.+thisIsUsedOnce Root (annotated): Value +ImportJsValue.+round Root (annotated): Value +TestModuleAliases.+testInner2 - Root (annotated): Value +VariantsWithPayload.+testSimpleVariant + Root (annotated): Value +Tuples.+getFirstName Root (annotated): Value +TestFirstClassModules.+convert + Root (annotated): Value +Records.+testMyRec Root (external ref): VariantCase +DeadRT.moduleAccessPath.Kaboom Root (external ref): Value +TypeReexport.UseReexported.+value + Root (external ref): Value +DeadTest.+deadIncorrect Root (external ref): Value +DeadCodeImplementation.M.+x - Root (annotated): Value +VariantsWithPayload.+testVariantWithPayloads Root (annotated): Value +Variants.+restResult2 Root (annotated): Value +Docstrings.+useParam Root (annotated): Value +Records.+getPayload + Root (annotated): Value +VariantsWithPayload.+printVariantWithPayloads Root (annotated): Value +ScopedAnnotationsOverride.M.NestedInLive.+nestedLive Root (external ref): Value +FirstClassModules.M.+y + Root (annotated): Value +Records.+findAddress2 Root (external ref): RecordLabel +Uncurried.authU.loginU + Root (external ref): RecordLabel +Tuples.person.name Root (annotated): Value +ModuleAliases.+testInner2 Root (annotated): RecordLabel +ImportHooks.props.person Root (external ref): Value DeadValueTest.+valueAlive + Root (external ref): Value +DeadTest.+ira Root (external ref): RecordLabel +Hooks.RenderPropRequiresConversion.props.renderVehicle Root (annotated): Value +Shadow.M.+test + Root (annotated): Value +Uncurried.+sumLblCurried Root (annotated): Value +ComponentAsProp.+make - Root (annotated): Value +Records.+testMyRec2 - Root (annotated): Value +VariantsWithPayload.+printManyPayloads Root (annotated): Value +TestFirstClassModules.+convertFirstClassModuleWithTypeEquations Root (annotated): Value +TransitiveType1.+convertAlias Root (annotated): Value +ForOf.+keep @@ -2237,12 +2233,13 @@ Forward Liveness Analysis Root (annotated): Value +TestImport.+defaultValue2 Root (external ref): Exception +DeadExn.Etoplevel Root (annotated): Value +Variants.+monday - Root (annotated): Value +VariantsWithPayload.+printVariantWithPayloads Root (annotated): Value +Unboxed.+r2Test Root (external ref): RecordLabel +Records.coord.y - Root (external ref): RecordLabel +DeadTest.record.xxx + Root (annotated): Value +Records.+testMyObj + Root (annotated): Value +TestPromise.+convert Root (annotated): Value +FirstClassModules.+firstClassModule Root (external ref): RecordLabel +Hooks.props.vehicle + Root (external ref): Value +DeadTest.VariantUsedOnlyInImplementation.+a Root (annotated): Value +ImportJsValue.+useGetAbs Root (external ref): Value +JsxV4.C.+make Root (external ref): RecordLabel +Types.selfRecursive.self @@ -2250,86 +2247,87 @@ Forward Liveness Analysis Root (annotated): Value +Variants.+polyWithOpt Root (annotated): Value +References.+destroysRefIdentity Root (external ref): Value +Hooks.RenderPropRequiresConversion.+car + Root (external ref): Value +OptArg.+twoArgs Root (external ref): Value +FirstClassModules.M.+x Root (external ref): Value +TypeReexportCrossFileB.+recordValue - Root (annotated): Value +Records.+computeArea4 Root (annotated): Value +TestModuleAliases.+testInner1Expanded Root (external ref): Value +TypeReexport.OnlyReexportedDead.+value + Root (annotated): Value +DeadTest.GloobLive.+globallyLive3 + Root (annotated): Value +VariantsWithPayload.+testVariant1Int Root (annotated): Value +ImportIndex.+make - Root (external ref): RecordLabel +DeadTest.inlineRecord.IR.b Root (annotated): Value +Unboxed.+testV1 Root (annotated): Value +NestedModules.Universe.+theAnswer Root (annotated): Value +References.+access Root (annotated): Value +TestModuleAliases.+testInner2Expanded Root (annotated): Value +Variants.+isWeekend Root (annotated): Value +Variants.+testConvert + Root (annotated): Value +DeadTest.GloobLive.+globallyLive1 Root (annotated): Value +Variants.+id1 - Root (annotated): Value +VariantsWithPayload.+testVariant1Object Root (annotated): Value +References.+update Root (annotated): Value +Opaque.+noConversion Root (external ref): RecordLabel +RepeatedLabel.tabState.b - Root (annotated): Value +DeadTest.GloobLive.+globallyLive2 + Root (annotated): Value +VariantsWithPayload.+testManyPayloads Root (external ref): RecordLabel +TypeReexport.OnlyReexportedDead.reexportedType.usedField Root (annotated): Value +Docstrings.+unitArgWithConversion Root (external ref): RecordLabel +Records.business.owner - Root (external ref): VariantCase +DeadTest.WithInclude.t.A Root (external ref): VariantCase +DeadTypeTest.deadType.InBoth Root (external ref): RecordLabel +Records.business.address Root (external ref): RecordLabel +VariantsWithPayload.payload.y Root (annotated): RecordLabel +ImportHookDefault.props.children + Root (annotated): Value +Records.+testMyRec2 Root (annotated): Value +TestModuleAliases.+testInner1 Root (annotated): Value +ForAwaitOf.+keep Root (annotated): Value +OcamlWarningSuppressToplevel.+suppressed2 Root (annotated): Value +VariantsWithPayload.+testWithPayload - Root (annotated): Value +Types.+testConvertNull Root (annotated): Value +Records.+getPayloadRecord Root (annotated): Value +Tuples.+computeAreaNoConverters Root (annotated): Value +Types.+mutuallyRecursiveConverter Root (annotated): Value +UseImportJsValue.+useGetProp Root (annotated): Value +Hooks.+functionWithRenamedArgs - 325 roots found + 323 roots found Propagate: DeadRT.moduleAccessPath.Root -> +DeadRT.moduleAccessPath.Root Propagate: +TypeReexportCrossFileB.reexportedRecord.usedField -> +TypeReexportCrossFileA.originalRecord.usedField + Propagate: +OptArg.+wrapfourArgs -> +OptArg.+fourArgs Propagate: +DeadTypeTest.deadType.OnlyInImplementation -> DeadTypeTest.deadType.OnlyInImplementation Propagate: +OptionalArgsLiveDead.+liveCaller -> +OptionalArgsLiveDead.+formatDate Propagate: +Newton.+f -> +Newton.+- Propagate: +Newton.+f -> +Newton.++ Propagate: +Newton.+f -> +Newton.+* - Propagate: +DeadTest.VariantUsedOnlyInImplementation.t.A -> +DeadTest.VariantUsedOnlyInImplementation.t.A - Propagate: +DeadTest.+thisIsMarkedLive -> +DeadTest.+thisIsKeptAlive Propagate: +TypeReexport.UseOriginal.reexportedType.directlyUsed -> +TypeReexport.UseOriginal.originalType.directlyUsed Propagate: +Hooks.+default -> +Hooks.+make Propagate: InnerModuleTypes.I.t.Foo -> +InnerModuleTypes.I.t.Foo Propagate: DeadTypeTest.deadType.OnlyInInterface -> +DeadTypeTest.deadType.OnlyInInterface + Propagate: +DeadTest.VariantUsedOnlyInImplementation.t.A -> +DeadTest.VariantUsedOnlyInImplementation.t.A Propagate: +TypeReexport.UseReexported.reexportedType.usedField -> +TypeReexport.UseReexported.originalType.usedField + Propagate: +DeadTest.WithInclude.t.A -> +DeadTest.WithInclude.t.A Propagate: +References.+get -> +References.R.+get + Propagate: +DeadTest.MM.+x -> +DeadTest.MM.+x Propagate: ErrorHandler.Make.+notify -> +ErrorHandler.Make.+notify Propagate: +References.+make -> +References.R.+make Propagate: +ScopedAnnotationsLiveVsDead.LiveScope.+root -> +ScopedAnnotationsLiveVsDead.+middleLive Propagate: +Newton.+result -> +Newton.+newton Propagate: +Newton.+result -> +Newton.+fPrimed Propagate: +Records.+findAllAddresses -> +Records.+getOpt - Propagate: +TestOptArg.+bar -> +TestOptArg.+foo - Propagate: +DeadTest.VariantUsedOnlyInImplementation.+a -> +DeadTest.VariantUsedOnlyInImplementation.+a + Propagate: +DeadTest.+thisIsMarkedLive -> +DeadTest.+thisIsKeptAlive Propagate: +OptArg.+wrapOneArg -> +OptArg.+oneArg Propagate: +TestImmutableArray.+testImmutableArrayGet -> ImmutableArray.Array.+get Propagate: +TypeReexport.VariantUseReexported.reexportedType.A -> +TypeReexport.VariantUseReexported.originalType.A Propagate: +Unison.+toString -> +Unison.+fits Propagate: +References.+set -> +References.R.+set - Propagate: +DeadTest.MM.+x -> +DeadTest.MM.+x + Propagate: +TestOptArg.+bar -> +TestOptArg.+foo Propagate: NestedModulesInSignature.Universe.+theAnswer -> +NestedModulesInSignature.Universe.+theAnswer Propagate: +DeadTypeTest.t.A -> DeadTypeTest.t.A Propagate: ImmutableArray.+fromArray -> +ImmutableArray.+fromArray - Propagate: +OptArg.+wrapfourArgs -> +OptArg.+fourArgs Propagate: +DeadRT.moduleAccessPath.Kaboom -> DeadRT.moduleAccessPath.Kaboom Propagate: DeadValueTest.+valueAlive -> +DeadValueTest.+valueAlive + Propagate: +DeadTest.VariantUsedOnlyInImplementation.+a -> +DeadTest.VariantUsedOnlyInImplementation.+a Propagate: +ImportJsValue.+useGetAbs -> +ImportJsValue.AbsoluteValue.+getAbs Propagate: +TypeReexport.VariantUseOriginal.reexportedType.A -> +TypeReexport.VariantUseOriginal.originalType.A Propagate: +TypeReexport.OnlyReexportedDead.reexportedType.usedField -> +TypeReexport.OnlyReexportedDead.originalType.usedField - Propagate: +DeadTest.WithInclude.t.A -> +DeadTest.WithInclude.t.A Propagate: +References.R.+get -> +References.R.+get + Propagate: +DeadTest.MM.+x -> +DeadTest.MM.+y Propagate: +References.R.+make -> +References.R.+make Propagate: +ScopedAnnotationsLiveVsDead.+middleLive -> +ScopedAnnotationsLiveVsDead.+leafLive Propagate: +Newton.+newton -> +Newton.+/ @@ -2341,7 +2339,6 @@ Forward Liveness Analysis Propagate: +Newton.+newton -> +Newton.+next Propagate: ImmutableArray.Array.+get -> +ImmutableArray.+get Propagate: +References.R.+set -> +References.R.+set - Propagate: +DeadTest.MM.+x -> +DeadTest.MM.+y Propagate: +ImportJsValue.AbsoluteValue.+getAbs -> +ImportJsValue.AbsoluteValue.+getAbs 53 declarations marked live via propagation @@ -3867,8 +3864,6 @@ Forward Liveness Analysis Live (annotated) Value +Types.+testFunctionOnOptionsAsArgument Dead VariantCase +Types.opaqueVariant.A Dead VariantCase +Types.opaqueVariant.B - Live (annotated) Value +Types.+jsStringT - Live (annotated) Value +Types.+jsString2T Live (annotated) Value +Types.+jsonStringify Dead RecordLabel +Types.record.i Dead RecordLabel +Types.record.s @@ -4118,7 +4113,7 @@ Forward Liveness Analysis deadRef is never used Warning Dead Value With Side Effects - DeadTest.res:121:1-40 + DeadTest.res:121:1-45 theSideEffectIsLogging is never used and could have side effects Warning Dead Value With Side Effects @@ -4538,7 +4533,7 @@ Forward Liveness Analysis reverse is never used Warning Dead Value - ImmutableArray.resi:29:1-49 + ImmutableArray.resi:29:1-46 makeUninitialized is never used Warning Dead Value @@ -4954,7 +4949,7 @@ Forward Liveness Analysis business2.name is a record label never used to read a value Warning Dead Type - Records.res:91:3-30 + Records.res:91:3-25 business2.owner is a record label never used to read a value Warning Dead Type @@ -5110,23 +5105,23 @@ Forward Liveness Analysis opaqueVariant.B is a variant case which is never constructed Warning Dead Type - Types.res:84:3-8 + Types.res:78:3-8 record.i is a record label never used to read a value Warning Dead Type - Types.res:85:3-11 + Types.res:79:3-11 record.s is a record label never used to read a value Warning Dead Type - Types.res:130:20-26 + Types.res:124:20-26 someRecord.id is a record label never used to read a value Warning Dead Module - Types.res:158:8-79 + Types.res:152:8-79 Types.ObjectId is a dead module as all its items are dead. Warning Dead Value - Types.res:163:3-11 + Types.res:157:3-11 ObjectId.x is never used Warning Dead Type @@ -5201,21 +5196,17 @@ Forward Liveness Analysis VariantsWithPayload.res:96:23-32 variant1Object.R is a variant case which is never constructed - Warning Unused Argument - OptArg.res:24:1-63 - optional argument d of function fourArgs is never used - - Warning Unused Argument - TestOptArg.res:9:1-65 - optional argument x of function notSuppressesOptArgs is never used + Warning Redundant Optional Argument + OptArg.res:26:1-70 + optional argument c of function wrapfourArgs is always supplied (2 calls) - Warning Unused Argument - TestOptArg.res:9:1-65 - optional argument y of function notSuppressesOptArgs is never used + Warning Redundant Optional Argument + TestOptArg.res:3:1-28 + optional argument x of function foo is always supplied (1 calls) Warning Unused Argument - TestOptArg.res:9:1-65 - optional argument z of function notSuppressesOptArgs is never used + OptArg.res:24:1-63 + optional argument d of function fourArgs is never used Warning Unused Argument OptArg.res:1:1-48 @@ -5237,6 +5228,10 @@ Forward Liveness Analysis OptArg.res:3:1-38 optional argument x of function bar is never used + Warning Unused Argument + OptionalArgsLiveDead.res:1:1-33 + optional argument fmt of function formatDate is never used + Warning Unused Argument OptArg.res:9:1-54 optional argument b of function threeArgs is never used @@ -5245,32 +5240,32 @@ Forward Liveness Analysis OptArg.res:9:1-54 optional argument a of function threeArgs is always supplied (2 calls) - Warning Unused Argument - OptionalArgsLiveDead.res:1:1-33 - optional argument fmt of function formatDate is never used + Warning Redundant Optional Argument + OptArg.res:20:1-51 + optional argument a of function wrapOneArg is always supplied (1 calls) Warning Unused Argument - OptArg.res:14:1-42 - optional argument a of function twoArgs is never used + TestOptArg.res:9:1-65 + optional argument x of function notSuppressesOptArgs is never used Warning Unused Argument - OptArg.res:14:1-42 - optional argument b of function twoArgs is never used - - Warning Redundant Optional Argument - TestOptArg.res:3:1-28 - optional argument x of function foo is always supplied (1 calls) + TestOptArg.res:9:1-65 + optional argument y of function notSuppressesOptArgs is never used - Warning Redundant Optional Argument - OptArg.res:20:1-51 - optional argument a of function wrapOneArg is always supplied (1 calls) + Warning Unused Argument + TestOptArg.res:9:1-65 + optional argument z of function notSuppressesOptArgs is never used Warning Redundant Optional Argument Unison.res:17:1-55 optional argument break_ of function group is always supplied (2 calls) - Warning Redundant Optional Argument - OptArg.res:26:1-70 - optional argument c of function wrapfourArgs is always supplied (2 calls) + Warning Unused Argument + OptArg.res:14:1-42 + optional argument a of function twoArgs is never used + + Warning Unused Argument + OptArg.res:14:1-42 + optional argument b of function twoArgs is never used Analysis reported 319 issues (Incorrect Dead Annotation:1, Warning Dead Exception:2, Warning Dead Module:22, Warning Dead Type:94, Warning Dead Value:177, Warning Dead Value With Side Effects:5, Warning Redundant Optional Argument:6, Warning Unused Argument:12) diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/DeadExn.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/DeadExn.res index 3f68ffce74c..547bb1bcb30 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/DeadExn.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/DeadExn.res @@ -9,5 +9,5 @@ let eToplevel = Etoplevel let eInside = Inside.Einside -Js.log(eInside) +Console.log(eInside) diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/DeadRT.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/DeadRT.res index be16b074f39..1e5414f77e8 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/DeadRT.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/DeadRT.res @@ -8,5 +8,5 @@ let rec emitModuleAccessPath = moduleAccessPath => | Kaboom => "" } -let () = Js.log(Kaboom) +let () = Console.log(Kaboom) diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/DeadTest.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/DeadTest.res index 1690f4dfef1..db2dacbb904 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/DeadTest.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/DeadTest.res @@ -1,4 +1,4 @@ -let _ = Js.log(ImmutableArray.fromArray) +let _ = Console.log(ImmutableArray.fromArray) let fortytwo = 42 @genType @@ -66,11 +66,11 @@ module MM: { } let _ = { - Js.log(MM.x) + Console.log(MM.x) 44 } -let () = Js.log(DeadValueTest.valueAlive) +let () = Console.log(DeadValueTest.valueAlive) let rec unusedRec = () => unusedRec() @@ -95,7 +95,7 @@ and bar = () => foo() let withDefaultValue = (~paramWithDefault=3, y) => paramWithDefault + y -let () = Js.log(DeadRT.Root("xzz")) +let () = Console.log(DeadRT.Root("xzz")) module type LocalDynamicallyLoadedComponent2 = module type of DynamicallyLoadedComponent @@ -107,7 +107,7 @@ let zzz = { let a3 = 3 } -let () = Js.log() +let () = Console.log() let second = 1 @@ -116,9 +116,9 @@ let deadRef = ref(12) @react.component let make = (~s) => React.string(s) -let () = Js.log(make) +let () = Console.log(make) -let theSideEffectIsLogging = Js.log(123) +let theSideEffectIsLogging = Console.log(123) let stringLengthNoSideEffects = String.length("sdkdl") @@ -145,7 +145,7 @@ module WithInclude: { include T } -Js.log(WithInclude.A) +Console.log(WithInclude.A) @dead let funWithInnerVars = () => { diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/ImmutableArray.resi b/tests/analysis_tests/tests-reanalyze/deadcode/src/ImmutableArray.resi index a0695a8aac6..cb9c0542434 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/ImmutableArray.resi +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/ImmutableArray.resi @@ -26,7 +26,7 @@ let shuffle: t<'a> => t<'a> let reverse: t<'a> => t<'a> -let makeUninitialized: int => t> +let makeUninitialized: int => t> let makeUninitializedUnsafe: int => t<'a> diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/ModuleExceptionBug.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/ModuleExceptionBug.res index f9b36ce2355..7ac327b39ba 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/ModuleExceptionBug.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/ModuleExceptionBug.res @@ -5,4 +5,4 @@ module Dep = { exception MyOtherException let ddjdj = 34 -Js.log(ddjdj) +Console.log(ddjdj) diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/Newton.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/Newton.res index ce8f3388904..5536fdb17e4 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/Newton.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/Newton.res @@ -28,5 +28,5 @@ let fPrimed = x => 3.0 * x * x - 4.0 * x - 11.0 let result = newton(~f, ~fPrimed, ~initial=5.0, ~threshold=0.0003) -Js.log2(result, f(result)) +Console.log2(result, f(result)) diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/OptArg.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/OptArg.res index d72a06e155b..7a01f3f920d 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/OptArg.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/OptArg.res @@ -2,29 +2,29 @@ let foo = (~x=1, ~y=2, ~z=3, w) => x + y + z + w let bar = (~x=?, ~y, ~z=?, w) => y + w -Js.log(foo(~x=3, 4)) +Console.log(foo(~x=3, 4)) -Js.log(bar(~y=3, 4)) +Console.log(bar(~y=3, 4)) let threeArgs = (~a=1, ~b=2, ~c=3, d) => a + b + c + d -Js.log(threeArgs(~a=4, ~c=7, 1)) -Js.log(threeArgs(~a=4, 1)) +Console.log(threeArgs(~a=4, ~c=7, 1)) +Console.log(threeArgs(~a=4, 1)) let twoArgs = (~a=1, ~b=2, c) => a + b + c -Js.log(1->twoArgs) +Console.log(1->twoArgs) let oneArg = (~a=1, ~z, b) => a + b let wrapOneArg = (~a=?, n) => oneArg(~a?, ~z=33, n) -Js.log(wrapOneArg(~a=3, 44)) +Console.log(wrapOneArg(~a=3, 44)) let fourArgs = (~a=1, ~b=2, ~c=3, ~d=4, n) => a + b + c + d + n let wrapfourArgs = (~a=?, ~b=?, ~c=?, n) => fourArgs(~a?, ~b?, ~c?, n) -Js.log(wrapfourArgs(~a=3, ~c=44, 44)) -Js.log(wrapfourArgs(~b=4, ~c=44, 44)) +Console.log(wrapfourArgs(~a=3, ~c=44, 44)) +Console.log(wrapfourArgs(~b=4, ~c=44, 44)) diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/Records.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/Records.res index 3d7bfc2f126..386cc2b5e49 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/Records.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/Records.res @@ -88,24 +88,24 @@ let getPayloadRecordPlusOne = ({payload}): record => { @genType type business2 = { name: string, - owner: Js.Nullable.t, - address2: Js.Nullable.t, + owner: nullable, + address2: nullable, } @genType let findAddress2 = (business: business2): list => - business.address2->Js.Nullable.toOption->getOpt(list{}, a => list{a}) + business.address2->Nullable.toOption->getOpt(list{}, a => list{a}) @genType let someBusiness2 = { name: "SomeBusiness", - owner: Js.Nullable.null, - address2: Js.Nullable.null, + owner: Nullable.null, + address2: Nullable.null, } @genType -let computeArea3 = (o: {"x": int, "y": int, "z": Js.Nullable.t}) => - o["x"] * o["y"] * o["z"]->Js.Nullable.toOption->Option.mapWithDefault(1, n => n) +let computeArea3 = (o: {"x": int, "y": int, "z": nullable}) => + o["x"] * o["y"] * o["z"]->Nullable.toOption->Option.mapWithDefault(1, n => n) @genType let computeArea4 = (o: {"x": int, "y": int, "z": option}) => @@ -146,4 +146,3 @@ let testMyRecBsAs = (x: myRecBsAs) => x.type_ @genType let testMyRecBsAs2 = (x: myRecBsAs) => x - diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/RepeatedLabel.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/RepeatedLabel.res index 3c0b6ddeb95..1efb1efd1cd 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/RepeatedLabel.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/RepeatedLabel.res @@ -11,5 +11,5 @@ type tabState = { let userData = ({a, b}): userData => {a: a, b: b} -Js.log(userData) +Console.log(userData) diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/RequireCond.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/RequireCond.res index 8c3638e16f8..b3cbadd8f8b 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/RequireCond.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/RequireCond.res @@ -6,7 +6,7 @@ external make: ( @string [@as("qe.bool") #qeBool | @as("gk") #gk], string, string, -) => Js.Nullable.t<'a> = "requireCond" +) => nullable<'a> = "requireCond" @module @deprecated( diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/TestDeadExn.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/TestDeadExn.res index 7810b9ccf3c..e05edf25052 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/TestDeadExn.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/TestDeadExn.res @@ -1,2 +1,2 @@ -Js.log(DeadExn.Etoplevel) +Console.log(DeadExn.Etoplevel) diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/TestOptArg.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/TestOptArg.res index ef38c7c7ec2..53ce173fb75 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/TestOptArg.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/TestOptArg.res @@ -1,10 +1,10 @@ -Js.log(OptArg.bar(~z=3, ~y=3, 4)) +Console.log(OptArg.bar(~z=3, ~y=3, 4)) let foo = (~x=3, y) => x + y let bar = () => foo(~x=12, 3) -Js.log(bar) +Console.log(bar) let notSuppressesOptArgs = (~x=1, ~y=2, ~z=3, w) => x + y + z + w diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/TestPromise.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/TestPromise.res index 174cb4964fb..b0b744aa907 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/TestPromise.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/TestPromise.res @@ -1,5 +1,5 @@ @genType -type promise<'a> = Js.Promise.t<'a> +type promise<'a> = Promise.t<'a> @genType type fromPayload = { @@ -11,5 +11,4 @@ type fromPayload = { type toPayload = {result: string} @genType -let convert = Js.Promise.then_(({s}) => Js.Promise.resolve({result: s}), ...) - +let convert = promise => promise->Promise.then(({s}) => Promise.resolve({result: s})) diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/Tuples.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/Tuples.res index d2194a49d9c..5e6f6aaafa0 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/Tuples.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/Tuples.res @@ -28,7 +28,7 @@ let computeAreaNoConverters = ((x: int, y: int)) => x * y let coord2d = (x, y) => (x, y, None) @genType -type coord2 = (int, int, Js.Nullable.t) +type coord2 = (int, int, nullable) @genType type person = { diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/Types.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/Types.res index ed7de796eb2..bbc0d2bba5e 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/Types.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/Types.res @@ -56,12 +56,6 @@ type opaqueVariant = | A | B -@genType -let jsStringT: Js.String.t = "a" - -@genType -let jsString2T: Js.String2.t = "a" - @genType type twice<'a> = ('a, 'a) @@ -69,16 +63,16 @@ type twice<'a> = ('a, 'a) type genTypeMispelled = int @genType -type dictString = Js.Dict.t +type dictString = dict @genType -let jsonStringify = Js.Json.stringify +let jsonStringify = JSON.stringify @genType -type nullOrString = Js.Null.t +type nullOrString = Null.t @genType -type nullOrString2 = Js.null +type nullOrString2 = null type record = { i: int, @@ -86,7 +80,7 @@ type record = { } @genType -let testConvertNull = (x: Js.Null.t) => x +let testConvertNull = (x: Null.t) => x @genType type decorator<'a, 'b> = 'a => 'b constraint 'a = int constraint 'b = _ => _ @@ -138,10 +132,10 @@ let testInstantiateTypeParameter = (x: instantiateTypeParameter) => x type vector<'a> = ('a, 'a) @genType -type date = Js.Date.t +type date = Date.t @genType -let currentTime = Js.Date.make() +let currentTime = Date.make() @genType type i64A = int @@ -162,4 +156,3 @@ module ObjectId: { type t = int let x = 1 } - diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/Uncurried.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/Uncurried.res index 7a3ae4bf04e..74eb18f3079 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/Uncurried.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/Uncurried.res @@ -38,20 +38,20 @@ let callback2 = auth => auth.login() let callback2U = auth => auth.loginU() @genType -let sumU = (n, m) => Js.log4("sumU 2nd arg", m, "result", n + m) +let sumU = (n, m) => Console.log4("sumU 2nd arg", m, "result", n + m) @genType -let sumU2 = (n, m) => Js.log4("sumU2 2nd arg", m, "result", n + m) +let sumU2 = (n, m) => Console.log4("sumU2 2nd arg", m, "result", n + m) @genType let sumCurried = n => { - Js.log2("sumCurried 1st arg", n) - m => Js.log4("sumCurried 2nd arg", m, "result", n + m) + Console.log2("sumCurried 1st arg", n) + m => Console.log4("sumCurried 2nd arg", m, "result", n + m) } @genType let sumLblCurried = (s: string, ~n) => { - Js.log3(s, "sumLblCurried 1st arg", n) - (~m) => Js.log4("sumLblCurried 2nd arg", m, "result", n + m) + Console.log3(s, "sumLblCurried 1st arg", n) + (~m) => Console.log4("sumLblCurried 2nd arg", m, "result", n + m) } diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/VariantsWithPayload.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/VariantsWithPayload.res index 4da94ed5783..def8d276792 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/VariantsWithPayload.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/VariantsWithPayload.res @@ -18,12 +18,12 @@ let testWithPayload = (x: withPayload) => x @genType let printVariantWithPayload = (x: withPayload) => switch x { - | #a => Js.log("printVariantWithPayload: a") - | #b => Js.log("printVariantWithPayload: b") - | #True => Js.log("printVariantWithPayload: True") - | #Twenty => Js.log("printVariantWithPayload: Twenty") - | #Half => Js.log("printVariantWithPayload: Half") - | #c(payload) => Js.log4("printVariantWithPayload x:", payload.x, "y:", payload.y) + | #a => Console.log("printVariantWithPayload: a") + | #b => Console.log("printVariantWithPayload: b") + | #True => Console.log("printVariantWithPayload: True") + | #Twenty => Console.log("printVariantWithPayload: Twenty") + | #Half => Console.log("printVariantWithPayload: Half") + | #c(payload) => Console.log4("printVariantWithPayload x:", payload.x, "y:", payload.y) } @genType @@ -39,9 +39,9 @@ let testManyPayloads = (x: manyPayloads) => x @genType let printManyPayloads = (x: manyPayloads) => switch x { - | #one(n) => Js.log2("printManyPayloads one:", n) - | #two(s1, s2) => Js.log3("printManyPayloads two:", s1, s2) - | #three(payload) => Js.log4("printManyPayloads x:", payload.x, "y:", payload.y) + | #one(n) => Console.log2("printManyPayloads one:", n) + | #two(s1, s2) => Console.log3("printManyPayloads two:", s1, s2) + | #three(payload) => Console.log4("printManyPayloads x:", payload.x, "y:", payload.y) } @genType @@ -67,20 +67,20 @@ let testVariantWithPayloads = (x: variantWithPayloads) => x @genType let printVariantWithPayloads = x => switch x { - | A => Js.log2("printVariantWithPayloads", "A") - | B(x) => Js.log2("printVariantWithPayloads", "B(" ++ (string_of_int(x) ++ ")")) + | A => Console.log2("printVariantWithPayloads", "A") + | B(x) => Console.log2("printVariantWithPayloads", "B(" ++ (string_of_int(x) ++ ")")) | C(x, y) => - Js.log2( + Console.log2( "printVariantWithPayloads", "C(" ++ (string_of_int(x) ++ (", " ++ (string_of_int(y) ++ ")"))), ) | D((x, y)) => - Js.log2( + Console.log2( "printVariantWithPayloads", "D((" ++ (string_of_int(x) ++ (", " ++ (string_of_int(y) ++ "))"))), ) | E(x, s, y) => - Js.log2( + Console.log2( "printVariantWithPayloads", "E(" ++ (string_of_int(x) ++ (", " ++ (s ++ (", " ++ (string_of_int(y) ++ ")"))))), ) diff --git a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Exn.res b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Exn.res index 37916f507ed..5fd6969bebb 100644 --- a/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Exn.res +++ b/tests/analysis_tests/tests-reanalyze/deadcode/src/exception/Exn.res @@ -116,7 +116,7 @@ let throwPipe = throw(Not_found) let throwArrow = Not_found->throw @throws(JsExn) -let bar = () => Js.Json.parseExn("!!!") +let bar = () => JSON.parseOrThrow("!!!") let severalCases = cases => switch cases { diff --git a/tests/analysis_tests/tests/src/Debug.res b/tests/analysis_tests/tests/src/Debug.res index 8490433e401..5c4916f0472 100644 --- a/tests/analysis_tests/tests/src/Debug.res +++ b/tests/analysis_tests/tests/src/Debug.res @@ -3,7 +3,6 @@ let _ = ShadowedBelt.List.map // ^def -open Js module Before = { open Belt let _ = Id.getCmpInternal diff --git a/tests/analysis_tests/tests/src/expected/Completion.res.txt b/tests/analysis_tests/tests/src/expected/Completion.res.txt index f679ec14ced..89d73b0b0ca 100644 --- a/tests/analysis_tests/tests/src/expected/Completion.res.txt +++ b/tests/analysis_tests/tests/src/expected/Completion.res.txt @@ -582,7 +582,7 @@ Path Array. "detail": "array<'a> => IteratorObject.t<(int, 'a), unit, unknown>", "documentation": { "kind": "markdown", - "value": "\n`entries(array)` returns a new array iterator object that contains the key/value pairs for each index in the array.\n\nSee [Array.prototype.entries](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries) on MDN.\n\n## Examples\n\n```rescript\nlet array = [5, 6, 7]\nlet iterator: IteratorObject.t<(int, int), unit, unknown> = array->Array.entries\niterator->IteratorObject.toArray == [(0, 5), (1, 6), (2, 7)]\n```\n" + "value": "\n`entries(array)` returns a new array iterator object that contains the key/value pairs for each index in the array.\n\nSee [Array.prototype.entries](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/entries) on MDN.\n\n## Examples\n\n```rescript\nlet array = [5, 6, 7]\nlet iterator: IteratorObject.t<(int, int), unit, unknown> = array->Array.entries\niterator->IteratorObject.asIterable->Array.fromIterable == [(0, 5), (1, 6), (2, 7)]\n```\n" }, "kind": 12, "label": "entries", @@ -682,7 +682,7 @@ Path Array. "detail": "array<'a> => IteratorObject.t<'a, unit, unknown>", "documentation": { "kind": "markdown", - "value": "\n`values(array)` returns a new array iterator object that contains the values for each index in the array.\n\nSee [Array.prototype.values](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values) on MDN.\n\n## Examples\n\n```rescript\nlet array = [5, 6, 7]\nlet iterator: IteratorObject.t = array->Array.values\niterator->IteratorObject.toArray == [5, 6, 7]\n```\n " + "value": "\n`values(array)` returns a new array iterator object that contains the values for each index in the array.\n\nSee [Array.prototype.values](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/values) on MDN.\n\n## Examples\n\n```rescript\nlet array = [5, 6, 7]\nlet iterator: IteratorObject.t = array->Array.values\niterator->IteratorObject.asIterable->Array.fromIterable == [5, 6, 7]\n```\n " }, "kind": 12, "label": "values", diff --git a/tests/analysis_tests/tests/src/expected/Debug.res.txt b/tests/analysis_tests/tests/src/expected/Debug.res.txt index 53064946e9a..4ceb94118d3 100644 --- a/tests/analysis_tests/tests/src/expected/Debug.res.txt +++ b/tests/analysis_tests/tests/src/expected/Debug.res.txt @@ -7,38 +7,14 @@ Definition src/Debug.res 2:27 "uri": "file:///ShadowedBelt.res" } -Complete src/Debug.res 11:8 -posCursor:[11:8] posNoWhite:[11:7] Found expr:[11:5->11:8] -Pexp_ident eqN:[11:5->11:8] +Complete src/Debug.res 10:8 +posCursor:[10:8] posNoWhite:[10:7] Found expr:[10:5->10:8] +Pexp_ident eqN:[10:5->10:8] Completable: Cpath Value[eqN] -Raw opens: 1 Js.place holder Package opens Stdlib.place holder Pervasives.JsxModules.place holder -Resolved opens 2 Stdlib Js +Resolved opens 1 Stdlib ContextPath Value[eqN] Path eqN -[ - { - "deprecated": true, - "detail": "('a, nullable<'a>) => bool", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `eqNullable` directly instead.\n\n" - }, - "kind": 12, - "label": "eqNullable", - "tags": [ 1 ] - }, - { - "deprecated": true, - "detail": "('a, null<'a>) => bool", - "documentation": { - "kind": "markdown", - "value": "Deprecated: Use `eqNull` directly instead.\n\n" - }, - "kind": 12, - "label": "eqNull", - "tags": [ 1 ] - } -] +[] diff --git a/tests/build_tests/case/src/demo.res b/tests/build_tests/case/src/demo.res index 8d0b19151fc..3bfb9a1da21 100644 --- a/tests/build_tests/case/src/demo.res +++ b/tests/build_tests/case/src/demo.res @@ -1 +1 @@ -let () = Js.log("Hello, ReScript") +let () = Console.log("Hello, ReScript") diff --git a/tests/build_tests/case2/src/X.res b/tests/build_tests/case2/src/X.res index 8d0b19151fc..3bfb9a1da21 100644 --- a/tests/build_tests/case2/src/X.res +++ b/tests/build_tests/case2/src/X.res @@ -1 +1 @@ -let () = Js.log("Hello, ReScript") +let () = Console.log("Hello, ReScript") diff --git a/tests/build_tests/devonly/src/demo.res b/tests/build_tests/devonly/src/demo.res index dda4ba39eb8..df948c53dcb 100644 --- a/tests/build_tests/devonly/src/demo.res +++ b/tests/build_tests/devonly/src/demo.res @@ -1 +1 @@ -let () = Js.log(Depdemo.a) +let () = Console.log(Depdemo.a) diff --git a/tests/build_tests/devonly/src2/hellodep.res b/tests/build_tests/devonly/src2/hellodep.res index 382ad1a9a6d..a2bc3d182b2 100644 --- a/tests/build_tests/devonly/src2/hellodep.res +++ b/tests/build_tests/devonly/src2/hellodep.res @@ -1 +1 @@ -Js.log(Hello.v) +Console.log(Hello.v) diff --git a/tests/build_tests/exports/src/demo.res b/tests/build_tests/exports/src/demo.res index 223767069b0..bf534e09fdb 100644 --- a/tests/build_tests/exports/src/demo.res +++ b/tests/build_tests/exports/src/demo.res @@ -1,6 +1,6 @@ exception Stack_overflow exception Sys_error(string) -let _ = (Js.Int.toString, Js.Float.isNaN) +let _ = (Int.toString, Float.isNaN) /* make sure exception runtime is there */ let f = x => diff --git a/tests/build_tests/hyphen2/y-src/demo.res b/tests/build_tests/hyphen2/y-src/demo.res index 8d0b19151fc..3bfb9a1da21 100644 --- a/tests/build_tests/hyphen2/y-src/demo.res +++ b/tests/build_tests/hyphen2/y-src/demo.res @@ -1 +1 @@ -let () = Js.log("Hello, ReScript") +let () = Console.log("Hello, ReScript") diff --git a/tests/build_tests/jsx_settings_inheritance/node_modules/@rescript/react/src/React.res b/tests/build_tests/jsx_settings_inheritance/node_modules/@rescript/react/src/React.res index 33d33e2f313..2995ebeb8db 100644 --- a/tests/build_tests/jsx_settings_inheritance/node_modules/@rescript/react/src/React.res +++ b/tests/build_tests/jsx_settings_inheritance/node_modules/@rescript/react/src/React.res @@ -57,7 +57,7 @@ module Ref = { } @module("react") -external createRef: unit => ref> = "createRef" +external createRef: unit => ref> = "createRef" module Children = { @module("react") @scope("Children") @@ -92,7 +92,7 @@ module Context = { external createContext: 'a => Context.t<'a> = "createContext" @module("react") -external forwardRef: (@uncurry ('props, Js.Nullable.t>) => element) => component<'props> = +external forwardRef: (@uncurry ('props, nullable>) => element) => component<'props> = "forwardRef" @module("react") @@ -280,13 +280,13 @@ external useContext: Context.t<'any> => 'any = "useContext" @module("react") external useImperativeHandleOnEveryRender: ( - Js.Nullable.t>, + nullable>, @uncurry (unit => 'value), ) => unit = "useImperativeHandle" @module("react") external useImperativeHandle: ( - Js.Nullable.t>, + nullable>, @uncurry (unit => 'value), 'deps, ) => unit = "useImperativeHandle" @@ -294,7 +294,7 @@ external useImperativeHandle: ( @module("react") @deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle0: ( - Js.Nullable.t>, + nullable>, @uncurry (unit => 'value), @as(json`[]`) _, ) => unit = "useImperativeHandle" @@ -302,7 +302,7 @@ external useImperativeHandle0: ( @module("react") @deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle1: ( - Js.Nullable.t>, + nullable>, @uncurry (unit => 'value), array<'a>, ) => unit = "useImperativeHandle" @@ -310,7 +310,7 @@ external useImperativeHandle1: ( @module("react") @deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle2: ( - Js.Nullable.t>, + nullable>, @uncurry (unit => 'value), ('a, 'b), ) => unit = "useImperativeHandle" @@ -318,7 +318,7 @@ external useImperativeHandle2: ( @module("react") @deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle3: ( - Js.Nullable.t>, + nullable>, @uncurry (unit => 'value), ('a, 'b, 'c), ) => unit = "useImperativeHandle" @@ -326,7 +326,7 @@ external useImperativeHandle3: ( @module("react") @deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle4: ( - Js.Nullable.t>, + nullable>, @uncurry (unit => 'value), ('a, 'b, 'c, 'd), ) => unit = "useImperativeHandle" @@ -334,7 +334,7 @@ external useImperativeHandle4: ( @module("react") @deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle5: ( - Js.Nullable.t>, + nullable>, @uncurry (unit => 'value), ('a, 'b, 'c, 'd, 'e), ) => unit = "useImperativeHandle" @@ -342,7 +342,7 @@ external useImperativeHandle5: ( @module("react") @deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle6: ( - Js.Nullable.t>, + nullable>, @uncurry (unit => 'value), ('a, 'b, 'c, 'd, 'e, 'f), ) => unit = "useImperativeHandle" @@ -350,7 +350,7 @@ external useImperativeHandle6: ( @module("react") @deprecated("Please use useImperativeHandle or useImperativeHandleOnEveryRender instead") external useImperativeHandle7: ( - Js.Nullable.t>, + nullable>, @uncurry (unit => 'value), ('a, 'b, 'c, 'd, 'e, 'f, 'g), ) => unit = "useImperativeHandle" diff --git a/tests/build_tests/jsx_settings_inheritance/node_modules/@rescript/react/src/ReactDOM.res b/tests/build_tests/jsx_settings_inheritance/node_modules/@rescript/react/src/ReactDOM.res index c406b220e98..e260fb38e97 100644 --- a/tests/build_tests/jsx_settings_inheritance/node_modules/@rescript/react/src/ReactDOM.res +++ b/tests/build_tests/jsx_settings_inheritance/node_modules/@rescript/react/src/ReactDOM.res @@ -52,8 +52,8 @@ type domRef = JsxDOM.domRef module Ref = { type t = domRef - type currentDomRef = React.ref> - type callbackDomRef = Js.nullable => unit + type currentDomRef = React.ref> + type callbackDomRef = nullable => unit external domRef: currentDomRef => domRef = "%identity" external callbackDomRef: callbackDomRef => domRef = "%identity" @@ -75,7 +75,7 @@ module Props = { @optional key: string, @optional - ref: Js.nullable => unit, + ref: nullable => unit, /* accessibility */ /* https://www.w3.org/TR/wai-aria-1.1/ */ /* https://accessibilityresources.org/ is a great resource for these */ @@ -315,7 +315,7 @@ module Props = { @optional manifest: string /* uri */, @optional - max: string /* should be int or Js.Date.t */, + max: string /* should be int or Date.t */, @optional maxLength: int, @optional diff --git a/tests/build_tests/ns/src/demo.res b/tests/build_tests/ns/src/demo.res index b4490c8ff9c..bb62248e72e 100644 --- a/tests/build_tests/ns/src/demo.res +++ b/tests/build_tests/ns/src/demo.res @@ -1 +1 @@ -let () = Js.log(Hello.a + Hello.b) +let () = Console.log(Hello.a + Hello.b) diff --git a/tests/build_tests/react_ppx/src/React.res b/tests/build_tests/react_ppx/src/React.res index 38a5649b159..cb5168fc595 100644 --- a/tests/build_tests/react_ppx/src/React.res +++ b/tests/build_tests/react_ppx/src/React.res @@ -44,7 +44,7 @@ module Ref = { } @module("react") -external createRef: unit => Ref.t> = "createRef" +external createRef: unit => Ref.t> = "createRef" module Children = { @module("react") @scope("Children") @val @@ -75,8 +75,7 @@ module Context = { external createContext: 'a => Context.t<'a> = "createContext" @module("react") -external forwardRef: (('props, Js.Nullable.t>) => element) => component<'props> = - "forwardRef" +external forwardRef: (('props, nullable>) => element) => component<'props> = "forwardRef" @module("react") external memo: component<'props> => component<'props> = "memo" @@ -222,51 +221,42 @@ external useContext: Context.t<'any> => 'any = "useContext" @module("react") external useRef: 'value => Ref.t<'value> = "useRef" @module("react") -external useImperativeHandle0: ( - Js.Nullable.t>, - unit => 'value, - @as(json`[]`) _, -) => unit = "useImperativeHandle" +external useImperativeHandle0: (nullable>, unit => 'value, @as(json`[]`) _) => unit = + "useImperativeHandle" @module("react") -external useImperativeHandle1: (Js.Nullable.t>, unit => 'value, array<'a>) => unit = +external useImperativeHandle1: (nullable>, unit => 'value, array<'a>) => unit = "useImperativeHandle" @module("react") -external useImperativeHandle2: (Js.Nullable.t>, unit => 'value, ('a, 'b)) => unit = +external useImperativeHandle2: (nullable>, unit => 'value, ('a, 'b)) => unit = "useImperativeHandle" @module("react") -external useImperativeHandle3: ( - Js.Nullable.t>, - unit => 'value, - ('a, 'b, 'c), -) => unit = "useImperativeHandle" +external useImperativeHandle3: (nullable>, unit => 'value, ('a, 'b, 'c)) => unit = + "useImperativeHandle" @module("react") -external useImperativeHandle4: ( - Js.Nullable.t>, - unit => 'value, - ('a, 'b, 'c, 'd), -) => unit = "useImperativeHandle" +external useImperativeHandle4: (nullable>, unit => 'value, ('a, 'b, 'c, 'd)) => unit = + "useImperativeHandle" @module("react") external useImperativeHandle5: ( - Js.Nullable.t>, + nullable>, unit => 'value, ('a, 'b, 'c, 'd, 'e), ) => unit = "useImperativeHandle" @module("react") external useImperativeHandle6: ( - Js.Nullable.t>, + nullable>, unit => 'value, ('a, 'b, 'c, 'd, 'e, 'f), ) => unit = "useImperativeHandle" @module("react") external useImperativeHandle7: ( - Js.Nullable.t>, + nullable>, unit => 'value, ('a, 'b, 'c, 'd, 'e, 'f, 'g), ) => unit = "useImperativeHandle" diff --git a/tests/build_tests/source_map/input.js b/tests/build_tests/source_map/input.js index 65734dc2db9..666284d51a5 100644 --- a/tests/build_tests/source_map/input.js +++ b/tests/build_tests/source_map/input.js @@ -124,7 +124,7 @@ const originalDebuggerPositions = findTokenPositions(demoSource, "%debugger"); assert.equal(originalDebuggerPositions.length, 2); const originalRaiseErrorPositions = findTokenPositions( demoSource, - "Js.Exn.raiseError", + "Exn.raiseError", ); assert.equal(originalRaiseErrorPositions.length, 2); const originalPipeCallPositions = findTokenPositions(demoSource, "input->fn"); @@ -135,7 +135,7 @@ const originalPatternBranchPositions = [ ]; const originalHelperRaiseErrorPositions = findTokenPositions( helperSource, - "Js.Exn.raiseError", + "Exn.raiseError", ); assert.equal(originalHelperRaiseErrorPositions.length, 1); const originalHelperPipeCallPositions = findTokenPositions( diff --git a/tests/build_tests/source_map/src/Demo.res b/tests/build_tests/source_map/src/Demo.res index 95958650a5e..b8ba45ea21d 100644 --- a/tests/build_tests/source_map/src/Demo.res +++ b/tests/build_tests/source_map/src/Demo.res @@ -7,7 +7,7 @@ type item = | Single(int) | Pair(int, int) -let crash = () => Js.Exn.raiseError("source map test") +let crash = () => Exn.raiseError("source map test") let debugStatement = () => { %debugger @@ -33,6 +33,6 @@ let describeItem = item => let unicodeMessage = "한글 ðŸŒ" -let unicodeCrash = () => Js.Exn.raiseError(unicodeMessage) +let unicodeCrash = () => Exn.raiseError(unicodeMessage) let value = add(pipedValue, 22) diff --git a/tests/build_tests/source_map/src/Helper.res b/tests/build_tests/source_map/src/Helper.res index 86bd75e642c..217bca9ea9a 100644 --- a/tests/build_tests/source_map/src/Helper.res +++ b/tests/build_tests/source_map/src/Helper.res @@ -15,6 +15,6 @@ let describe = payload => let unicodeLabel = "helper 한글 ðŸŒ" -let fail = () => Js.Exn.raiseError("helper source map") +let fail = () => Exn.raiseError("helper source map") let value = pipeThrough(21, multiply) diff --git a/tests/build_tests/super_errors/expected/deprecated_with_automigration.res.expected b/tests/build_tests/super_errors/expected/deprecated_with_automigration.res.expected index 8b4971c02ab..a905b528b7b 100644 --- a/tests/build_tests/super_errors/expected/deprecated_with_automigration.res.expected +++ b/tests/build_tests/super_errors/expected/deprecated_with_automigration.res.expected @@ -1,11 +1,13 @@ Warning number 3 - /.../fixtures/deprecated_with_automigration.res:1:9-21 + /.../fixtures/deprecated_with_automigration.res:2:13-23 - 1 │ let _ = Js.Array2.map([1, 2], v => v + 1) - 2 │ + 1 │ let values = list{1, 2} + 2 │ let first = List.getExn(values, 0) + 3 │ let incremented = first + 1 + 4 │ let _ = incremented - deprecated: Js.Array2.map - Use `Array.map` instead. + deprecated: Stdlib.List.getExn + Use `getOrThrow` instead This can be automatically migrated by the ReScript migration tool. Run `rescript-tools migrate-all ` to run all automatic migrations available in your project, or `rescript-tools migrate ` to migrate a single file. \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/dict_magic_field_on_non_dict.res.expected b/tests/build_tests/super_errors/expected/dict_magic_field_on_non_dict.res.expected index 05d88219c2a..3a8d4af497c 100644 --- a/tests/build_tests/super_errors/expected/dict_magic_field_on_non_dict.res.expected +++ b/tests/build_tests/super_errors/expected/dict_magic_field_on_non_dict.res.expected @@ -4,8 +4,8 @@ 3 │ let foo = (fakeDict: fakeDict<'a>) => { 4 │ switch fakeDict { - 5 │ | {someUndefinedField: 1} => Js.log("one") - 6 │ | _ => Js.log("not one") + 5 │ | {someUndefinedField: 1} => Console.log("one") + 6 │ | _ => Console.log("not one") 7 │ } The field someUndefinedField does not belong to type fakeDict diff --git a/tests/build_tests/super_errors/expected/dict_pattern_inference.res.expected b/tests/build_tests/super_errors/expected/dict_pattern_inference.res.expected index eb2a546da95..0684eb69178 100644 --- a/tests/build_tests/super_errors/expected/dict_pattern_inference.res.expected +++ b/tests/build_tests/super_errors/expected/dict_pattern_inference.res.expected @@ -4,8 +4,8 @@ 1 │ let foo = dict => 2 │ switch dict { - 3 │ | dict{"one": 1, "two": "hello"} => Js.log("one") - 4 │ | _ => Js.log("not one") + 3 │ | dict{"one": 1, "two": "hello"} => Console.log("one") + 4 │ | _ => Console.log("not one") 5 │ } This pattern matches values of type string diff --git a/tests/build_tests/super_errors/expected/dict_pattern_inference_constrained.res.expected b/tests/build_tests/super_errors/expected/dict_pattern_inference_constrained.res.expected index 7263287dfbd..962646e6f92 100644 --- a/tests/build_tests/super_errors/expected/dict_pattern_inference_constrained.res.expected +++ b/tests/build_tests/super_errors/expected/dict_pattern_inference_constrained.res.expected @@ -5,8 +5,8 @@ 2 ┆ switch dict { 3 ┆ | dict{"one": 1} => 4 ┆ let _: dict = dict - 5 ┆ Js.log("one") - 6 ┆ | _ => Js.log("not one") + 5 ┆ Console.log("one") + 6 ┆ | _ => Console.log("not one") This has type: dict But it's expected to have type: dict diff --git a/tests/build_tests/super_errors/expected/dict_pattern_regular_record.res.expected b/tests/build_tests/super_errors/expected/dict_pattern_regular_record.res.expected index 69b1bb9e153..3ddb62c1220 100644 --- a/tests/build_tests/super_errors/expected/dict_pattern_regular_record.res.expected +++ b/tests/build_tests/super_errors/expected/dict_pattern_regular_record.res.expected @@ -4,8 +4,8 @@ 3 │ let constrainedAsDict = (dict: x) => 4 │ switch dict { - 5 │ | dict{"one": "one"} => Js.log("one") - 6 │ | _ => Js.log("not one") + 5 │ | dict{"one": "one"} => Console.log("one") + 6 │ | _ => Console.log("not one") 7 │ } This pattern matches values of type dict diff --git a/tests/build_tests/super_errors/expected/react_component_with_props.res.expected b/tests/build_tests/super_errors/expected/react_component_with_props.res.expected index ea08c175f29..880e2e17a78 100644 --- a/tests/build_tests/super_errors/expected/react_component_with_props.res.expected +++ b/tests/build_tests/super_errors/expected/react_component_with_props.res.expected @@ -1,15 +1,16 @@ We've found a bug for you! - /.../fixtures/react_component_with_props.res:3:31-13:10 + /.../fixtures/react_component_with_props.res:3:31-9:10 1 │ module V4C7 = { 2 │ @react.componentWithProps - 3 │ let make = React.forwardRef(( - 4 │  ~className=?, + 3 │ let make = React.forwardRef((~className=?, ~children, ref: nullable) => + 4 │ 
 . │ ... - 12 │  children - 13 │ 
 - 14 │ ) - 15 │ } + 8 │  children + 9 │ 
 + 10 │ ) + 11 │ } Components using React.forwardRef cannot use @react.componentWithProps. Use @react.component instead. \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/variant_pattern_type_spreads_not_subtype.res.expected b/tests/build_tests/super_errors/expected/variant_pattern_type_spreads_not_subtype.res.expected index deb18a1a629..48c8eaf690e 100644 --- a/tests/build_tests/super_errors/expected/variant_pattern_type_spreads_not_subtype.res.expected +++ b/tests/build_tests/super_errors/expected/variant_pattern_type_spreads_not_subtype.res.expected @@ -4,8 +4,8 @@ 5 │ let lookup = (b: b) => 6 │ switch b { - 7 │ | ...c as c => Js.log(c) - 8 │ | Four => Js.log("four") - 9 │ | Five => Js.log("five") + 7 │ | ...c as c => Console.log(c) + 8 │ | Four => Console.log("four") + 9 │ | Five => Console.log("five") Type c is not a subtype of b \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/variant_pattern_type_spreads_not_variant.res.expected b/tests/build_tests/super_errors/expected/variant_pattern_type_spreads_not_variant.res.expected index ac3ad7103cb..33b9d6690cd 100644 --- a/tests/build_tests/super_errors/expected/variant_pattern_type_spreads_not_variant.res.expected +++ b/tests/build_tests/super_errors/expected/variant_pattern_type_spreads_not_variant.res.expected @@ -4,9 +4,9 @@ 5 │ let lookup = (b: b) => 6 │ switch b { - 7 │ | ...c as c => Js.log(c) - 8 │ | Four => Js.log("four") - 9 │ | Five => Js.log("five") + 7 │ | ...c as c => Console.log(c) + 8 │ | Four => Console.log("four") + 9 │ | Five => Console.log("five") The type c is not a variant type \ No newline at end of file diff --git a/tests/build_tests/super_errors/fixtures/deprecated_with_automigration.res b/tests/build_tests/super_errors/fixtures/deprecated_with_automigration.res index ae70045279b..959937879dd 100644 --- a/tests/build_tests/super_errors/fixtures/deprecated_with_automigration.res +++ b/tests/build_tests/super_errors/fixtures/deprecated_with_automigration.res @@ -1 +1,4 @@ -let _ = Js.Array2.map([1, 2], v => v + 1) +let values = list{1, 2} +let first = List.getExn(values, 0) +let incremented = first + 1 +let _ = incremented diff --git a/tests/build_tests/super_errors/fixtures/dict_magic_field_on_non_dict.res b/tests/build_tests/super_errors/fixtures/dict_magic_field_on_non_dict.res index 5f3e9785896..486c90adc2d 100644 --- a/tests/build_tests/super_errors/fixtures/dict_magic_field_on_non_dict.res +++ b/tests/build_tests/super_errors/fixtures/dict_magic_field_on_non_dict.res @@ -2,7 +2,7 @@ type fakeDict<'t> = {dictValuesType?: 't} let foo = (fakeDict: fakeDict<'a>) => { switch fakeDict { - | {someUndefinedField: 1} => Js.log("one") - | _ => Js.log("not one") + | {someUndefinedField: 1} => Console.log("one") + | _ => Console.log("not one") } } diff --git a/tests/build_tests/super_errors/fixtures/dict_pattern_inference.res b/tests/build_tests/super_errors/fixtures/dict_pattern_inference.res index b2b9e66b349..7d193de4769 100644 --- a/tests/build_tests/super_errors/fixtures/dict_pattern_inference.res +++ b/tests/build_tests/super_errors/fixtures/dict_pattern_inference.res @@ -1,5 +1,5 @@ let foo = dict => switch dict { - | dict{"one": 1, "two": "hello"} => Js.log("one") - | _ => Js.log("not one") + | dict{"one": 1, "two": "hello"} => Console.log("one") + | _ => Console.log("not one") } diff --git a/tests/build_tests/super_errors/fixtures/dict_pattern_inference_constrained.res b/tests/build_tests/super_errors/fixtures/dict_pattern_inference_constrained.res index 36b315487ec..c22fc0a8c10 100644 --- a/tests/build_tests/super_errors/fixtures/dict_pattern_inference_constrained.res +++ b/tests/build_tests/super_errors/fixtures/dict_pattern_inference_constrained.res @@ -2,6 +2,6 @@ let foo = dict => switch dict { | dict{"one": 1} => let _: dict = dict - Js.log("one") - | _ => Js.log("not one") + Console.log("one") + | _ => Console.log("not one") } diff --git a/tests/build_tests/super_errors/fixtures/dict_pattern_regular_record.res b/tests/build_tests/super_errors/fixtures/dict_pattern_regular_record.res index c5caecc4893..ad1dfd37edb 100644 --- a/tests/build_tests/super_errors/fixtures/dict_pattern_regular_record.res +++ b/tests/build_tests/super_errors/fixtures/dict_pattern_regular_record.res @@ -2,6 +2,6 @@ type x = {one: int} let constrainedAsDict = (dict: x) => switch dict { - | dict{"one": "one"} => Js.log("one") - | _ => Js.log("not one") + | dict{"one": "one"} => Console.log("one") + | _ => Console.log("not one") } diff --git a/tests/build_tests/super_errors/fixtures/react_component_with_props.res b/tests/build_tests/super_errors/fixtures/react_component_with_props.res index 29ca3b301b9..a910ad36016 100644 --- a/tests/build_tests/super_errors/fixtures/react_component_with_props.res +++ b/tests/build_tests/super_errors/fixtures/react_component_with_props.res @@ -1,13 +1,9 @@ module V4C7 = { @react.componentWithProps - let make = React.forwardRef(( - ~className=?, - ~children, - ref: Js.Nullable.t, - ) => + let make = React.forwardRef((~className=?, ~children, ref: nullable) =>
Belt.Option.map(React.Ref.domRef)} + type_="text" ?className ref=?{Nullable.toOption(ref)->Belt.Option.map(React.Ref.domRef)} /> children
diff --git a/tests/build_tests/super_errors/fixtures/variant_pattern_type_spreads_not_subtype.res b/tests/build_tests/super_errors/fixtures/variant_pattern_type_spreads_not_subtype.res index f29def3d0ff..88d56ad1300 100644 --- a/tests/build_tests/super_errors/fixtures/variant_pattern_type_spreads_not_subtype.res +++ b/tests/build_tests/super_errors/fixtures/variant_pattern_type_spreads_not_subtype.res @@ -4,7 +4,7 @@ type c = Six | Seven let lookup = (b: b) => switch b { - | ...c as c => Js.log(c) - | Four => Js.log("four") - | Five => Js.log("five") + | ...c as c => Console.log(c) + | Four => Console.log("four") + | Five => Console.log("five") } diff --git a/tests/build_tests/super_errors/fixtures/variant_pattern_type_spreads_not_variant.res b/tests/build_tests/super_errors/fixtures/variant_pattern_type_spreads_not_variant.res index 2eac5761379..e57c5c473c3 100644 --- a/tests/build_tests/super_errors/fixtures/variant_pattern_type_spreads_not_variant.res +++ b/tests/build_tests/super_errors/fixtures/variant_pattern_type_spreads_not_variant.res @@ -4,7 +4,7 @@ type c = {name: string} let lookup = (b: b) => switch b { - | ...c as c => Js.log(c) - | Four => Js.log("four") - | Five => Js.log("five") + | ...c as c => Console.log(c) + | Four => Console.log("four") + | Five => Console.log("five") } diff --git a/tests/build_tests/transitive_dependency/node_modules/b/src/src.res b/tests/build_tests/transitive_dependency/node_modules/b/src/src.res index 95733e46aff..f9030b0b7fc 100644 --- a/tests/build_tests/transitive_dependency/node_modules/b/src/src.res +++ b/tests/build_tests/transitive_dependency/node_modules/b/src/src.res @@ -1 +1 @@ -Js.Console.log("src") +Console.log("src") diff --git a/tests/build_tests/transitive_dependency/node_modules/b/tests/test.res b/tests/build_tests/transitive_dependency/node_modules/b/tests/test.res index aa7a48d65d5..6b797705d41 100644 --- a/tests/build_tests/transitive_dependency/node_modules/b/tests/test.res +++ b/tests/build_tests/transitive_dependency/node_modules/b/tests/test.res @@ -1 +1 @@ -Js.Console.log("test") +Console.log("test") diff --git a/tests/build_tests/transitive_dependency/node_modules/c/src/src.res b/tests/build_tests/transitive_dependency/node_modules/c/src/src.res index 95733e46aff..f9030b0b7fc 100644 --- a/tests/build_tests/transitive_dependency/node_modules/c/src/src.res +++ b/tests/build_tests/transitive_dependency/node_modules/c/src/src.res @@ -1 +1 @@ -Js.Console.log("src") +Console.log("src") diff --git a/tests/build_tests/transitive_dependency/node_modules/c/tests/test.res b/tests/build_tests/transitive_dependency/node_modules/c/tests/test.res index aa7a48d65d5..6b797705d41 100644 --- a/tests/build_tests/transitive_dependency/node_modules/c/tests/test.res +++ b/tests/build_tests/transitive_dependency/node_modules/c/tests/test.res @@ -1 +1 @@ -Js.Console.log("test") +Console.log("test") diff --git a/tests/build_tests/uncurried-always/src/UncurriedAlways.res b/tests/build_tests/uncurried-always/src/UncurriedAlways.res index 01f9d2ee16d..222160cda1a 100644 --- a/tests/build_tests/uncurried-always/src/UncurriedAlways.res +++ b/tests/build_tests/uncurried-always/src/UncurriedAlways.res @@ -10,6 +10,6 @@ let w = 3->foo(4) let a = 3->foo(4) -Js.log(a) // Test automatic uncurried application +Console.log(a) // Test automatic uncurried application -let _ = Js.Array2.map([1], x => x + 1) +let _ = Array.map([1], x => x + 1) diff --git a/tests/build_tests/warn_legacy_config/src/demo.res b/tests/build_tests/warn_legacy_config/src/demo.res index 8d0b19151fc..3bfb9a1da21 100644 --- a/tests/build_tests/warn_legacy_config/src/demo.res +++ b/tests/build_tests/warn_legacy_config/src/demo.res @@ -1 +1 @@ -let () = Js.log("Hello, ReScript") +let () = Console.log("Hello, ReScript") diff --git a/tests/build_tests/weird_deps/src/demo.res b/tests/build_tests/weird_deps/src/demo.res index 8d0b19151fc..3bfb9a1da21 100644 --- a/tests/build_tests/weird_deps/src/demo.res +++ b/tests/build_tests/weird_deps/src/demo.res @@ -1 +1 @@ -let () = Js.log("Hello, ReScript") +let () = Console.log("Hello, ReScript") diff --git a/tests/build_tests/weird_devdeps/src/demo.res b/tests/build_tests/weird_devdeps/src/demo.res index 8d0b19151fc..3bfb9a1da21 100644 --- a/tests/build_tests/weird_devdeps/src/demo.res +++ b/tests/build_tests/weird_devdeps/src/demo.res @@ -1 +1 @@ -let () = Js.log("Hello, ReScript") +let () = Console.log("Hello, ReScript") diff --git a/tests/build_tests/x-y/x-src/demo.res b/tests/build_tests/x-y/x-src/demo.res index 8d0b19151fc..3bfb9a1da21 100644 --- a/tests/build_tests/x-y/x-src/demo.res +++ b/tests/build_tests/x-y/x-src/demo.res @@ -1 +1 @@ -let () = Js.log("Hello, ReScript") +let () = Console.log("Hello, ReScript") diff --git a/tests/dependencies/rescript-react/src/ReactTestUtils.res b/tests/dependencies/rescript-react/src/ReactTestUtils.res index 3b92614fddc..0df04fe6ad2 100644 --- a/tests/dependencies/rescript-react/src/ReactTestUtils.res +++ b/tests/dependencies/rescript-react/src/ReactTestUtils.res @@ -1,14 +1,10 @@ -type undefined = nullable - -let undefined: undefined = Nullable.undefined - @module("react-dom/test-utils") -external reactAct: (unit => undefined) => unit = "act" +external reactAct: (unit => option) => unit = "act" let act: (unit => unit) => unit = func => { let reactFunc = () => { func() - undefined + None } reactAct(reactFunc) } diff --git a/tests/docstring_tests/Node.res b/tests/docstring_tests/Node.res index 276b4ed88b3..bcdd75c2b4e 100644 --- a/tests/docstring_tests/Node.res +++ b/tests/docstring_tests/Node.res @@ -35,8 +35,7 @@ module ChildProcess = { @send external on: (readable, string, Buffer.t => unit) => unit = "on" @send - external once: (spawnReturns, string, (Js.Null.t, Js.Null.t) => unit) => unit = - "once" + external once: (spawnReturns, string, (Null.t, Null.t) => unit) => unit = "once" type execSyncOptions = {maxBuffer?: float} @module("child_process") external execSync: (string, ~options: execSyncOptions=?) => Buffer.t = "execSync" diff --git a/tests/gentype_tests/typescript-react-example/src/Core.gen.tsx b/tests/gentype_tests/typescript-react-example/src/Core.gen.tsx index bf672b5e238..113efbfacaa 100644 --- a/tests/gentype_tests/typescript-react-example/src/Core.gen.tsx +++ b/tests/gentype_tests/typescript-react-example/src/Core.gen.tsx @@ -37,8 +37,6 @@ export const nullable1: (x:(null | undefined | number)) => (null | undefined | n export const undefined0: (x:(undefined | number)) => (undefined | number) = CoreJS.undefined0 as any; -export const undefined1: (x:(undefined | number)) => (undefined | number) = CoreJS.undefined1 as any; - export const dict0: (x:{[id: string]: string}) => {[id: string]: string} = CoreJS.dict0 as any; export const dict1: (x:{[id: string]: string}) => {[id: string]: string} = CoreJS.dict1 as any; @@ -51,16 +49,16 @@ export const taggedTemplate0: (x:((strings:TemplateStringsArray, ...values:strin export const taggedTemplate1: (x:((strings:TemplateStringsArray, ...values:string[]) => string)) => (strings:TemplateStringsArray, ...values:string[]) => string = CoreJS.taggedTemplate1 as any; -export const date0: (x:Date) => Date = CoreJS.date0 as any; - export const date1: (x:Date) => Date = CoreJS.date1 as any; export const bigint0: (x:bigint) => bigint = CoreJS.bigint0 as any; -export const regexp0: (x:RegExp) => RegExp = CoreJS.regexp0 as any; +export const stdlibBigInt: (x:bigint) => bigint = CoreJS.stdlibBigInt as any; export const regexp1: (x:RegExp) => RegExp = CoreJS.regexp1 as any; +export const stdlibArray: (x:number[]) => number[] = CoreJS.stdlibArray as any; + export const map1: (x:Map) => Map = CoreJS.map1 as any; export const weakmap1: (x:WeakMap) => WeakMap = CoreJS.weakmap1 as any; diff --git a/tests/gentype_tests/typescript-react-example/src/Core.res b/tests/gentype_tests/typescript-react-example/src/Core.res index 16fe0cb7797..7f48f22459e 100644 --- a/tests/gentype_tests/typescript-react-example/src/Core.res +++ b/tests/gentype_tests/typescript-react-example/src/Core.res @@ -1,20 +1,17 @@ @genType -let null0 = (x: Js.null) => x +let null0 = (x: null) => x @genType let null1 = (x: Null.t) => x @genType -let nullable0 = (x: Js.nullable) => x +let nullable0 = (x: nullable) => x @genType let nullable1 = (x: Nullable.t) => x @genType -let undefined0 = (x: Js.undefined) => x - -@genType -let undefined1 = (x: Undefined.t) => x +let undefined0 = (x: undefined) => x @genType let dict0 = (x: dict) => x @@ -34,9 +31,6 @@ let taggedTemplate0 = (x: taggedTemplate) => x @genType let taggedTemplate1 = (x: TaggedTemplate.t) => x -@genType -let date0 = (x: Js.Date.t) => x - @genType let date1 = (x: Date.t) => x @@ -44,11 +38,14 @@ let date1 = (x: Date.t) => x let bigint0 = (x: bigint) => x @genType -let regexp0 = (x: Js.Re.t) => x +let stdlibBigInt = (x: Stdlib.BigInt.t) => x @genType let regexp1 = (x: RegExp.t) => x +@genType +let stdlibArray = (x: Stdlib.Array.t) => x + module Map = Map_ module Set = Set_ @@ -76,7 +73,7 @@ let option1 = (x: option) => x type t1 = {x?: string} @genType -type t2 = {x: Js.undefined} +type t2 = {x: undefined} @genType.import("./CoreTS") external someFunWithNullThenOptionalArgs: ( diff --git a/tests/gentype_tests/typescript-react-example/src/Core.res.js b/tests/gentype_tests/typescript-react-example/src/Core.res.js index 6d21492479e..67291b187b7 100644 --- a/tests/gentype_tests/typescript-react-example/src/Core.res.js +++ b/tests/gentype_tests/typescript-react-example/src/Core.res.js @@ -22,10 +22,6 @@ function undefined0(x) { return x; } -function undefined1(x) { - return x; -} - function dict0(x) { return x; } @@ -50,10 +46,6 @@ function taggedTemplate1(x) { return x; } -function date0(x) { - return x; -} - function date1(x) { return x; } @@ -62,7 +54,7 @@ function bigint0(x) { return x; } -function regexp0(x) { +function stdlibBigInt(x) { return x; } @@ -70,6 +62,10 @@ function regexp1(x) { return x; } +function stdlibArray(x) { + return x; +} + function map1(x) { return x; } @@ -116,18 +112,17 @@ export { nullable0, nullable1, undefined0, - undefined1, dict0, dict1, promise0, promise1, taggedTemplate0, taggedTemplate1, - date0, date1, bigint0, - regexp0, + stdlibBigInt, regexp1, + stdlibArray, $$Map, $$Set, map1, diff --git a/tests/gentype_tests/typescript-react-example/src/Date.res b/tests/gentype_tests/typescript-react-example/src/Date.res index 9cee890bbce..613500307a2 100644 --- a/tests/gentype_tests/typescript-react-example/src/Date.res +++ b/tests/gentype_tests/typescript-react-example/src/Date.res @@ -1 +1 @@ -type t = Js.Date.t +type t = Date.t diff --git a/tests/gentype_tests/typescript-react-example/src/EmitModuleIfNoConversion.res b/tests/gentype_tests/typescript-react-example/src/EmitModuleIfNoConversion.res index 7d74a6ed1d5..3efaca0b8e2 100644 --- a/tests/gentype_tests/typescript-react-example/src/EmitModuleIfNoConversion.res +++ b/tests/gentype_tests/typescript-react-example/src/EmitModuleIfNoConversion.res @@ -8,8 +8,8 @@ module X = { @genType let foo = (t: t) => switch t { - | A => Js.log("A") - | B({name}) => Js.log("B" ++ name) + | A => Console.log("A") + | B({name}) => Console.log("B" ++ name) } @genType let x = 42 diff --git a/tests/gentype_tests/typescript-react-example/src/Hooks.gen.tsx b/tests/gentype_tests/typescript-react-example/src/Hooks.gen.tsx index da76a0edfcd..7bf4cc30e11 100644 --- a/tests/gentype_tests/typescript-react-example/src/Hooks.gen.tsx +++ b/tests/gentype_tests/typescript-react-example/src/Hooks.gen.tsx @@ -5,8 +5,6 @@ import * as HooksJS from './Hooks.res.js'; -import type {TypedArray2_Uint8Array_t as Js_TypedArray2_Uint8Array_t} from '../src/shims/Js.shim'; - export type vehicle = { readonly name: string }; export type props = { readonly vehicle: vehicle }; @@ -91,7 +89,7 @@ export const RenderPropRequiresConversion_make: React.ComponentType<{ readonly r export const WithChildren_aComponentWithChildren: React.ComponentType<{ readonly vehicle: vehicle; readonly children: React.ReactNode }> = HooksJS.WithChildren.aComponentWithChildren as any; -export const DD_make: React.ComponentType<{ readonly array: Js_TypedArray2_Uint8Array_t; readonly name: string }> = HooksJS.DD.make as any; +export const DD_make: React.ComponentType<{ readonly array: Uint8Array; readonly name: string }> = HooksJS.DD.make as any; export const NoProps: { make: React.ComponentType<{}> } = HooksJS.NoProps as any; @@ -132,7 +130,7 @@ export const WithRef: { make: React.ComponentType<{ readonly vehicle: vehicle; r export const WithChildren: { aComponentWithChildren: React.ComponentType<{ readonly vehicle: vehicle; readonly children: React.ReactNode }> } = HooksJS.WithChildren as any; -export const DD: { make: React.ComponentType<{ readonly array: Js_TypedArray2_Uint8Array_t; readonly name: string }> } = HooksJS.DD as any; +export const DD: { make: React.ComponentType<{ readonly array: Uint8Array; readonly name: string }> } = HooksJS.DD as any; export const Another: { anotherComponent: React.ComponentType<{ readonly vehicle: vehicle; readonly callback: () => void }> } = HooksJS.Another as any; diff --git a/tests/gentype_tests/typescript-react-example/src/Hooks.res b/tests/gentype_tests/typescript-react-example/src/Hooks.res index a8bcf090a0d..b4547789834 100644 --- a/tests/gentype_tests/typescript-react-example/src/Hooks.res +++ b/tests/gentype_tests/typescript-react-example/src/Hooks.res @@ -87,7 +87,7 @@ module WithRef = { @genType @react.component let make = React.forwardRef((~vehicle, ref) => { let _ = 34 - switch ref->Js.Nullable.toOption { + switch ref->Stdlib.Nullable.toOption { | Some(ref) => | None => React.null } @@ -140,5 +140,5 @@ module WithChildren = { module DD = { @genType @react.component - let make = (~array as _: Js.TypedArray2.Uint8Array.t, ~name: string) => React.string(name) + let make = (~array as _: Stdlib.Uint8Array.t, ~name: string) => React.string(name) } diff --git a/tests/gentype_tests/typescript-react-example/src/ImmutableArray.resi b/tests/gentype_tests/typescript-react-example/src/ImmutableArray.resi index 6616546510e..7f10215dee6 100644 --- a/tests/gentype_tests/typescript-react-example/src/ImmutableArray.resi +++ b/tests/gentype_tests/typescript-react-example/src/ImmutableArray.resi @@ -26,7 +26,7 @@ let shuffle: t<'a> => t<'a> let reverse: t<'a> => t<'a> -let makeUninitialized: int => t> +let makeUninitialized: int => t> let makeUninitializedUnsafe: int => t<'a> diff --git a/tests/gentype_tests/typescript-react-example/src/Null.res b/tests/gentype_tests/typescript-react-example/src/Null.res index fff00a9895f..e75477c1ebe 100644 --- a/tests/gentype_tests/typescript-react-example/src/Null.res +++ b/tests/gentype_tests/typescript-react-example/src/Null.res @@ -1 +1 @@ -type t<'a> = Js.null<'a> +type t<'a> = null<'a> diff --git a/tests/gentype_tests/typescript-react-example/src/Nullable.res b/tests/gentype_tests/typescript-react-example/src/Nullable.res index 56a19212cef..65885bd9cd3 100644 --- a/tests/gentype_tests/typescript-react-example/src/Nullable.res +++ b/tests/gentype_tests/typescript-react-example/src/Nullable.res @@ -1 +1 @@ -type t<'a> = Js.nullable<'a> +type t<'a> = nullable<'a> diff --git a/tests/gentype_tests/typescript-react-example/src/Records.res b/tests/gentype_tests/typescript-react-example/src/Records.res index c8485e092e3..7d43e291892 100644 --- a/tests/gentype_tests/typescript-react-example/src/Records.res +++ b/tests/gentype_tests/typescript-react-example/src/Records.res @@ -81,24 +81,24 @@ let getPayloadRecordPlusOne = ({payload}): record => { @genType type business2 = { name: string, - owner: Js.Nullable.t, - address2: Js.Nullable.t, + owner: nullable, + address2: nullable, } @genType let findAddress2 = (business: business2): list => - business.address2->Js.Nullable.toOption->getOpt(list{}, a => list{a}) + business.address2->Stdlib.Nullable.toOption->getOpt(list{}, a => list{a}) @genType let someBusiness2 = { name: "SomeBusiness", - owner: Js.Nullable.null, - address2: Js.Nullable.null, + owner: Stdlib.Nullable.null, + address2: Stdlib.Nullable.null, } @genType -let computeArea3 = (o: {"x": int, "y": int, "z": Js.Nullable.t}) => - o["x"] * o["y"] * o["z"]->Js.Nullable.toOption->Option.mapWithDefault(1, n => n) +let computeArea3 = (o: {"x": int, "y": int, "z": nullable}) => + o["x"] * o["y"] * o["z"]->Stdlib.Nullable.toOption->Option.mapWithDefault(1, n => n) @genType let computeArea4 = (o: {"x": int, "y": int, "z": option}) => diff --git a/tests/gentype_tests/typescript-react-example/src/RegExp.res b/tests/gentype_tests/typescript-react-example/src/RegExp.res index afd4e13e6fd..9a0fda71b4f 100644 --- a/tests/gentype_tests/typescript-react-example/src/RegExp.res +++ b/tests/gentype_tests/typescript-react-example/src/RegExp.res @@ -1 +1 @@ -type t = Js.Re.t +type t = RegExp.t diff --git a/tests/gentype_tests/typescript-react-example/src/RequireCond.res b/tests/gentype_tests/typescript-react-example/src/RequireCond.res index b7fdd67a36c..5dd78b97780 100644 --- a/tests/gentype_tests/typescript-react-example/src/RequireCond.res +++ b/tests/gentype_tests/typescript-react-example/src/RequireCond.res @@ -2,11 +2,8 @@ @deprecated( "Please use this syntax to guarantee safe usage: [%requireCond(`gk, \"gk_name\", ConditionalModule)]" ) -external make: ( - @string [@as("qe.bool") #qeBool | @as("gk") #gk], - string, - string, -) => Js.Nullable.t<'a> = "requireCond" +external make: (@string [@as("qe.bool") #qeBool | @as("gk") #gk], string, string) => nullable<'a> = + "requireCond" @module @deprecated( diff --git a/tests/gentype_tests/typescript-react-example/src/TestPromise.res b/tests/gentype_tests/typescript-react-example/src/TestPromise.res index 80c84d3b480..ae77db99d69 100644 --- a/tests/gentype_tests/typescript-react-example/src/TestPromise.res +++ b/tests/gentype_tests/typescript-react-example/src/TestPromise.res @@ -1,4 +1,4 @@ -@genType type promise<'a> = Js.Promise.t<'a> +@genType type promise<'a> = Promise.t<'a> @genType type fromPayload = { @@ -8,6 +8,6 @@ type fromPayload = { @genType type toPayload = {result: string} -@genType let convert = p => Js.Promise.then_(({s}) => Js.Promise.resolve({result: s}), p) +@genType let convert = p => Promise.then(p, ({s}) => Promise.resolve({result: s})) -@genType let barx = (~x=Js.Promise.resolve(Some("a")), ()) => x == x +@genType let barx = (~x=Promise.resolve(Some("a")), ()) => x == x diff --git a/tests/gentype_tests/typescript-react-example/src/TestPromise.res.js b/tests/gentype_tests/typescript-react-example/src/TestPromise.res.js index a1cd18e8ebc..627f19f2aa9 100644 --- a/tests/gentype_tests/typescript-react-example/src/TestPromise.res.js +++ b/tests/gentype_tests/typescript-react-example/src/TestPromise.res.js @@ -1,12 +1,11 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Js_promise from "@rescript/runtime/lib/es6/Js_promise.mjs"; import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.mjs"; function convert(p) { - return Js_promise.then_(param => Promise.resolve({ + return p.then(param => Promise.resolve({ result: param.s - }), p); + })); } function barx(xOpt, param) { diff --git a/tests/gentype_tests/typescript-react-example/src/Uncurried.res b/tests/gentype_tests/typescript-react-example/src/Uncurried.res index 8de34f67d9b..73b83f9acdc 100644 --- a/tests/gentype_tests/typescript-react-example/src/Uncurried.res +++ b/tests/gentype_tests/typescript-react-example/src/Uncurried.res @@ -25,18 +25,18 @@ type authU = {loginU: unit => string} @genType let callback2U = auth => auth.loginU() -@genType let sumU = (n, m) => Js.log4("sumU 2nd arg", m, "result", n + m) +@genType let sumU = (n, m) => Console.log4("sumU 2nd arg", m, "result", n + m) -@genType let sumU2 = n => m => Js.log4("sumU2 2nd arg", m, "result", n + m) +@genType let sumU2 = n => m => Console.log4("sumU2 2nd arg", m, "result", n + m) @genType let sumCurried = n => { - Js.log2("sumCurried 1st arg", n) - m => Js.log4("sumCurried 2nd arg", m, "result", n + m) + Console.log2("sumCurried 1st arg", n) + m => Console.log4("sumCurried 2nd arg", m, "result", n + m) } @genType let sumLblCurried = (s: string, ~n) => { - Js.log3(s, "sumLblCurried 1st arg", n) - (~m) => Js.log4("sumLblCurried 2nd arg", m, "result", n + m) + Console.log3(s, "sumLblCurried 1st arg", n) + (~m) => Console.log4("sumLblCurried 2nd arg", m, "result", n + m) } diff --git a/tests/gentype_tests/typescript-react-example/src/Undefined.res b/tests/gentype_tests/typescript-react-example/src/Undefined.res deleted file mode 100644 index 5c2e5dc3dec..00000000000 --- a/tests/gentype_tests/typescript-react-example/src/Undefined.res +++ /dev/null @@ -1 +0,0 @@ -type t<'a> = Js.undefined<'a> diff --git a/tests/gentype_tests/typescript-react-example/src/Undefined.res.js b/tests/gentype_tests/typescript-react-example/src/Undefined.res.js deleted file mode 100644 index d856702bfe6..00000000000 --- a/tests/gentype_tests/typescript-react-example/src/Undefined.res.js +++ /dev/null @@ -1,2 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE -/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */ diff --git a/tests/gentype_tests/typescript-react-example/src/VariantsWithPayload.res b/tests/gentype_tests/typescript-react-example/src/VariantsWithPayload.res index 1ccc9d1b6c4..1bae4b07bc9 100644 --- a/tests/gentype_tests/typescript-react-example/src/VariantsWithPayload.res +++ b/tests/gentype_tests/typescript-react-example/src/VariantsWithPayload.res @@ -17,12 +17,12 @@ type withPayload = [ @genType let printVariantWithPayload = (x: withPayload) => switch x { - | #a => Js.log("printVariantWithPayload: a") - | #b => Js.log("printVariantWithPayload: b") - | #True => Js.log("printVariantWithPayload: True") - | #Twenty => Js.log("printVariantWithPayload: Twenty") - | #Half => Js.log("printVariantWithPayload: Half") - | #c(payload) => Js.log4("printVariantWithPayload x:", payload.x, "y:", payload.y) + | #a => Console.log("printVariantWithPayload: a") + | #b => Console.log("printVariantWithPayload: b") + | #True => Console.log("printVariantWithPayload: True") + | #Twenty => Console.log("printVariantWithPayload: Twenty") + | #Half => Console.log("printVariantWithPayload: Half") + | #c(payload) => Console.log4("printVariantWithPayload x:", payload.x, "y:", payload.y) } @genType @@ -37,9 +37,9 @@ type manyPayloads = [ @genType let printManyPayloads = (x: manyPayloads) => switch x { - | #one(n) => Js.log2("printManyPayloads one:", n) - | #two(s1, s2) => Js.log3("printManyPayloads two:", s1, s2) - | #three(payload) => Js.log4("printManyPayloads x:", payload.x, "y:", payload.y) + | #one(n) => Console.log2("printManyPayloads one:", n) + | #two(s1, s2) => Console.log3("printManyPayloads two:", s1, s2) + | #three(payload) => Console.log4("printManyPayloads x:", payload.x, "y:", payload.y) } @genType @@ -63,20 +63,20 @@ type variantWithPayloads = @genType let printVariantWithPayloads = x => switch x { - | A => Js.log2("printVariantWithPayloads", "A") - | B(x) => Js.log2("printVariantWithPayloads", "B(" ++ (Belt.Int.toString(x) ++ ")")) + | A => Console.log2("printVariantWithPayloads", "A") + | B(x) => Console.log2("printVariantWithPayloads", "B(" ++ (Belt.Int.toString(x) ++ ")")) | C(x, y) => - Js.log2( + Console.log2( "printVariantWithPayloads", "C(" ++ (Belt.Int.toString(x) ++ (", " ++ (Belt.Int.toString(y) ++ ")"))), ) | D((x, y)) => - Js.log2( + Console.log2( "printVariantWithPayloads", "D((" ++ (Belt.Int.toString(x) ++ (", " ++ (Belt.Int.toString(y) ++ "))"))), ) | E(x, s, y) => - Js.log2( + Console.log2( "printVariantWithPayloads", "E(" ++ (Belt.Int.toString(x) ++ (", " ++ (s ++ (", " ++ (Belt.Int.toString(y) ++ ")"))))), ) diff --git a/tests/gentype_tests/typescript-react-example/src/nested/Tuples.res b/tests/gentype_tests/typescript-react-example/src/nested/Tuples.res index ed13440350d..a371a58dd5d 100644 --- a/tests/gentype_tests/typescript-react-example/src/nested/Tuples.res +++ b/tests/gentype_tests/typescript-react-example/src/nested/Tuples.res @@ -22,7 +22,7 @@ let computeAreaWithIdent = ((x, y, z): coord) => { @genType let coord2d = (x, y) => (x, y, None) -@genType type coord2 = (int, int, Js.Nullable.t) +@genType type coord2 = (int, int, nullable) @genType type person = { diff --git a/tests/gentype_tests/typescript-react-example/src/nested/Types.gen.tsx b/tests/gentype_tests/typescript-react-example/src/nested/Types.gen.tsx index cda2b782d6a..950e4ecf369 100644 --- a/tests/gentype_tests/typescript-react-example/src/nested/Types.gen.tsx +++ b/tests/gentype_tests/typescript-react-example/src/nested/Types.gen.tsx @@ -5,8 +5,6 @@ import * as TypesJS from './Types.res.js'; -import type {Json_t as Js_Json_t} from '../../src/shims/Js.shim'; - import type {List_t as Belt_List_t} from '../../src/shims/Belt.shim'; import type {M_t__ as TypeNameSanitize_M_t__} from '../../src/TypeNameSanitize.gen'; @@ -59,14 +57,6 @@ export type nullableOrString3 = (null | undefined | string); export type nullableOrString4 = (null | undefined | string); -export type undefinedOrString = (undefined | string); - -export type undefinedOrString2 = (undefined | string); - -export type undefinedOrString3 = (undefined | string); - -export type undefinedOrString4 = (undefined | string); - export type record = { readonly i: number; readonly s: string }; export type decorator = (_1:a) => b; @@ -114,11 +104,7 @@ export const testFunctionOnOptionsAsArgument: (a:(undefined | a), foo:((_1 export const stringT: string = TypesJS.stringT as any; -export const jsStringT: string = TypesJS.jsStringT as any; - -export const jsString2T: string = TypesJS.jsString2T as any; - -export const jsonStringify: (_1:Js_Json_t) => string = TypesJS.jsonStringify as any; +export const jsonStringify: (value:unknown) => string = TypesJS.jsonStringify as any; export const testConvertNull: (x:(null | record)) => (null | record) = TypesJS.testConvertNull as any; diff --git a/tests/gentype_tests/typescript-react-example/src/nested/Types.res b/tests/gentype_tests/typescript-react-example/src/nested/Types.res index d44030ed88d..b215f016ed6 100644 --- a/tests/gentype_tests/typescript-react-example/src/nested/Types.res +++ b/tests/gentype_tests/typescript-react-example/src/nested/Types.res @@ -51,10 +51,6 @@ type opaqueVariant = @genType let stringT: string = "a" -@genType let jsStringT: Js.String.t = "a" - -@genType let jsString2T: Js.String2.t = "a" - @genType type twice<'a> = ('a, 'a) @gentype @@ -62,38 +58,30 @@ type genTypeMispelled = int @genType type dictString = dict -@genType let jsonStringify = Js.Json.stringify +@genType let jsonStringify = value => JSON.stringify(value) @genType type nullOrString = null @genType type nullOrString2 = Null.t -@genType type nullOrString3 = Js.null +@genType type nullOrString3 = null -@genType type nullOrString4 = Js.Null.t +@genType type nullOrString4 = Null.t @genType type nullableOrString = nullable @genType type nullableOrString2 = Nullable.t -@genType type nullableOrString3 = Js.nullable - -@genType type nullableOrString4 = Js.Nullable.t - -@genType type undefinedOrString = undefined - -@genType type undefinedOrString2 = Undefined.t - -@genType type undefinedOrString3 = Js.undefined +@genType type nullableOrString3 = nullable -@genType type undefinedOrString4 = Js.Undefined.t +@genType type nullableOrString4 = nullable type record = { i: int, s: string, } -@genType let testConvertNull = (x: Js.Null.t) => x +@genType let testConvertNull = (x: Null.t) => x @genType type decorator<'a, 'b> = 'a => 'b constraint 'a = int constraint 'b = _ => _ @@ -142,9 +130,9 @@ type instantiateTypeParameter = ocaml_array @genType @genType.as("Vector") type vector<'a> = ('a, 'a) -@genType type date = Js.Date.t +@genType type date = Date.t -@genType let currentTime = Js.Date.make() +@genType let currentTime = Date.make() @genType let optFunction = Some(() => 3) diff --git a/tests/gentype_tests/typescript-react-example/src/nested/Types.res.js b/tests/gentype_tests/typescript-react-example/src/nested/Types.res.js index f2859daa805..0ec0a547c38 100644 --- a/tests/gentype_tests/typescript-react-example/src/nested/Types.res.js +++ b/tests/gentype_tests/typescript-react-example/src/nested/Types.res.js @@ -23,8 +23,8 @@ function testFunctionOnOptionsAsArgument(a, foo) { return foo(a); } -function jsonStringify(prim) { - return JSON.stringify(prim); +function jsonStringify(value) { + return JSON.stringify(value); } function testConvertNull(x) { @@ -76,10 +76,6 @@ let map = Belt_List.map; let stringT = "a"; -let jsStringT = "a"; - -let jsString2T = "a"; - export { someIntList, map, @@ -88,8 +84,6 @@ export { mutuallyRecursiveConverter, testFunctionOnOptionsAsArgument, stringT, - jsStringT, - jsString2T, jsonStringify, testConvertNull, testConvertLocation, diff --git a/tests/package_tests/installation_test/src/Test.res b/tests/package_tests/installation_test/src/Test.res index 25ae6e664c0..2bb95f0a6ee 100644 --- a/tests/package_tests/installation_test/src/Test.res +++ b/tests/package_tests/installation_test/src/Test.res @@ -1 +1 @@ -Js.Console.log("Hello, world!") +Console.log("Hello, world!") diff --git a/tests/syntax_benchmarks/data/Napkinscript.res b/tests/syntax_benchmarks/data/Napkinscript.res index 22acfa41691..03395e1ad17 100644 --- a/tests/syntax_benchmarks/data/Napkinscript.res +++ b/tests/syntax_benchmarks/data/Napkinscript.res @@ -13104,9 +13104,9 @@ Solution: directly use `concat`." handle_seq(seq) } - /* {"foo": bar} -> Js.t({. foo: bar}) - * {.. "foo": bar} -> Js.t({.. foo: bar}) - * {..} -> Js.t({..}) */ + /* {"foo": bar} -> object({. foo: bar}) + * {.. "foo": bar} -> object({.. foo: bar}) + * {..} -> object({..}) */ let makeBsObjType = (~attrs, ~loc, ~closed, rows) => { let obj = Ast_helper.Typ.object_(~loc, rows, closed) let jsDotTCtor = Location.mkloc(Longident.Ldot(Longident.Lident("Js"), "t"), loc) @@ -17019,7 +17019,7 @@ Solution: directly use `concat`." None } - /* Js.Nullable.value<'a> */ + /* Nullable.t<'a> */ and parseTypeConstructorArgs = (~constrName, p) => { let opening = p.Parser.token let openingStartPos = p.startPos diff --git a/tests/syntax_benchmarks/data/RedBlackTree.res b/tests/syntax_benchmarks/data/RedBlackTree.res index e1dff155df1..72d84226c79 100644 --- a/tests/syntax_benchmarks/data/RedBlackTree.res +++ b/tests/syntax_benchmarks/data/RedBlackTree.res @@ -492,7 +492,7 @@ let make = (~compare) => {size: 0, root: None, compare} let makeWith = (array, ~compare) => { let rbt = make(~compare) - array->Js.Array2.forEach(((value, height)) => add(rbt, value, ~height)->ignore) + array->Array.forEach(((value, height)) => add(rbt, value, ~height)->ignore) rbt } @@ -502,7 +502,7 @@ let rec heightOfInterval = (rbt, node, lhs, rhs) => { switch node { | None => 0. | Some(n) => - //Js.log4("heightOfInterval n:", n.value, lhs, rhs) + //Console.log4("heightOfInterval n:", n.value, lhs, rhs) if lhs === None && rhs === None { n.sum } else if lhs !== None && rbt.compare(n.value, lhs->castNotOption) < 0 { @@ -521,7 +521,7 @@ let rec heightOfInterval = (rbt, node, lhs, rhs) => { } let heightOfInterval = (rbt, lhs, rhs) => { - //Js.log("-----------") + //Console.log("-----------") heightOfInterval(rbt, rbt.root, lhs, rhs) } @@ -530,7 +530,7 @@ let rec firstVisibleNode = (node, top) => { switch node { | None => None | Some(node) => - //Js.log4("firstVisibleNode", node.value, "top:", top) + //Console.log4("firstVisibleNode", node.value, "top:", top) if node.sum <= top { // no node is visible None @@ -679,12 +679,12 @@ let onChangedVisible = ( let old = oldNewVisible.new let new = oldNewVisible.old // empty new - new->Js.Array2.removeCountInPlace(~pos=0, ~count=new->Js.Array2.length)->ignore + new->Array.splice(~start=0, ~remove=new->Array.length, ~insert=[])->ignore oldNewVisible.old = old oldNewVisible.new = new let anchorDelta = rbt->getAnchorDelta(~anchor) - //Js.log2("anchorDelta", anchorDelta) + //Console.log2("anchorDelta", anchorDelta) let top = top_ -. anchorDelta let top = top < 0.0 ? 0.0 : top // anchoring can make top negative let bottom = bottom_ -. anchorDelta @@ -692,7 +692,7 @@ let onChangedVisible = ( let first = firstVisibleNode(rbt.root, top) let last = lastVisibleNode(rbt.root, bottom) - let oldLen = old->Js.Array2.length + let oldLen = old->Array.length let oldIter = ref(0) iterateWithY(~inclusive=true, first, last, ~callback=(node, y_) => { let y = y_ +. anchorDelta @@ -700,14 +700,14 @@ let onChangedVisible = ( // anchoring can make y negative while ( oldIter.contents < oldLen && - rbt.compare(Js.Array2.unsafe_get(old, oldIter.contents), node.value) < 0 + rbt.compare(Array.getUnsafe(old, oldIter.contents), node.value) < 0 ) { - disappear(Js.Array2.unsafe_get(old, oldIter.contents)) + disappear(Array.getUnsafe(old, oldIter.contents)) oldIter.contents = oldIter.contents + 1 } - new->Js.Array2.push(node.value)->ignore + new->Array.push(node.value)->ignore if oldIter.contents < oldLen { - let cmp = rbt.compare(Js.Array2.unsafe_get(old, oldIter.contents), node.value) + let cmp = rbt.compare(Array.getUnsafe(old, oldIter.contents), node.value) if cmp == 0 { remained(node, y) oldIter.contents = oldIter.contents + 1 @@ -720,7 +720,7 @@ let onChangedVisible = ( } }) while oldIter.contents < oldLen { - disappear(Js.Array2.unsafe_get(old, oldIter.contents)) + disappear(Array.getUnsafe(old, oldIter.contents)) oldIter.contents = oldIter.contents + 1 } } diff --git a/tests/syntax_benchmarks/data/RedBlackTreeNoComments.res b/tests/syntax_benchmarks/data/RedBlackTreeNoComments.res index 627e6a8d5d2..9cb9c98e87c 100644 --- a/tests/syntax_benchmarks/data/RedBlackTreeNoComments.res +++ b/tests/syntax_benchmarks/data/RedBlackTreeNoComments.res @@ -398,7 +398,7 @@ let make = (~compare) => {size: 0, root: None, compare} let makeWith = (array, ~compare) => { let rbt = make(~compare) - array->Js.Array2.forEach(((value, height)) => add(rbt, value, ~height)->ignore) + array->Array.forEach(((value, height)) => add(rbt, value, ~height)->ignore) rbt } @@ -564,7 +564,7 @@ let onChangedVisible = ( let new = oldNewVisible.old new - ->Js.Array2.removeCountInPlace(~pos=0, ~count=new->Js.Array2.length) + ->Array.splice(~start=0, ~remove=new->Array.length, ~insert=[]) ->ignore oldNewVisible.old = old oldNewVisible.new = new @@ -578,21 +578,21 @@ let onChangedVisible = ( let first = firstVisibleNode(rbt.root, top) let last = lastVisibleNode(rbt.root, bottom) - let oldLen = old->Js.Array2.length + let oldLen = old->Array.length let oldIter = ref(0) iterateWithY(~inclusive=true, first, last, (node, y_) => { let y = y_ +. anchorDelta if y >= 0.0 { while ( oldIter.contents < oldLen && - rbt.compare(Js.Array2.unsafe_get(old, oldIter.contents), node.value) < 0 + rbt.compare(Array.getUnsafe(old, oldIter.contents), node.value) < 0 ) { - disappear(Js.Array2.unsafe_get(old, oldIter.contents)) + disappear(Array.getUnsafe(old, oldIter.contents)) oldIter.contents = oldIter.contents + 1 } - new->Js.Array2.push(node.value)->ignore + new->Array.push(node.value)->ignore if oldIter.contents < oldLen { - let cmp = rbt.compare(Js.Array2.unsafe_get(old, oldIter.contents), node.value) + let cmp = rbt.compare(Array.getUnsafe(old, oldIter.contents), node.value) if cmp == 0 { remained(node, y) oldIter.contents = oldIter.contents + 1 @@ -605,7 +605,7 @@ let onChangedVisible = ( } }) while oldIter.contents < oldLen { - disappear(Js.Array2.unsafe_get(old, oldIter.contents)) + disappear(Array.getUnsafe(old, oldIter.contents)) oldIter.contents = oldIter.contents + 1 } } diff --git a/tests/syntax_tests/data/api/resSyntax.res b/tests/syntax_tests/data/api/resSyntax.res index 2d6f904b826..4214fe1e7a8 100644 --- a/tests/syntax_tests/data/api/resSyntax.res +++ b/tests/syntax_tests/data/api/resSyntax.res @@ -1,7 +1,7 @@ // test file if true { - Js.log("true") + Console.log("true") } else { - Js.log("false") + Console.log("false") } diff --git a/tests/syntax_tests/data/conversion/reason/attributes.res b/tests/syntax_tests/data/conversion/reason/attributes.res index 4549e63705c..87de6827be6 100644 --- a/tests/syntax_tests/data/conversion/reason/attributes.res +++ b/tests/syntax_tests/data/conversion/reason/attributes.res @@ -12,9 +12,9 @@ module Color: { @send external map: (array<'a>, 'a => 'b) => array<'b> = "map" @send external filter: (array<'a>, 'a => 'b) => array<'b> = "filter" -list{1, 2, 3}->map(a => a + 1)->filter(a => modulo(a, 2) == 0)->Js.log +list{1, 2, 3}->map(a => a + 1)->filter(a => modulo(a, 2) == 0)->Console.log type t @new external make: unit => t = "DOMParser" -Js.log(make()->parseHtmlFromString("sdsd")) +Console.log(make()->parseHtmlFromString("sdsd")) diff --git a/tests/syntax_tests/data/conversion/reason/bracedJsx.res b/tests/syntax_tests/data/conversion/reason/bracedJsx.res index 0cbb8f4784f..5d0e30c43c4 100644 --- a/tests/syntax_tests/data/conversion/reason/bracedJsx.res +++ b/tests/syntax_tests/data/conversion/reason/bracedJsx.res @@ -48,7 +48,7 @@ module Styles = { @react.component let make = () => { - let containerRef = React.useRef(Js.Nullable.null) + let containerRef = React.useRef(Nullable.null) let (state, send) = React.useReducer((state, action) => switch action { @@ -58,7 +58,7 @@ let make = () => { state.history, [ User(state.input), - switch state.input->Js.String.trim { + switch state.input->String.trim { | "" => System("") | "help" => System(`available commands: @@ -81,7 +81,7 @@ let make = () => { System("000000") | "go-to-home.sh" | "./go-to-home.sh" => - Js.Global.setTimeout(() => ReasonReact.Router.push("/"), 1_000)->ignore + setTimeout(() => ReasonReact.Router.push("/"), 1_000)->ignore System("Redirecting ...") | "cat go-to-home.sh" | "cat ./go-to-home.sh" => @@ -96,7 +96,7 @@ let make = () => { , {history: [], input: ""}) React.useEffect1(() => { - switch containerRef.current->Js.Nullable.toOption { + switch containerRef.current->Nullable.toOption { | Some(containerRef) => open Webapi.Dom containerRef->Element.setScrollTop(containerRef->Element.scrollHeight->float_of_int) diff --git a/tests/syntax_tests/data/conversion/reason/braces.res b/tests/syntax_tests/data/conversion/reason/braces.res index cf164c934df..6cddc1ae5cd 100644 --- a/tests/syntax_tests/data/conversion/reason/braces.res +++ b/tests/syntax_tests/data/conversion/reason/braces.res @@ -3,7 +3,7 @@ let f = () => id if isArray(children) { // Scenario 1 - let code = children->asStringArray->Js.Array2.joinWith("") + let code = children->asStringArray->Array.joinUnsafe("") {code->s} } else if isObject(children) { // Scenario 2 diff --git a/tests/syntax_tests/data/conversion/reason/expected/attributes.res.txt b/tests/syntax_tests/data/conversion/reason/expected/attributes.res.txt index 4549e63705c..87de6827be6 100644 --- a/tests/syntax_tests/data/conversion/reason/expected/attributes.res.txt +++ b/tests/syntax_tests/data/conversion/reason/expected/attributes.res.txt @@ -12,9 +12,9 @@ module Color: { @send external map: (array<'a>, 'a => 'b) => array<'b> = "map" @send external filter: (array<'a>, 'a => 'b) => array<'b> = "filter" -list{1, 2, 3}->map(a => a + 1)->filter(a => modulo(a, 2) == 0)->Js.log +list{1, 2, 3}->map(a => a + 1)->filter(a => modulo(a, 2) == 0)->Console.log type t @new external make: unit => t = "DOMParser" -Js.log(make()->parseHtmlFromString("sdsd")) +Console.log(make()->parseHtmlFromString("sdsd")) diff --git a/tests/syntax_tests/data/conversion/reason/expected/bracedJsx.res.txt b/tests/syntax_tests/data/conversion/reason/expected/bracedJsx.res.txt index 17d75e3d9ae..ff29d848c78 100644 --- a/tests/syntax_tests/data/conversion/reason/expected/bracedJsx.res.txt +++ b/tests/syntax_tests/data/conversion/reason/expected/bracedJsx.res.txt @@ -48,7 +48,7 @@ module Styles = { @react.component let make = () => { - let containerRef = React.useRef(Js.Nullable.null) + let containerRef = React.useRef(Nullable.null) let (state, send) = React.useReducer((state, action) => switch action { @@ -58,7 +58,7 @@ let make = () => { state.history, [ User(state.input), - switch state.input->Js.String.trim { + switch state.input->String.trim { | "" => System("") | "help" => System(`available commands: @@ -81,7 +81,7 @@ let make = () => { System("000000") | "go-to-home.sh" | "./go-to-home.sh" => - Js.Global.setTimeout(() => ReasonReact.Router.push("/"), 1_000)->ignore + setTimeout(() => ReasonReact.Router.push("/"), 1_000)->ignore System("Redirecting ...") | "cat go-to-home.sh" | "cat ./go-to-home.sh" => @@ -96,7 +96,7 @@ let make = () => { , {history: [], input: ""}) React.useEffect1(() => { - switch containerRef.current->Js.Nullable.toOption { + switch containerRef.current->Nullable.toOption { | Some(containerRef) => open Webapi.Dom containerRef->Element.setScrollTop(containerRef->Element.scrollHeight->float_of_int) diff --git a/tests/syntax_tests/data/conversion/reason/expected/braces.res.txt b/tests/syntax_tests/data/conversion/reason/expected/braces.res.txt index 0a3e335d63c..ae6589c3753 100644 --- a/tests/syntax_tests/data/conversion/reason/expected/braces.res.txt +++ b/tests/syntax_tests/data/conversion/reason/expected/braces.res.txt @@ -3,7 +3,7 @@ let f = () => id if isArray(children) { // Scenario 1 - let code = children->asStringArray->Js.Array2.joinWith("") + let code = children->asStringArray->Array.joinUnsafe("") {code->s} } else if isObject(children) { // Scenario 2 diff --git a/tests/syntax_tests/data/conversion/reason/expected/fastPipe.res.txt b/tests/syntax_tests/data/conversion/reason/expected/fastPipe.res.txt index a7007b68b58..60c1fc09fc1 100644 --- a/tests/syntax_tests/data/conversion/reason/expected/fastPipe.res.txt +++ b/tests/syntax_tests/data/conversion/reason/expected/fastPipe.res.txt @@ -15,8 +15,8 @@ let x = @attr ((@attr2 a)->f(b)->c(d)) Route.urlToRoute(url)->ChangeView->self.send let aggregateTotal = (forecast, ~audienceType) => - Js.Nullable.toOption(forecast["audiences"]) - ->Option.flatMap(item => Js.Dict.get(item, audienceType)) + Nullable.toOption(forecast["audiences"]) + ->Option.flatMap(item => Dict.get(item, audienceType)) ->Option.map(item => { pages: item["reach"]["pages"], views: item["reach"]["views"], diff --git a/tests/syntax_tests/data/conversion/reason/expected/jsObject.res.txt b/tests/syntax_tests/data/conversion/reason/expected/jsObject.res.txt index 0c591da8352..1d1e3511a4b 100644 --- a/tests/syntax_tests/data/conversion/reason/expected/jsObject.res.txt +++ b/tests/syntax_tests/data/conversion/reason/expected/jsObject.res.txt @@ -8,7 +8,7 @@ let y = {"age": 30, "name": "steve"} type propField<'a> = {.} type propField<'a> = {..} as 'a type propField<'a> = {..} as 'a -type propField<'a> = Js.nullable<{..} as 'a> +type propField<'a> = nullable<{..} as 'a> type propField<'a> = {"a": b} type propField<'a> = {.."a": b} diff --git a/tests/syntax_tests/data/conversion/reason/expected/jsObject.resi.txt b/tests/syntax_tests/data/conversion/reason/expected/jsObject.resi.txt index f9ca82b776c..2115096e1d6 100644 --- a/tests/syntax_tests/data/conversion/reason/expected/jsObject.resi.txt +++ b/tests/syntax_tests/data/conversion/reason/expected/jsObject.resi.txt @@ -1,7 +1,7 @@ type propField<'a> = {.} type propField<'a> = {..} as 'a type propField<'a> = {..} as 'a -type propField<'a> = Js.nullable<{..} as 'a> +type propField<'a> = nullable<{..} as 'a> type propField<'a> = {"a": b} type propField<'a> = {.."a": b} diff --git a/tests/syntax_tests/data/conversion/reason/expected/openPattern.res.txt b/tests/syntax_tests/data/conversion/reason/expected/openPattern.res.txt index 28558275a78..110c8ab11ab 100644 --- a/tests/syntax_tests/data/conversion/reason/expected/openPattern.res.txt +++ b/tests/syntax_tests/data/conversion/reason/expected/openPattern.res.txt @@ -13,11 +13,11 @@ module Color = { } let () = switch (Color.red, Color.blue, Color.green) { -| (Color.Red, Blue, Green) => Js.log("hello world") +| (Color.Red, Blue, Green) => Console.log("hello world") | _ => () } let () = switch [Color.red, Color.blue, Color.green] { -| [Color.Red, Blue, Green] => Js.log("hello world") +| [Color.Red, Blue, Green] => Console.log("hello world") | _ => () } diff --git a/tests/syntax_tests/data/conversion/reason/expected/string.res.txt b/tests/syntax_tests/data/conversion/reason/expected/string.res.txt index 217af2ddad0..30bf3f0c2ab 100644 --- a/tests/syntax_tests/data/conversion/reason/expected/string.res.txt +++ b/tests/syntax_tests/data/conversion/reason/expected/string.res.txt @@ -30,7 +30,7 @@ let var1 = "three" let var2 = "a string" switch (var1, var2) { -| (`3`, `a string`) => Js.log("worked") -| (` test with \` \${here} \``, _) => Js.log("escapes ` and ${") -| _ => Js.log("didn't match") +| (`3`, `a string`) => Console.log("worked") +| (` test with \` \${here} \``, _) => Console.log("escapes ` and ${") +| _ => Console.log("didn't match") } diff --git a/tests/syntax_tests/data/conversion/reason/expected/uncurrried.res.txt b/tests/syntax_tests/data/conversion/reason/expected/uncurrried.res.txt index f5cad9198ae..93b1854666e 100644 --- a/tests/syntax_tests/data/conversion/reason/expected/uncurrried.res.txt +++ b/tests/syntax_tests/data/conversion/reason/expected/uncurrried.res.txt @@ -1,5 +1,5 @@ // ok -let updateBriefletNarrative = updateObj => Js.log("patented merge algorithm goes here") +let updateBriefletNarrative = updateObj => Console.log("patented merge algorithm goes here") // this is a bug in Reason, the . will be parsed wrong and disappear. /* updateBriefletNarrative(briefletNarrativeUpdateObj); */ @@ -49,11 +49,11 @@ let () = { dontDoThisAhome(a, b)(c, d)(e, f) } -let _ = library.getBalance(account)->Promise.Js.catch(_ => Promise.resolved(None)) +let _ = library.getBalance(account)->Promise.catch(_ => Promise.resolve(None)) let _ = library.getBalance(account) - ->Promise.Js.catch(_ => Promise.resolved(None)) + ->Promise.catch(_ => Promise.resolve(None)) ->Promise.get(newBalance => dispatch( LoadAddress( diff --git a/tests/syntax_tests/data/conversion/reason/fastPipe.res b/tests/syntax_tests/data/conversion/reason/fastPipe.res index c758fccd153..be8d5ca2ef0 100644 --- a/tests/syntax_tests/data/conversion/reason/fastPipe.res +++ b/tests/syntax_tests/data/conversion/reason/fastPipe.res @@ -15,8 +15,8 @@ let x = @attr (@attr2 a->f(b)->c(d)) Route.urlToRoute(url)->ChangeView->self.send let aggregateTotal = (forecast, ~audienceType) => - Js.Nullable.toOption(forecast["audiences"]) - ->Option.flatMap(item => Js.Dict.get(item, audienceType)) + Nullable.toOption(forecast["audiences"]) + ->Option.flatMap(item => Dict.get(item, audienceType)) ->Option.map(item => { pages: item["reach"]["pages"], views: item["reach"]["views"], diff --git a/tests/syntax_tests/data/conversion/reason/jsObject.res b/tests/syntax_tests/data/conversion/reason/jsObject.res index 0c591da8352..1d1e3511a4b 100644 --- a/tests/syntax_tests/data/conversion/reason/jsObject.res +++ b/tests/syntax_tests/data/conversion/reason/jsObject.res @@ -8,7 +8,7 @@ let y = {"age": 30, "name": "steve"} type propField<'a> = {.} type propField<'a> = {..} as 'a type propField<'a> = {..} as 'a -type propField<'a> = Js.nullable<{..} as 'a> +type propField<'a> = nullable<{..} as 'a> type propField<'a> = {"a": b} type propField<'a> = {.."a": b} diff --git a/tests/syntax_tests/data/conversion/reason/jsObject.resi b/tests/syntax_tests/data/conversion/reason/jsObject.resi index f9ca82b776c..2115096e1d6 100644 --- a/tests/syntax_tests/data/conversion/reason/jsObject.resi +++ b/tests/syntax_tests/data/conversion/reason/jsObject.resi @@ -1,7 +1,7 @@ type propField<'a> = {.} type propField<'a> = {..} as 'a type propField<'a> = {..} as 'a -type propField<'a> = Js.nullable<{..} as 'a> +type propField<'a> = nullable<{..} as 'a> type propField<'a> = {"a": b} type propField<'a> = {.."a": b} diff --git a/tests/syntax_tests/data/conversion/reason/openPattern.res b/tests/syntax_tests/data/conversion/reason/openPattern.res index 28558275a78..110c8ab11ab 100644 --- a/tests/syntax_tests/data/conversion/reason/openPattern.res +++ b/tests/syntax_tests/data/conversion/reason/openPattern.res @@ -13,11 +13,11 @@ module Color = { } let () = switch (Color.red, Color.blue, Color.green) { -| (Color.Red, Blue, Green) => Js.log("hello world") +| (Color.Red, Blue, Green) => Console.log("hello world") | _ => () } let () = switch [Color.red, Color.blue, Color.green] { -| [Color.Red, Blue, Green] => Js.log("hello world") +| [Color.Red, Blue, Green] => Console.log("hello world") | _ => () } diff --git a/tests/syntax_tests/data/conversion/reason/string.res b/tests/syntax_tests/data/conversion/reason/string.res index dde635285c9..5da53173ff7 100644 --- a/tests/syntax_tests/data/conversion/reason/string.res +++ b/tests/syntax_tests/data/conversion/reason/string.res @@ -30,7 +30,7 @@ let var1 = "three" let var2 = "a string" switch (var1, var2) { -| (`3`, `a string`) => Js.log("worked") -| (` test with \` \${here} \``, _) => Js.log("escapes ` and ${") -| _ => Js.log("didn't match") +| (`3`, `a string`) => Console.log("worked") +| (` test with \` \${here} \``, _) => Console.log("escapes ` and ${") +| _ => Console.log("didn't match") } diff --git a/tests/syntax_tests/data/conversion/reason/uncurrried.res b/tests/syntax_tests/data/conversion/reason/uncurrried.res index 30a34ee74d4..babb841e86e 100644 --- a/tests/syntax_tests/data/conversion/reason/uncurrried.res +++ b/tests/syntax_tests/data/conversion/reason/uncurrried.res @@ -1,5 +1,5 @@ // ok -let updateBriefletNarrative = (updateObj) => Js.log("patented merge algorithm goes here") +let updateBriefletNarrative = (updateObj) => Console.log("patented merge algorithm goes here") // this is a bug in Reason, the . will be parsed wrong and disappear. /* updateBriefletNarrative(briefletNarrativeUpdateObj); */ @@ -49,11 +49,11 @@ let () = { dontDoThisAhome(a, b)(c, d)(e, f) } -let _ = library.getBalance(account)->Promise.Js.catch(_ => Promise.resolved(None)) +let _ = library.getBalance(account)->Promise.catch(_ => Promise.resolve(None)) let _ = library.getBalance(account) - ->Promise.Js.catch(_ => Promise.resolved(None)) + ->Promise.catch(_ => Promise.resolve(None)) ->Promise.get(newBalance => dispatch( LoadAddress( diff --git a/tests/syntax_tests/data/idempotency/bs-css/Css.res b/tests/syntax_tests/data/idempotency/bs-css/Css.res index e97500d8e1f..8d683c51b0f 100644 --- a/tests/syntax_tests/data/idempotency/bs-css/Css.res +++ b/tests/syntax_tests/data/idempotency/bs-css/Css.res @@ -11,6 +11,6 @@ include Css_Legacy_Core.Make({ let makeKeyFrames = (_) => throw(NotImplemented) }) -external unsafeJsonToStyles: Js.Json.t => ReactDOMRe.Style.t = "%identity" +external unsafeJsonToStyles: JSON.t => ReactDOMRe.Style.t = "%identity" let style = rules => rules->toJson->unsafeJsonToStyles diff --git a/tests/syntax_tests/data/idempotency/bs-css/CssEmotion.res b/tests/syntax_tests/data/idempotency/bs-css/CssEmotion.res index 2fcc61ae049..045cdaa2d72 100644 --- a/tests/syntax_tests/data/idempotency/bs-css/CssEmotion.res +++ b/tests/syntax_tests/data/idempotency/bs-css/CssEmotion.res @@ -5,16 +5,16 @@ include Css_Legacy_Core.Make({ @module("emotion") external mergeStyles: (array) => string = "cx" - @module("emotion") external make: (Js.Json.t) => string = "css" + @module("emotion") external make: (JSON.t) => string = "css" @module("emotion") - external injectRule: (Js.Json.t) => unit = "injectGlobal" + external injectRule: (JSON.t) => unit = "injectGlobal" @module("emotion") external injectRaw: (string) => unit = "injectGlobal" @module("emotion") - external makeKeyFrames: (dict) => string = "keyframes" + external makeKeyFrames: (dict) => string = "keyframes" }) type cache diff --git a/tests/syntax_tests/data/idempotency/bs-css/CssEmotionJs.res b/tests/syntax_tests/data/idempotency/bs-css/CssEmotionJs.res index a8a108b7656..c8f90746071 100644 --- a/tests/syntax_tests/data/idempotency/bs-css/CssEmotionJs.res +++ b/tests/syntax_tests/data/idempotency/bs-css/CssEmotionJs.res @@ -5,16 +5,16 @@ include Css_Js_Core.Make({ @module("emotion") external mergeStyles: (array) => string = "cx" - @module("emotion") external make: (Js.Json.t) => string = "css" + @module("emotion") external make: (JSON.t) => string = "css" @module("emotion") - external injectRule: (Js.Json.t) => unit = "injectGlobal" + external injectRule: (JSON.t) => unit = "injectGlobal" @module("emotion") external injectRaw: (string) => unit = "injectGlobal" @module("emotion") - external makeKeyFrames: (dict) => string = "keyframes" + external makeKeyFrames: (dict) => string = "keyframes" }) type cache diff --git a/tests/syntax_tests/data/idempotency/bs-css/CssJs.res b/tests/syntax_tests/data/idempotency/bs-css/CssJs.res index 14889ae6bf1..0eb943ccfbc 100644 --- a/tests/syntax_tests/data/idempotency/bs-css/CssJs.res +++ b/tests/syntax_tests/data/idempotency/bs-css/CssJs.res @@ -11,6 +11,6 @@ include Css_Js_Core.Make({ let makeKeyFrames = (_) => throw(NotImplemented) }) -external unsafeJsonToStyles: Js.Json.t => ReactDOMRe.Style.t = "%identity" +external unsafeJsonToStyles: JSON.t => ReactDOMRe.Style.t = "%identity" let style = (rules) => rules->toJson->unsafeJsonToStyles diff --git a/tests/syntax_tests/data/idempotency/bs-css/Css_AtomicTypes.res b/tests/syntax_tests/data/idempotency/bs-css/Css_AtomicTypes.res index bbf835c94ae..e9a92b9077f 100644 --- a/tests/syntax_tests/data/idempotency/bs-css/Css_AtomicTypes.res +++ b/tests/syntax_tests/data/idempotency/bs-css/Css_AtomicTypes.res @@ -29,7 +29,7 @@ module Var = { let var = x => #var(x) let varDefault = (x, default) => #varDefault(x, default) - let prefix = x => Js.String.startsWith("--", x) ? x : "--" ++ x + let prefix = x => String.startsWith(x, "--") ? x : "--" ++ x let toString = x => switch x { @@ -46,8 +46,8 @@ module Time = { let toString = x => switch x { - | #s(v) => Js.Float.toString(v) ++ "s" - | #ms(v) => Js.Float.toString(v) ++ "ms" + | #s(v) => Float.toString(v) ++ "s" + | #ms(v) => Float.toString(v) ++ "ms" } } @@ -58,7 +58,7 @@ module Percentage = { let toString = x => switch x { - | #percent(x) => Js.Float.toString(x) ++ "%" + | #percent(x) => Float.toString(x) ++ "%" } } @@ -112,26 +112,26 @@ module Length = { let rec toString = x => switch x { - | #ch(x) => Js.Float.toString(x) ++ "ch" - | #em(x) => Js.Float.toString(x) ++ "em" - | #ex(x) => Js.Float.toString(x) ++ "ex" - | #rem(x) => Js.Float.toString(x) ++ "rem" - | #vh(x) => Js.Float.toString(x) ++ "vh" - | #vw(x) => Js.Float.toString(x) ++ "vw" - | #vmin(x) => Js.Float.toString(x) ++ "vmin" - | #vmax(x) => Js.Float.toString(x) ++ "vmax" - | #px(x) => Js.Int.toString(x) ++ "px" - | #pxFloat(x) => Js.Float.toString(x) ++ "px" - | #cm(x) => Js.Float.toString(x) ++ "cm" - | #mm(x) => Js.Float.toString(x) ++ "mm" - | #inch(x) => Js.Float.toString(x) ++ "in" - | #pc(x) => Js.Float.toString(x) ++ "pc" - | #pt(x) => Js.Int.toString(x) ++ "pt" + | #ch(x) => Float.toString(x) ++ "ch" + | #em(x) => Float.toString(x) ++ "em" + | #ex(x) => Float.toString(x) ++ "ex" + | #rem(x) => Float.toString(x) ++ "rem" + | #vh(x) => Float.toString(x) ++ "vh" + | #vw(x) => Float.toString(x) ++ "vw" + | #vmin(x) => Float.toString(x) ++ "vmin" + | #vmax(x) => Float.toString(x) ++ "vmax" + | #px(x) => Int.toString(x) ++ "px" + | #pxFloat(x) => Float.toString(x) ++ "px" + | #cm(x) => Float.toString(x) ++ "cm" + | #mm(x) => Float.toString(x) ++ "mm" + | #inch(x) => Float.toString(x) ++ "in" + | #pc(x) => Float.toString(x) ++ "pc" + | #pt(x) => Int.toString(x) ++ "pt" | #zero => "0" | #calc(#add, a, b) => "calc(" ++ (toString(a) ++ (" + " ++ (toString(b) ++ ")"))) | #calc(#sub, a, b) => "calc(" ++ (toString(a) ++ (" - " ++ (toString(b) ++ ")"))) - | #percent(x) => Js.Float.toString(x) ++ "%" + | #percent(x) => Float.toString(x) ++ "%" } } @@ -145,10 +145,10 @@ module Angle = { let toString = x => switch x { - | #deg(x) => Js.Float.toString(x) ++ "deg" - | #rad(x) => Js.Float.toString(x) ++ "rad" - | #grad(x) => Js.Float.toString(x) ++ "grad" - | #turn(x) => Js.Float.toString(x) ++ "turn" + | #deg(x) => Float.toString(x) ++ "deg" + | #rad(x) => Float.toString(x) ++ "rad" + | #grad(x) => Float.toString(x) ++ "grad" + | #turn(x) => Float.toString(x) ++ "turn" } } @@ -366,14 +366,14 @@ module TimingFunction = { | #easeInOut => "ease-in-out" | #stepStart => "step-start" | #stepEnd => "step-end" - | #steps(i, #start) => "steps(" ++ (Js.Int.toString(i) ++ ", start)") - | #steps(i, #end_) => "steps(" ++ (Js.Int.toString(i) ++ ", end)") + | #steps(i, #start) => "steps(" ++ (Int.toString(i) ++ ", start)") + | #steps(i, #end_) => "steps(" ++ (Int.toString(i) ++ ", end)") | #cubicBezier(a, b, c, d) => "cubic-bezier(" ++ - (Js.Float.toString(a) ++ + (Float.toString(a) ++ (", " ++ - (Js.Float.toString(b) ++ - (", " ++ (Js.Float.toString(c) ++ (", " ++ (Js.Float.toString(d) ++ ")"))))))) + (Float.toString(b) ++ + (", " ++ (Float.toString(c) ++ (", " ++ (Float.toString(d) ++ ")"))))))) } } @@ -384,7 +384,7 @@ module RepeatValue = { switch x { | #autoFill => "auto-fill" | #autoFit => "auto-fit" - | #num(x) => Js.Int.toString(x) + | #num(x) => Int.toString(x) } } @@ -488,7 +488,7 @@ module FontWeight = { let toString = x => switch x { - | #num(n) => Js.Int.toString(n) + | #num(n) => Int.toString(n) | #thin => "100" | #extraLight => "200" | #light => "300" @@ -546,7 +546,7 @@ module Transform = { let skewY = a => #skewY(a) let string_of_scale = (x, y) => - "scale(" ++ (Js.Float.toString(x) ++ (", " ++ (Js.Float.toString(y) ++ ")"))) + "scale(" ++ (Float.toString(x) ++ (", " ++ (Float.toString(y) ++ ")"))) let string_of_translate3d = (x, y, z) => "translate3d(" ++ @@ -564,25 +564,25 @@ module Transform = { | #scale(x, y) => string_of_scale(x, y) | #scale3d(x, y, z) => "scale3d(" ++ - (Js.Float.toString(x) ++ - (", " ++ (Js.Float.toString(y) ++ (", " ++ (Js.Float.toString(z) ++ ")"))))) - | #scaleX(x) => "scaleX(" ++ (Js.Float.toString(x) ++ ")") - | #scaleY(y) => "scaleY(" ++ (Js.Float.toString(y) ++ ")") - | #scaleZ(z) => "scaleZ(" ++ (Js.Float.toString(z) ++ ")") + (Float.toString(x) ++ + (", " ++ (Float.toString(y) ++ (", " ++ (Float.toString(z) ++ ")"))))) + | #scaleX(x) => "scaleX(" ++ (Float.toString(x) ++ ")") + | #scaleY(y) => "scaleY(" ++ (Float.toString(y) ++ ")") + | #scaleZ(z) => "scaleZ(" ++ (Float.toString(z) ++ ")") | #rotate(a) => "rotate(" ++ (Angle.toString(a) ++ ")") | #rotate3d(x, y, z, a) => "rotate3d(" ++ - (Js.Float.toString(x) ++ + (Float.toString(x) ++ (", " ++ - (Js.Float.toString(y) ++ - (", " ++ (Js.Float.toString(z) ++ (", " ++ (Angle.toString(a) ++ ")"))))))) + (Float.toString(y) ++ + (", " ++ (Float.toString(z) ++ (", " ++ (Angle.toString(a) ++ ")"))))))) | #rotateX(a) => "rotateX(" ++ (Angle.toString(a) ++ ")") | #rotateY(a) => "rotateY(" ++ (Angle.toString(a) ++ ")") | #rotateZ(a) => "rotateZ(" ++ (Angle.toString(a) ++ ")") | #skew(x, y) => "skew(" ++ (Angle.toString(x) ++ (", " ++ (Angle.toString(y) ++ ")"))) | #skewX(a) => "skewX(" ++ (Angle.toString(a) ++ ")") | #skewY(a) => "skewY(" ++ (Angle.toString(a) ++ ")") - | #perspective(x) => "perspective(" ++ (Js.Int.toString(x) ++ ")") + | #perspective(x) => "perspective(" ++ (Int.toString(x) ++ ")") } } @@ -616,7 +616,7 @@ module AnimationIterationCount = { let toString = x => switch x { | #infinite => "infinite" - | #count(x) => Js.Int.toString(x) + | #count(x) => Int.toString(x) } } @@ -769,7 +769,7 @@ module Color = { let string_of_alpha = x => switch x { - | #num(f) => Js.Float.toString(f) + | #num(f) => Float.toString(f) | #...Percentage.t as pc => Percentage.toString(pc) } @@ -777,14 +777,14 @@ module Color = { switch x { | #rgb(r, g, b) => "rgb(" ++ - (Js.Int.toString(r) ++ - (", " ++ (Js.Int.toString(g) ++ (", " ++ (Js.Int.toString(b) ++ ")"))))) + (Int.toString(r) ++ + (", " ++ (Int.toString(g) ++ (", " ++ (Int.toString(b) ++ ")"))))) | #rgba(r, g, b, a) => "rgba(" ++ - (Js.Int.toString(r) ++ + (Int.toString(r) ++ (", " ++ - (Js.Int.toString(g) ++ - (", " ++ (Js.Int.toString(b) ++ (", " ++ (string_of_alpha(a) ++ ")"))))))) + (Int.toString(g) ++ + (", " ++ (Int.toString(b) ++ (", " ++ (string_of_alpha(a) ++ ")"))))))) | #hsl(h, s, l) => "hsl(" ++ (Angle.toString(h) ++ @@ -866,7 +866,7 @@ module LineHeight = { let toString = x => switch x { | #normal => "normal" - | #abs(x) => Js.Float.toString(x) + | #abs(x) => Float.toString(x) } } @@ -1233,7 +1233,7 @@ module ColumnCount = { let toString = x => switch x { | #auto => "auto" - | #count(v) => Js.Int.toString(v) + | #count(v) => Int.toString(v) } } @@ -1320,7 +1320,7 @@ module BackdropFilter = { | #sepia([#num(int) | #percent(float)]) ] - let string_of_percent = p => Js.Float.toString(p) ++ "%" + let string_of_percent = p => Float.toString(p) ++ "%" let toString = x => switch x { diff --git a/tests/syntax_tests/data/idempotency/bs-css/Css_Core.res b/tests/syntax_tests/data/idempotency/bs-css/Css_Core.res index 711f9e19e90..9bb43b844b4 100644 --- a/tests/syntax_tests/data/idempotency/bs-css/Css_Core.res +++ b/tests/syntax_tests/data/idempotency/bs-css/Css_Core.res @@ -1,7 +1,7 @@ module type CssImplementationIntf = { let mergeStyles: (array) => string - let injectRule: (Js.Json.t) => unit + let injectRule: (JSON.t) => unit let injectRaw: (string) => unit - let make: (Js.Json.t) => string - let makeKeyFrames: (dict) => string + let make: (JSON.t) => string + let makeKeyFrames: (dict) => string } diff --git a/tests/syntax_tests/data/idempotency/bs-css/Css_Js_Core.res b/tests/syntax_tests/data/idempotency/bs-css/Css_Js_Core.res index 295ab788a96..b50cfae20df 100644 --- a/tests/syntax_tests/data/idempotency/bs-css/Css_Js_Core.res +++ b/tests/syntax_tests/data/idempotency/bs-css/Css_Js_Core.res @@ -10,17 +10,17 @@ type rec rule = let rec ruleToDict = (dict, rule) => { switch rule { | D(name, value) if name == "content" => - dict->Js.Dict.set(name, Js.Json.string(value == "" ? "\"\"" : value)) - | D(name, value) => dict->Js.Dict.set(name, Js.Json.string(value)) - | S(name, ruleset) => dict->Js.Dict.set(name, toJson(ruleset)) - | PseudoClass(name, ruleset) => dict->Js.Dict.set(":" ++ name, toJson(ruleset)) + dict->Dict.set(name, JSON.string(value == "" ? "\"\"" : value)) + | D(name, value) => dict->Dict.set(name, JSON.string(value)) + | S(name, ruleset) => dict->Dict.set(name, toJson(ruleset)) + | PseudoClass(name, ruleset) => dict->Dict.set(":" ++ name, toJson(ruleset)) | PseudoClassParam(name, param, ruleset) => - dict->Js.Dict.set(":" ++ (name ++ ("(" ++ (param ++ ")"))), toJson(ruleset)) + dict->Dict.set(":" ++ (name ++ ("(" ++ (param ++ ")"))), toJson(ruleset)) } dict } -and toJson = rules => rules->Belt.Array.reduce(Js.Dict.empty(), ruleToDict)->Js.Json.object_ +and toJson = rules => rules->Belt.Array.reduce(Dict.make(), ruleToDict)->JSON.object_ module Make = (CssImplementation: Css_Core.CssImplementationIntf) => { let merge = (stylenames) => CssImplementation.mergeStyles(stylenames) @@ -30,11 +30,11 @@ module Make = (CssImplementation: Css_Core.CssImplementationIntf) => { let style = (rules) => CssImplementation.make(rules->toJson) let global = (selector, rules) => - CssImplementation.injectRule([(selector, toJson(rules))]->Js.Dict.fromArray->Js.Json.object_) + CssImplementation.injectRule([(selector, toJson(rules))]->Dict.fromArray->JSON.object_) let keyframes = (frames) => - CssImplementation.makeKeyFrames(frames->Belt.Array.reduceU(Js.Dict.empty(), (dict, (stop, rules)) => { - Js.Dict.set(dict, Js.Int.toString(stop) ++ "%", toJson(rules)) + CssImplementation.makeKeyFrames(frames->Belt.Array.reduceU(Dict.make(), (dict, (stop, rules)) => { + Dict.set(dict, Int.toString(stop) ++ "%", toJson(rules)) dict }), ) @@ -46,7 +46,7 @@ let join = (strings, separator) => ) module Converter = { - let string_of_time = t => Js.Int.toString(t) ++ "ms" + let string_of_time = t => Int.toString(t) ++ "ms" let string_of_content = x => switch x { @@ -397,7 +397,7 @@ let flex = x => D( "flex", switch x { | #...Flex.t as f => Flex.toString(f) - | #num(n) => Js.Float.toString(n) + | #num(n) => Float.toString(n) }, ) @@ -410,9 +410,9 @@ let flexDirection = x => D( }, ) -let flexGrow = x => D("flexGrow", Js.Float.toString(x)) +let flexGrow = x => D("flexGrow", Float.toString(x)) -let flexShrink = x => D("flexShrink", Js.Float.toString(x)) +let flexShrink = x => D("flexShrink", Float.toString(x)) let flexWrap = x => D( "flexWrap", @@ -490,18 +490,18 @@ let gridAutoFlow = x => D( let gridColumn = (start, end') => D( "gridColumn", - Js.Int.toString(start) ++ (" / " ++ Js.Int.toString(end')), + Int.toString(start) ++ (" / " ++ Int.toString(end')), ) let gridColumnGap = x => D("gridColumnGap", string_of_column_gap(x)) -let gridColumnStart = n => D("gridColumnStart", Js.Int.toString(n)) +let gridColumnStart = n => D("gridColumnStart", Int.toString(n)) -let gridColumnEnd = n => D("gridColumnEnd", Js.Int.toString(n)) +let gridColumnEnd = n => D("gridColumnEnd", Int.toString(n)) let gridRow = (start, end') => D( "gridRow", - Js.Int.toString(start) ++ (" / " ++ Js.Int.toString(end')), + Int.toString(start) ++ (" / " ++ Int.toString(end')), ) let gridGap = x => D( @@ -524,9 +524,9 @@ let gridRowGap = x => D( }, ) -let gridRowEnd = n => D("gridRowEnd", Js.Int.toString(n)) +let gridRowEnd = n => D("gridRowEnd", Int.toString(n)) -let gridRowStart = n => D("gridRowStart", Js.Int.toString(n)) +let gridRowStart = n => D("gridRowStart", Int.toString(n)) let height = x => D( "height", @@ -705,7 +705,7 @@ let objectFit = x => D( let objectPosition = x => D("objectPosition", string_of_backgroundposition(x)) -let opacity = x => D("opacity", Js.Float.toString(x)) +let opacity = x => D("opacity", Float.toString(x)) let outline = (size, style, color) => D( "outline", @@ -982,7 +982,7 @@ let wordSpacing = x => D( let wordWrap = overflowWrap -let zIndex = x => D("zIndex", Js.Int.toString(x)) +let zIndex = x => D("zIndex", Int.toString(x)) /* Selectors */ @@ -1023,8 +1023,8 @@ module Nth = { switch x { | #odd => "odd" | #even => "even" - | #n(x) => Js.Int.toString(x) ++ "n" - | #add(x, y) => Js.Int.toString(x) ++ ("n+" ++ Js.Int.toString(y)) + | #n(x) => Int.toString(x) ++ "n" + | #add(x, y) => Int.toString(x) ++ ("n+" ++ Int.toString(y)) } } let nthChild = (x, rules) => PseudoClassParam("nth-child", Nth.toString(x), rules) @@ -1362,9 +1362,9 @@ let square = #square let flex3 = (~grow, ~shrink, ~basis) => D( "flex", - Js.Float.toString(grow) ++ + Float.toString(grow) ++ (" " ++ - (Js.Float.toString(shrink) ++ + (Float.toString(shrink) ++ (" " ++ switch basis { | #...FlexBasis.t as b => FlexBasis.toString(b) @@ -1379,30 +1379,30 @@ let flexBasis = x => D( }, ) -let order = x => D("order", Js.Int.toString(x)) +let order = x => D("order", Int.toString(x)) let string_of_minmax = x => switch x { | #auto => "auto" | #calc(#add, a, b) => "calc(" ++ (Length.toString(a) ++ (" + " ++ (Length.toString(b) ++ ")"))) | #calc(#sub, a, b) => "calc(" ++ (Length.toString(a) ++ (" - " ++ (Length.toString(b) ++ ")"))) - | #ch(x) => Js.Float.toString(x) ++ "ch" - | #cm(x) => Js.Float.toString(x) ++ "cm" - | #em(x) => Js.Float.toString(x) ++ "em" - | #ex(x) => Js.Float.toString(x) ++ "ex" - | #mm(x) => Js.Float.toString(x) ++ "mm" - | #percent(x) => Js.Float.toString(x) ++ "%" - | #pt(x) => Js.Int.toString(x) ++ "pt" - | #px(x) => Js.Int.toString(x) ++ "px" - | #pxFloat(x) => Js.Float.toString(x) ++ "px" - | #rem(x) => Js.Float.toString(x) ++ "rem" - | #vh(x) => Js.Float.toString(x) ++ "vh" - | #vmax(x) => Js.Float.toString(x) ++ "vmax" - | #vmin(x) => Js.Float.toString(x) ++ "vmin" - | #vw(x) => Js.Float.toString(x) ++ "vw" - | #fr(x) => Js.Float.toString(x) ++ "fr" - | #inch(x) => Js.Float.toString(x) ++ "in" - | #pc(x) => Js.Float.toString(x) ++ "pc" + | #ch(x) => Float.toString(x) ++ "ch" + | #cm(x) => Float.toString(x) ++ "cm" + | #em(x) => Float.toString(x) ++ "em" + | #ex(x) => Float.toString(x) ++ "ex" + | #mm(x) => Float.toString(x) ++ "mm" + | #percent(x) => Float.toString(x) ++ "%" + | #pt(x) => Int.toString(x) ++ "pt" + | #px(x) => Int.toString(x) ++ "px" + | #pxFloat(x) => Float.toString(x) ++ "px" + | #rem(x) => Float.toString(x) ++ "rem" + | #vh(x) => Float.toString(x) ++ "vh" + | #vmax(x) => Float.toString(x) ++ "vmax" + | #vmin(x) => Float.toString(x) ++ "vmin" + | #vw(x) => Float.toString(x) ++ "vw" + | #fr(x) => Float.toString(x) ++ "fr" + | #inch(x) => Float.toString(x) ++ "in" + | #pc(x) => Float.toString(x) ++ "pc" | #zero => "0" | #minContent => "min-content" | #maxContent => "max-content" @@ -1414,23 +1414,23 @@ let string_of_dimension = x => | #none => "none" | #calc(#add, a, b) => "calc(" ++ (Length.toString(a) ++ (" + " ++ (Length.toString(b) ++ ")"))) | #calc(#sub, a, b) => "calc(" ++ (Length.toString(a) ++ (" - " ++ (Length.toString(b) ++ ")"))) - | #ch(x) => Js.Float.toString(x) ++ "ch" - | #cm(x) => Js.Float.toString(x) ++ "cm" - | #em(x) => Js.Float.toString(x) ++ "em" - | #ex(x) => Js.Float.toString(x) ++ "ex" - | #mm(x) => Js.Float.toString(x) ++ "mm" - | #percent(x) => Js.Float.toString(x) ++ "%" - | #pt(x) => Js.Int.toString(x) ++ "pt" - | #px(x) => Js.Int.toString(x) ++ "px" - | #pxFloat(x) => Js.Float.toString(x) ++ "px" - | #rem(x) => Js.Float.toString(x) ++ "rem" - | #vh(x) => Js.Float.toString(x) ++ "vh" - | #vmax(x) => Js.Float.toString(x) ++ "vmax" - | #vmin(x) => Js.Float.toString(x) ++ "vmin" - | #vw(x) => Js.Float.toString(x) ++ "vw" - | #fr(x) => Js.Float.toString(x) ++ "fr" - | #inch(x) => Js.Float.toString(x) ++ "in" - | #pc(x) => Js.Float.toString(x) ++ "pc" + | #ch(x) => Float.toString(x) ++ "ch" + | #cm(x) => Float.toString(x) ++ "cm" + | #em(x) => Float.toString(x) ++ "em" + | #ex(x) => Float.toString(x) ++ "ex" + | #mm(x) => Float.toString(x) ++ "mm" + | #percent(x) => Float.toString(x) ++ "%" + | #pt(x) => Int.toString(x) ++ "pt" + | #px(x) => Int.toString(x) ++ "px" + | #pxFloat(x) => Float.toString(x) ++ "px" + | #rem(x) => Float.toString(x) ++ "rem" + | #vh(x) => Float.toString(x) ++ "vh" + | #vmax(x) => Float.toString(x) ++ "vmax" + | #vmin(x) => Float.toString(x) ++ "vmin" + | #vw(x) => Float.toString(x) ++ "vw" + | #fr(x) => Float.toString(x) ++ "fr" + | #inch(x) => Float.toString(x) ++ "in" + | #pc(x) => Float.toString(x) ++ "pc" | #zero => "0" | #fitContent => "fit-content" | #minContent => "min-content" @@ -1455,23 +1455,23 @@ let gridLengthToJs = x => | #auto => "auto" | #calc(#add, a, b) => "calc(" ++ (Length.toString(a) ++ (" + " ++ (Length.toString(b) ++ ")"))) | #calc(#sub, a, b) => "calc(" ++ (Length.toString(a) ++ (" - " ++ (Length.toString(b) ++ ")"))) - | #ch(x) => Js.Float.toString(x) ++ "ch" - | #cm(x) => Js.Float.toString(x) ++ "cm" - | #em(x) => Js.Float.toString(x) ++ "em" - | #ex(x) => Js.Float.toString(x) ++ "ex" - | #mm(x) => Js.Float.toString(x) ++ "mm" - | #percent(x) => Js.Float.toString(x) ++ "%" - | #pt(x) => Js.Int.toString(x) ++ "pt" - | #px(x) => Js.Int.toString(x) ++ "px" - | #pxFloat(x) => Js.Float.toString(x) ++ "px" - | #rem(x) => Js.Float.toString(x) ++ "rem" - | #vh(x) => Js.Float.toString(x) ++ "vh" - | #inch(x) => Js.Float.toString(x) ++ "in" - | #pc(x) => Js.Float.toString(x) ++ "pc" - | #vmax(x) => Js.Float.toString(x) ++ "vmax" - | #vmin(x) => Js.Float.toString(x) ++ "vmin" - | #vw(x) => Js.Float.toString(x) ++ "vw" - | #fr(x) => Js.Float.toString(x) ++ "fr" + | #ch(x) => Float.toString(x) ++ "ch" + | #cm(x) => Float.toString(x) ++ "cm" + | #em(x) => Float.toString(x) ++ "em" + | #ex(x) => Float.toString(x) ++ "ex" + | #mm(x) => Float.toString(x) ++ "mm" + | #percent(x) => Float.toString(x) ++ "%" + | #pt(x) => Int.toString(x) ++ "pt" + | #px(x) => Int.toString(x) ++ "px" + | #pxFloat(x) => Float.toString(x) ++ "px" + | #rem(x) => Float.toString(x) ++ "rem" + | #vh(x) => Float.toString(x) ++ "vh" + | #inch(x) => Float.toString(x) ++ "in" + | #pc(x) => Float.toString(x) ++ "pc" + | #vmax(x) => Float.toString(x) ++ "vmax" + | #vmin(x) => Float.toString(x) ++ "vmin" + | #vw(x) => Float.toString(x) ++ "vw" + | #fr(x) => Float.toString(x) ++ "fr" | #zero => "0" | #minContent => "min-content" | #maxContent => "max-content" @@ -1544,20 +1544,20 @@ type filter = [ let string_of_filter = x => switch x { | #blur(v) => "blur(" ++ (Length.toString(v) ++ ")") - | #brightness(v) => "brightness(" ++ (Js.Float.toString(v) ++ "%)") - | #contrast(v) => "contrast(" ++ (Js.Float.toString(v) ++ "%)") + | #brightness(v) => "brightness(" ++ (Float.toString(v) ++ "%)") + | #contrast(v) => "contrast(" ++ (Float.toString(v) ++ "%)") | #dropShadow(a, b, c, d) => "drop-shadow(" ++ (Length.toString(a) ++ (" " ++ (Length.toString(b) ++ (" " ++ (Length.toString(c) ++ (" " ++ (Color.toString(d) ++ ")"))))))) - | #grayscale(v) => "grayscale(" ++ (Js.Float.toString(v) ++ "%)") + | #grayscale(v) => "grayscale(" ++ (Float.toString(v) ++ "%)") | #hueRotate(v) => "hue-rotate(" ++ (Angle.toString(v) ++ ")") - | #invert(v) => "invert(" ++ (Js.Float.toString(v) ++ "%)") - | #opacity(v) => "opacity(" ++ (Js.Float.toString(v) ++ "%)") - | #saturate(v) => "saturate(" ++ (Js.Float.toString(v) ++ "%)") - | #sepia(v) => "sepia(" ++ (Js.Float.toString(v) ++ "%)") + | #invert(v) => "invert(" ++ (Float.toString(v) ++ "%)") + | #opacity(v) => "opacity(" ++ (Float.toString(v) ++ "%)") + | #saturate(v) => "saturate(" ++ (Float.toString(v) ++ "%)") + | #sepia(v) => "sepia(" ++ (Float.toString(v) ++ "%)") | #none => "none" | #...Url.t as u => Url.toString(u) | #...Var.t as va => Var.toString(va) @@ -1684,7 +1684,7 @@ let backgroundSize = x => D( ) let fontFace = (~fontFamily, ~src, ~fontStyle=?, ~fontWeight=?, ~fontDisplay=?, ()) => { - let fontStyle = Js.Option.map((value) => FontStyle.toString(value), fontStyle) + let fontStyle = Option.map((value) => FontStyle.toString(value), fontStyle) let src = src ->Belt.Array.map(x => @@ -1871,7 +1871,7 @@ module SVG = { | #...Types.Url.t as u => Types.Url.toString(u) }, ) - let fillOpacity = opacity => D("fillOpacity", Js.Float.toString(opacity)) + let fillOpacity = opacity => D("fillOpacity", Float.toString(opacity)) let fillRule = x => D( "fillRule", switch x { @@ -1888,8 +1888,8 @@ module SVG = { }, ) let strokeWidth = x => D("strokeWidth", Length.toString(x)) - let strokeOpacity = opacity => D("strokeOpacity", Js.Float.toString(opacity)) - let strokeMiterlimit = x => D("strokeMiterlimit", Js.Float.toString(x)) + let strokeOpacity = opacity => D("strokeOpacity", Float.toString(opacity)) + let strokeMiterlimit = x => D("strokeMiterlimit", Float.toString(x)) let strokeLinecap = x => D( "strokeLinecap", switch x { @@ -1908,5 +1908,5 @@ module SVG = { }, ) let stopColor = x => D("stopColor", string_of_color(x)) - let stopOpacity = x => D("stopOpacity", Js.Float.toString(x)) + let stopOpacity = x => D("stopOpacity", Float.toString(x)) } diff --git a/tests/syntax_tests/data/idempotency/bs-css/Css_Js_Core.resi b/tests/syntax_tests/data/idempotency/bs-css/Css_Js_Core.resi index b1e07087b1c..22c74118a4c 100644 --- a/tests/syntax_tests/data/idempotency/bs-css/Css_Js_Core.resi +++ b/tests/syntax_tests/data/idempotency/bs-css/Css_Js_Core.resi @@ -14,7 +14,7 @@ module Make: Css_Core.CssImplementationIntf => let keyframes: (array<(int, array)>) => animationName } -let toJson: array => Js.Json.t +let toJson: array => JSON.t let important: rule => rule let label: string => rule @@ -1237,7 +1237,7 @@ let before: array => rule ") let firstLetter: array => rule -@ocaml.doc(",LÀ»›,") +@ocaml.doc(",L���,") let firstLine: array => rule @ocaml.doc(" diff --git a/tests/syntax_tests/data/idempotency/bs-css/Css_Legacy_Core.res b/tests/syntax_tests/data/idempotency/bs-css/Css_Legacy_Core.res index b3d081408df..c394c084c45 100644 --- a/tests/syntax_tests/data/idempotency/bs-css/Css_Legacy_Core.res +++ b/tests/syntax_tests/data/idempotency/bs-css/Css_Legacy_Core.res @@ -10,20 +10,20 @@ type rec rule = let rec ruleToDict = (dict, rule) => { switch rule { | D(name, value) if name == "content" => - dict->Js.Dict.set(name, Js.Json.string(value == "" ? "\"\"" : value)) - | D(name, value) => dict->Js.Dict.set(name, Js.Json.string(value)) - | S(name, ruleset) => dict->Js.Dict.set(name, toJson(ruleset)) - | PseudoClass(name, ruleset) => dict->Js.Dict.set(":" ++ name, toJson(ruleset)) + dict->Dict.set(name, JSON.string(value == "" ? "\"\"" : value)) + | D(name, value) => dict->Dict.set(name, JSON.string(value)) + | S(name, ruleset) => dict->Dict.set(name, toJson(ruleset)) + | PseudoClass(name, ruleset) => dict->Dict.set(":" ++ name, toJson(ruleset)) | PseudoClassParam(name, param, ruleset) => - dict->Js.Dict.set(":" ++ (name ++ ("(" ++ (param ++ ")"))), toJson(ruleset)) + dict->Dict.set(":" ++ (name ++ ("(" ++ (param ++ ")"))), toJson(ruleset)) } dict } -and toJson = rules => rules->Belt.List.reduce(Js.Dict.empty(), ruleToDict)->Js.Json.object_ +and toJson = rules => rules->Belt.List.reduce(Dict.make(), ruleToDict)->JSON.object_ let addStop = (dict, (stop, rules)) => { - Js.Dict.set(dict, Js.Int.toString(stop) ++ "%", toJson(rules)) + Dict.set(dict, Int.toString(stop) ++ "%", toJson(rules)) dict } @@ -35,11 +35,11 @@ module Make = (CssImplementation: Css_Core.CssImplementationIntf) => { let style = rules => CssImplementation.make(rules->toJson) let global = (selector, rules: list) => - CssImplementation.injectRule(list{(selector, toJson(rules))}->Js.Dict.fromList->Js.Json.object_, + CssImplementation.injectRule(list{(selector, toJson(rules))}->Dict.fromList->JSON.object_, ) let keyframes = frames => - CssImplementation.makeKeyFrames(List.fold_left(addStop, Js.Dict.empty(), frames)) + CssImplementation.makeKeyFrames(List.fold_left(addStop, Dict.make(), frames)) } let join = (strings, separator) => { @@ -56,7 +56,7 @@ module Converter = { let string_of_stops = stops => stops->Belt.List.map(((l, c)) => Color.toString(c) ++ (" " ++ Length.toString(l)))->join(", ") - let string_of_time = t => Js.Int.toString(t) ++ "ms" + let string_of_time = t => Int.toString(t) ++ "ms" let string_of_content = x => switch x { @@ -407,7 +407,7 @@ let flex = x => D( "flex", switch x { | #...Flex.t as f => Flex.toString(f) - | #num(n) => Js.Float.toString(n) + | #num(n) => Float.toString(n) }, ) @@ -420,9 +420,9 @@ let flexDirection = x => D( }, ) -let flexGrow = x => D("flexGrow", Js.Float.toString(x)) +let flexGrow = x => D("flexGrow", Float.toString(x)) -let flexShrink = x => D("flexShrink", Js.Float.toString(x)) +let flexShrink = x => D("flexShrink", Float.toString(x)) let flexWrap = x => D( "flexWrap", @@ -500,18 +500,18 @@ let gridAutoFlow = x => D( let gridColumn = (start, end') => D( "gridColumn", - Js.Int.toString(start) ++ (" / " ++ Js.Int.toString(end')), + Int.toString(start) ++ (" / " ++ Int.toString(end')), ) let gridColumnGap = x => D("gridColumnGap", string_of_column_gap(x)) -let gridColumnStart = n => D("gridColumnStart", Js.Int.toString(n)) +let gridColumnStart = n => D("gridColumnStart", Int.toString(n)) -let gridColumnEnd = n => D("gridColumnEnd", Js.Int.toString(n)) +let gridColumnEnd = n => D("gridColumnEnd", Int.toString(n)) let gridRow = (start, end') => D( "gridRow", - Js.Int.toString(start) ++ (" / " ++ Js.Int.toString(end')), + Int.toString(start) ++ (" / " ++ Int.toString(end')), ) let gridGap = x => D( @@ -534,9 +534,9 @@ let gridRowGap = x => D( }, ) -let gridRowEnd = n => D("gridRowEnd", Js.Int.toString(n)) +let gridRowEnd = n => D("gridRowEnd", Int.toString(n)) -let gridRowStart = n => D("gridRowStart", Js.Int.toString(n)) +let gridRowStart = n => D("gridRowStart", Int.toString(n)) let height = x => D( "height", @@ -715,7 +715,7 @@ let objectFit = x => D( let objectPosition = x => D("objectPosition", string_of_backgroundposition(x)) -let opacity = x => D("opacity", Js.Float.toString(x)) +let opacity = x => D("opacity", Float.toString(x)) let outline = (size, style, color) => D( "outline", @@ -992,7 +992,7 @@ let wordSpacing = x => D( let wordWrap = overflowWrap -let zIndex = x => D("zIndex", Js.Int.toString(x)) +let zIndex = x => D("zIndex", Int.toString(x)) /* Selectors */ @@ -1033,8 +1033,8 @@ module Nth = { switch x { | #odd => "odd" | #even => "even" - | #n(x) => Js.Int.toString(x) ++ "n" - | #add(x, y) => Js.Int.toString(x) ++ ("n+" ++ Js.Int.toString(y)) + | #n(x) => Int.toString(x) ++ "n" + | #add(x, y) => Int.toString(x) ++ ("n+" ++ Int.toString(y)) } } let nthChild = (x, rules) => PseudoClassParam("nth-child", Nth.toString(x), rules) @@ -1372,9 +1372,9 @@ let square = #square let flex3 = (~grow, ~shrink, ~basis) => D( "flex", - Js.Float.toString(grow) ++ + Float.toString(grow) ++ (" " ++ - (Js.Float.toString(shrink) ++ + (Float.toString(shrink) ++ (" " ++ switch basis { | #...FlexBasis.t as b => FlexBasis.toString(b) @@ -1389,30 +1389,30 @@ let flexBasis = x => D( }, ) -let order = x => D("order", Js.Int.toString(x)) +let order = x => D("order", Int.toString(x)) let string_of_minmax = x => switch x { | #auto => "auto" | #calc(#add, a, b) => "calc(" ++ (Length.toString(a) ++ (" + " ++ (Length.toString(b) ++ ")"))) | #calc(#sub, a, b) => "calc(" ++ (Length.toString(a) ++ (" - " ++ (Length.toString(b) ++ ")"))) - | #ch(x) => Js.Float.toString(x) ++ "ch" - | #cm(x) => Js.Float.toString(x) ++ "cm" - | #em(x) => Js.Float.toString(x) ++ "em" - | #ex(x) => Js.Float.toString(x) ++ "ex" - | #mm(x) => Js.Float.toString(x) ++ "mm" - | #percent(x) => Js.Float.toString(x) ++ "%" - | #pt(x) => Js.Int.toString(x) ++ "pt" - | #px(x) => Js.Int.toString(x) ++ "px" - | #pxFloat(x) => Js.Float.toString(x) ++ "px" - | #rem(x) => Js.Float.toString(x) ++ "rem" - | #vh(x) => Js.Float.toString(x) ++ "vh" - | #vmax(x) => Js.Float.toString(x) ++ "vmax" - | #vmin(x) => Js.Float.toString(x) ++ "vmin" - | #vw(x) => Js.Float.toString(x) ++ "vw" - | #fr(x) => Js.Float.toString(x) ++ "fr" - | #inch(x) => Js.Float.toString(x) ++ "in" - | #pc(x) => Js.Float.toString(x) ++ "pc" + | #ch(x) => Float.toString(x) ++ "ch" + | #cm(x) => Float.toString(x) ++ "cm" + | #em(x) => Float.toString(x) ++ "em" + | #ex(x) => Float.toString(x) ++ "ex" + | #mm(x) => Float.toString(x) ++ "mm" + | #percent(x) => Float.toString(x) ++ "%" + | #pt(x) => Int.toString(x) ++ "pt" + | #px(x) => Int.toString(x) ++ "px" + | #pxFloat(x) => Float.toString(x) ++ "px" + | #rem(x) => Float.toString(x) ++ "rem" + | #vh(x) => Float.toString(x) ++ "vh" + | #vmax(x) => Float.toString(x) ++ "vmax" + | #vmin(x) => Float.toString(x) ++ "vmin" + | #vw(x) => Float.toString(x) ++ "vw" + | #fr(x) => Float.toString(x) ++ "fr" + | #inch(x) => Float.toString(x) ++ "in" + | #pc(x) => Float.toString(x) ++ "pc" | #zero => "0" | #minContent => "min-content" | #maxContent => "max-content" @@ -1424,23 +1424,23 @@ let string_of_dimension = x => | #none => "none" | #calc(#add, a, b) => "calc(" ++ (Length.toString(a) ++ (" + " ++ (Length.toString(b) ++ ")"))) | #calc(#sub, a, b) => "calc(" ++ (Length.toString(a) ++ (" - " ++ (Length.toString(b) ++ ")"))) - | #ch(x) => Js.Float.toString(x) ++ "ch" - | #cm(x) => Js.Float.toString(x) ++ "cm" - | #em(x) => Js.Float.toString(x) ++ "em" - | #ex(x) => Js.Float.toString(x) ++ "ex" - | #mm(x) => Js.Float.toString(x) ++ "mm" - | #percent(x) => Js.Float.toString(x) ++ "%" - | #pt(x) => Js.Int.toString(x) ++ "pt" - | #px(x) => Js.Int.toString(x) ++ "px" - | #pxFloat(x) => Js.Float.toString(x) ++ "px" - | #rem(x) => Js.Float.toString(x) ++ "rem" - | #vh(x) => Js.Float.toString(x) ++ "vh" - | #vmax(x) => Js.Float.toString(x) ++ "vmax" - | #vmin(x) => Js.Float.toString(x) ++ "vmin" - | #vw(x) => Js.Float.toString(x) ++ "vw" - | #fr(x) => Js.Float.toString(x) ++ "fr" - | #inch(x) => Js.Float.toString(x) ++ "in" - | #pc(x) => Js.Float.toString(x) ++ "pc" + | #ch(x) => Float.toString(x) ++ "ch" + | #cm(x) => Float.toString(x) ++ "cm" + | #em(x) => Float.toString(x) ++ "em" + | #ex(x) => Float.toString(x) ++ "ex" + | #mm(x) => Float.toString(x) ++ "mm" + | #percent(x) => Float.toString(x) ++ "%" + | #pt(x) => Int.toString(x) ++ "pt" + | #px(x) => Int.toString(x) ++ "px" + | #pxFloat(x) => Float.toString(x) ++ "px" + | #rem(x) => Float.toString(x) ++ "rem" + | #vh(x) => Float.toString(x) ++ "vh" + | #vmax(x) => Float.toString(x) ++ "vmax" + | #vmin(x) => Float.toString(x) ++ "vmin" + | #vw(x) => Float.toString(x) ++ "vw" + | #fr(x) => Float.toString(x) ++ "fr" + | #inch(x) => Float.toString(x) ++ "in" + | #pc(x) => Float.toString(x) ++ "pc" | #zero => "0" | #fitContent => "fit-content" | #minContent => "min-content" @@ -1465,23 +1465,23 @@ let gridLengthToJs = x => | #auto => "auto" | #calc(#add, a, b) => "calc(" ++ (Length.toString(a) ++ (" + " ++ (Length.toString(b) ++ ")"))) | #calc(#sub, a, b) => "calc(" ++ (Length.toString(a) ++ (" - " ++ (Length.toString(b) ++ ")"))) - | #ch(x) => Js.Float.toString(x) ++ "ch" - | #cm(x) => Js.Float.toString(x) ++ "cm" - | #em(x) => Js.Float.toString(x) ++ "em" - | #ex(x) => Js.Float.toString(x) ++ "ex" - | #mm(x) => Js.Float.toString(x) ++ "mm" - | #percent(x) => Js.Float.toString(x) ++ "%" - | #pt(x) => Js.Int.toString(x) ++ "pt" - | #px(x) => Js.Int.toString(x) ++ "px" - | #pxFloat(x) => Js.Float.toString(x) ++ "px" - | #rem(x) => Js.Float.toString(x) ++ "rem" - | #vh(x) => Js.Float.toString(x) ++ "vh" - | #inch(x) => Js.Float.toString(x) ++ "in" - | #pc(x) => Js.Float.toString(x) ++ "pc" - | #vmax(x) => Js.Float.toString(x) ++ "vmax" - | #vmin(x) => Js.Float.toString(x) ++ "vmin" - | #vw(x) => Js.Float.toString(x) ++ "vw" - | #fr(x) => Js.Float.toString(x) ++ "fr" + | #ch(x) => Float.toString(x) ++ "ch" + | #cm(x) => Float.toString(x) ++ "cm" + | #em(x) => Float.toString(x) ++ "em" + | #ex(x) => Float.toString(x) ++ "ex" + | #mm(x) => Float.toString(x) ++ "mm" + | #percent(x) => Float.toString(x) ++ "%" + | #pt(x) => Int.toString(x) ++ "pt" + | #px(x) => Int.toString(x) ++ "px" + | #pxFloat(x) => Float.toString(x) ++ "px" + | #rem(x) => Float.toString(x) ++ "rem" + | #vh(x) => Float.toString(x) ++ "vh" + | #inch(x) => Float.toString(x) ++ "in" + | #pc(x) => Float.toString(x) ++ "pc" + | #vmax(x) => Float.toString(x) ++ "vmax" + | #vmin(x) => Float.toString(x) ++ "vmin" + | #vw(x) => Float.toString(x) ++ "vw" + | #fr(x) => Float.toString(x) ++ "fr" | #zero => "0" | #minContent => "min-content" | #maxContent => "max-content" @@ -1555,20 +1555,20 @@ type filter = [ let string_of_filter = x => switch x { | #blur(v) => "blur(" ++ (Length.toString(v) ++ ")") - | #brightness(v) => "brightness(" ++ (Js.Float.toString(v) ++ "%)") - | #contrast(v) => "contrast(" ++ (Js.Float.toString(v) ++ "%)") + | #brightness(v) => "brightness(" ++ (Float.toString(v) ++ "%)") + | #contrast(v) => "contrast(" ++ (Float.toString(v) ++ "%)") | #dropShadow(a, b, c, d) => "drop-shadow(" ++ (Length.toString(a) ++ (" " ++ (Length.toString(b) ++ (" " ++ (Length.toString(c) ++ (" " ++ (Color.toString(d) ++ ")"))))))) - | #grayscale(v) => "grayscale(" ++ (Js.Float.toString(v) ++ "%)") + | #grayscale(v) => "grayscale(" ++ (Float.toString(v) ++ "%)") | #hueRotate(v) => "hue-rotate(" ++ (Angle.toString(v) ++ ")") - | #invert(v) => "invert(" ++ (Js.Float.toString(v) ++ "%)") - | #opacity(v) => "opacity(" ++ (Js.Float.toString(v) ++ "%)") - | #saturate(v) => "saturate(" ++ (Js.Float.toString(v) ++ "%)") - | #sepia(v) => "sepia(" ++ (Js.Float.toString(v) ++ "%)") + | #invert(v) => "invert(" ++ (Float.toString(v) ++ "%)") + | #opacity(v) => "opacity(" ++ (Float.toString(v) ++ "%)") + | #saturate(v) => "saturate(" ++ (Float.toString(v) ++ "%)") + | #sepia(v) => "sepia(" ++ (Float.toString(v) ++ "%)") | #none => "none" | #...Url.t as u => Url.toString(u) | #...Var.t as va => Var.toString(va) @@ -1695,7 +1695,7 @@ let backgroundSize = x => D( ) let fontFace = (~fontFamily, ~src, ~fontStyle=?, ~fontWeight=?, ~fontDisplay=?, ()) => { - let fontStyle = Js.Option.map((value) => FontStyle.toString(value), fontStyle) + let fontStyle = Option.map((value) => FontStyle.toString(value), fontStyle) let src = src ->List.map(x => @@ -1882,7 +1882,7 @@ module SVG = { | #...Types.Url.t as u => Types.Url.toString(u) }, ) - let fillOpacity = opacity => D("fillOpacity", Js.Float.toString(opacity)) + let fillOpacity = opacity => D("fillOpacity", Float.toString(opacity)) let fillRule = x => D( "fillRule", switch x { @@ -1899,8 +1899,8 @@ module SVG = { }, ) let strokeWidth = x => D("strokeWidth", Length.toString(x)) - let strokeOpacity = opacity => D("strokeOpacity", Js.Float.toString(opacity)) - let strokeMiterlimit = x => D("strokeMiterlimit", Js.Float.toString(x)) + let strokeOpacity = opacity => D("strokeOpacity", Float.toString(opacity)) + let strokeMiterlimit = x => D("strokeMiterlimit", Float.toString(x)) let strokeLinecap = x => D( "strokeLinecap", switch x { @@ -1919,5 +1919,5 @@ module SVG = { }, ) let stopColor = x => D("stopColor", string_of_color(x)) - let stopOpacity = x => D("stopOpacity", Js.Float.toString(x)) + let stopOpacity = x => D("stopOpacity", Float.toString(x)) } diff --git a/tests/syntax_tests/data/idempotency/bs-css/Css_Legacy_Core.resi b/tests/syntax_tests/data/idempotency/bs-css/Css_Legacy_Core.resi index f601ed4b0d0..0e6de937424 100644 --- a/tests/syntax_tests/data/idempotency/bs-css/Css_Legacy_Core.resi +++ b/tests/syntax_tests/data/idempotency/bs-css/Css_Legacy_Core.resi @@ -14,7 +14,7 @@ module Make: Css_Core.CssImplementationIntf => let keyframes: list<(int, list)> => animationName } -let toJson: list => Js.Json.t +let toJson: list => JSON.t let important: rule => rule let label: string => rule diff --git a/tests/syntax_tests/data/idempotency/bs-css/Css_test.res b/tests/syntax_tests/data/idempotency/bs-css/Css_test.res index 174eaed77dc..c81e7eb7387 100644 --- a/tests/syntax_tests/data/idempotency/bs-css/Css_test.res +++ b/tests/syntax_tests/data/idempotency/bs-css/Css_test.res @@ -16,12 +16,12 @@ open Jest open Expect open CssForTest -let toBeJson = x => Expect.toBe(x->Js.Json.stringifyAny) +let toBeJson = x => Expect.toBe(x->JSON.stringifyAny) let r = x => toJson(list{x}) /* simple rule for more readable tests */ describe("Var", () => { test("test usage (limited)", () => - expect((r(color(var("foo"))), r(marginTop(var("--bar"))))->Js.Json.stringifyAny)->toBeJson(( + expect((r(color(var("foo"))), r(marginTop(var("--bar"))))->JSON.stringifyAny)->toBeJson(( {"color": "var(--foo)"}, {"marginTop": "var(--bar)"}, )) @@ -32,7 +32,7 @@ describe("Var", () => { ( r(textDecoration(varDefault("foo", "default"))), r(alignItems(varDefault("--bar", "default"))), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(({"textDecoration": "var(--foo,default)"}, {"alignItems": "var(--bar,default)"})) ) }) @@ -49,7 +49,7 @@ describe("Color style", () => r(color(transparent)), r(color(hex("FFF"))), r(color(currentColor)), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"color": "rgb(1, 2, 3)"}, {"color": "rgba(4, 5, 6, 0.3)"}, @@ -64,7 +64,7 @@ describe("Color style", () => ) describe("Label", () => - test("test value", () => expect(r(label("a"))->Js.Json.stringifyAny)->toBeJson({"label": "a"})) + test("test value", () => expect(r(label("a"))->JSON.stringifyAny)->toBeJson({"label": "a"})) ) // test("test classname", () => // expect(style([label("theName")]))->toContainString("theName") @@ -84,7 +84,7 @@ describe("Filter", () => r(filter(list{#initial})), r(filter(list{#unset})), r(filter(list{#url("myurl")})), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"filter": "opacity(10%) invert(20%)"}, {"filter": "blur(20px) brightness(20%)"}, @@ -108,7 +108,7 @@ describe("Angle", () => r(transform(rotate(rad(6.28)))), r(transform(rotate(grad(38.8)))), r(transform(rotate(turn(0.25)))), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"transform": "rotate(1deg)"}, {"transform": "rotate(6.28rad)"}, @@ -128,7 +128,7 @@ describe("Direction", () => r(direction(inherit_)), r(direction(unset)), r(direction(initial)), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"direction": "ltr"}, {"direction": "ltr"}, @@ -153,7 +153,7 @@ describe("Resize", () => r(resize(inherit_)), r(resize(unset)), r(resize(initial)), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"resize": "none"}, {"resize": "both"}, @@ -178,7 +178,7 @@ describe("Backdrop filter", () => r(backdropFilter(list{#grayscale(#percent(99.9)), #hueRotate(#deg(90.0))})), r(backdropFilter(list{#invert(#num(30)), #opacity(#percent(10.0))})), r(backdropFilter(list{#saturate(#num(30)), #sepia(#percent(10.0))})), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"backdrop-filter": "none"}, {"backdrop-filter": "blur(10px), brightness(42%)"}, @@ -211,7 +211,7 @@ describe("Gradient background", () => }), ), ), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"background": "linear-gradient(45deg, #FF0000 0, #0000FF 100%)"}, { @@ -233,7 +233,7 @@ describe("Position", () => { r(right(rem(1.))), r(bottom(pct(20.))), r(left(vh(4.))), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(({"top": "10px"}, {"right": "1rem"}, {"bottom": "20%"}, {"left": "4vh"})) ) @@ -244,7 +244,7 @@ describe("Position", () => { r(right(inherit_)), r(bottom(unset)), r(left(initial)), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"top": "initial"}, {"right": "inherit"}, @@ -266,7 +266,7 @@ describe("object-fit", () => r(objectFit(#inherit_)), r(objectFit(#initial)), r(objectFit(#unset)), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"objectFit": "fill"}, {"objectFit": "contain"}, @@ -286,7 +286,7 @@ describe("box-shadow", () => { ( r(boxShadow(Shadow.box(green))), r(boxShadows(list{Shadow.box(yellow), Shadow.box(red)})), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"boxShadow": "0 0 0 0 #008000"}, {"boxShadow": "0 0 0 0 #FFFF00, 0 0 0 0 #FF0000"}, @@ -298,7 +298,7 @@ describe("box-shadow", () => { ( r(boxShadow(Shadow.box(~x=px(1), ~y=px(2), red))), r(boxShadow(Shadow.box(~inset=true, red))), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(({"boxShadow": "1px 2px 0 0 #FF0000"}, {"boxShadow": "0 0 0 0 #FF0000 inset"})) ) @@ -310,7 +310,7 @@ describe("box-shadow", () => { r(boxShadow(initial)), r(boxShadow(unset)), r(important(boxShadow(none))), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"boxShadow": "none"}, {"boxShadow": "inherit"}, @@ -327,7 +327,7 @@ describe("text-shadow", () => { ( r(textShadow(Shadow.text(green))), r(textShadows(list{Shadow.text(yellow), Shadow.text(red)})), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(({"textShadow": "0 0 0 #008000"}, {"textShadow": "0 0 0 #FFFF00, 0 0 0 #FF0000"})) ) @@ -336,7 +336,7 @@ describe("text-shadow", () => { ( r(textShadow(Shadow.text(~x=px(1), ~y=px(2), red))), r(textShadow(Shadow.text(~blur=vh(1.), red))), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(({"textShadow": "1px 2px 0 #FF0000"}, {"textShadow": "0 0 1vh #FF0000"})) ) @@ -348,7 +348,7 @@ describe("text-shadow", () => { r(textShadow(initial)), r(textShadow(unset)), r(important(textShadow(none))), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"textShadow": "none"}, {"textShadow": "inherit"}, @@ -365,7 +365,7 @@ describe("transitions", () => { ( r(transition("transform")), r(transitions(list{Transition.shorthand("height"), Transition.shorthand("top")})), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"transition": "0ms ease 0ms transform"}, {"transition": "0ms ease 0ms height, 0ms ease 0ms top"}, @@ -374,7 +374,7 @@ describe("transitions", () => { test("should use options when present", () => expect( - r(transition(~duration=3, ~delay=4, ~timingFunction=easeOut, "top"))->Js.Json.stringifyAny, + r(transition(~duration=3, ~delay=4, ~timingFunction=easeOut, "top"))->JSON.stringifyAny, )->toBeJson({"transition": "3ms ease-out 4ms top"}) ) }) @@ -392,7 +392,7 @@ describe("animation", () => { Animation.shorthand(toAnimationName("a2")), }), ), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"animation": "a 0ms ease 0ms 1 normal none running"}, { @@ -414,7 +414,7 @@ describe("animation", () => { ~iterationCount=infinite, toAnimationName("a"), ), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson({ "animation": "a 300ms linear 400ms infinite reverse forwards running", }) @@ -429,7 +429,7 @@ describe("Word spacing", () => r(wordSpacing(vh(1.))), r(wordSpacing(pct(50.))), r(wordSpacing(inherit_)), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"wordSpacing": "normal"}, {"wordSpacing": "1vh"}, @@ -448,7 +448,7 @@ describe("gridTemplateAreas", () => { r(gridTemplateAreas(#inherit_)), r(gridTemplateAreas(#initial)), r(gridTemplateAreas(#unset)), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"gridTemplateAreas": "none"}, {"gridTemplateAreas": "'a'"}, @@ -459,7 +459,7 @@ describe("gridTemplateAreas", () => { ) test("sucessfully combines list", () => - expect(r(gridTemplateAreas(#areas(list{"a a a", "b b b"})))->Js.Json.stringifyAny)->toBeJson({ + expect(r(gridTemplateAreas(#areas(list{"a a a", "b b b"})))->JSON.stringifyAny)->toBeJson({ "gridTemplateAreas": "'a a a' 'b b b'", }) ) @@ -478,7 +478,7 @@ describe("GridArea", () => { r(gridArea(#inherit_)), r(gridArea(#initial)), r(gridArea(#unset)), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"gridArea": "auto"}, {"gridArea": "a"}, @@ -498,7 +498,7 @@ describe("GridArea", () => { r(gridArea2(#auto, #num(1))), r(gridArea3(#ident("a"), #numIdent(1, "a"), #auto)), r(gridArea4(#num(5), #span(#num(16)), #span(#ident("b")), #auto)), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"gridArea": "auto / 1"}, {"gridArea": "a / 1 a / auto"}, @@ -510,7 +510,7 @@ describe("GridArea", () => { describe("gridTemplateCoumns", () => { test("concatenates list", () => expect( - r(gridTemplateColumns(list{#fr(1.), #px(100), #auto}))->Js.Json.stringifyAny, + r(gridTemplateColumns(list{#fr(1.), #px(100), #auto}))->JSON.stringifyAny, )->toBeJson({"gridTemplateColumns": "1fr 100px auto"}) ) @@ -523,7 +523,7 @@ describe("gridTemplateCoumns", () => { r(gridTemplateColumns(list{#repeat(#num(4), #maxContent)})), r(gridTemplateColumns(list{#repeat(#num(4), #minmax(#px(100), #fr(1.)))})), // r(gridTemplateColumns([`repeat(`num(4), `fitContent(`px(200)))])), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"gridTemplateColumns": "repeat(4, 1fr)"}, {"gridTemplateColumns": "repeat(4, auto)"}, @@ -548,7 +548,7 @@ describe("backgroundPosition", () => { r(backgroundPosition(initial)), r(backgroundPosition(inherit_)), r(backgroundPosition(unset)), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"backgroundPosition": "left"}, {"backgroundPosition": "right"}, @@ -569,7 +569,7 @@ describe("backgroundPosition", () => { r(backgroundPosition(#hv(#right, pct(50.)))), r(backgroundPosition(#hv(pct(50.), #top))), r(backgroundPosition(#hv(pct(50.), pct(50.)))), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"backgroundPosition": "left center"}, {"backgroundPosition": "right 50%"}, @@ -580,7 +580,7 @@ describe("backgroundPosition", () => { test("test multiple positions", () => expect( - r(backgroundPositions(list{#hv(px(0), px(0)), center}))->Js.Json.stringifyAny, + r(backgroundPositions(list{#hv(px(0), px(0)), center}))->JSON.stringifyAny, )->toBeJson({"backgroundPosition": "0px 0px, center"}) ) @@ -588,7 +588,7 @@ describe("backgroundPosition", () => { expect( r( backgroundPosition4(~y=#top, ~offsetY=px(10), ~x=#right, ~offsetX=px(50)), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson({"backgroundPosition": "right 50px top 10px"}) ) }) @@ -604,7 +604,7 @@ describe("backgroundRepeat", () => { r(backgroundRepeat(round)), r(backgroundRepeat(noRepeat)), r(backgroundRepeat(inherit_)), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"backgroundRepeat": "repeat-x"}, {"backgroundRepeat": "repeat-y"}, @@ -623,7 +623,7 @@ describe("backgroundRepeat", () => { r(backgroundRepeat(#hv(repeat, repeat))), r(backgroundRepeat(#hv(round, space))), r(backgroundRepeat(#hv(noRepeat, round))), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"backgroundRepeat": "repeat space"}, {"backgroundRepeat": "repeat repeat"}, @@ -643,7 +643,7 @@ describe("backgroundImage", () => r(backgroundImage(repeatingLinearGradient(rad(6.), list{(pct(20.), black)}))), r(backgroundImage(radialGradient(list{(pct(30.), yellow)}))), r(backgroundImage(repeatingRadialGradient(list{(pct(30.), yellow)}))), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"backgroundImage": "none"}, {"backgroundImage": "url(x)"}, @@ -663,7 +663,7 @@ describe("background shorhand", () => r(background(url("x"))), r(background(linearGradient(deg(5.), list{(pct(10.), red)}))), r(background(none)), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"background": "rgb(1, 2, 3)"}, {"background": "url(x)"}, @@ -689,7 +689,7 @@ describe("clipPath", () => r(clipPath(inherit_)), r(clipPath(initial)), r(clipPath(unset)), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"clipPath": "none"}, {"clipPath": "url(x)"}, @@ -718,7 +718,7 @@ describe("columnGap", () => r(columnGap(inherit_)), r(columnGap(initial)), r(columnGap(unset)), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"columnGap": "normal"}, {"columnGap": "3px"}, @@ -771,7 +771,7 @@ describe("cursor", () => r(cursor(nwseResize)), r(cursor(zoomIn)), r(cursor(zoomOut)), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"cursor": "context-menu"}, {"cursor": "help"}, diff --git a/tests/syntax_tests/data/idempotency/bs-css/Selectors_test.res b/tests/syntax_tests/data/idempotency/bs-css/Selectors_test.res index 3ce089fa6cd..34a7657db67 100644 --- a/tests/syntax_tests/data/idempotency/bs-css/Selectors_test.res +++ b/tests/syntax_tests/data/idempotency/bs-css/Selectors_test.res @@ -15,7 +15,7 @@ open Jest open Expect open CssForTest -let toBeJson = x => Expect.toBe(x->Js.Json.stringifyAny) +let toBeJson = x => Expect.toBe(x->JSON.stringifyAny) let r = x => toJson(list{x}) /* simple rule for more readable tests */ let ruleSelector = display(block) let ruleJson = {"display": "block"} @@ -55,7 +55,7 @@ describe("Pseudo classes", () => { r(target(list{ruleSelector})), r(valid(list{ruleSelector})), r(visited(list{ruleSelector})), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {":active": ruleJson}, {":checked": ruleJson}, @@ -96,12 +96,12 @@ describe("Pseudo classes", () => { ( r(host(list{ruleSelector})), r(host(~selector=".special-custom-element", list{ruleSelector})), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(({":host": ruleJson}, {":host(.special-custom-element)": ruleJson})) ) test("test not", () => - expect(r(not__("p", list{ruleSelector}))->Js.Json.stringifyAny)->toBeJson({ + expect(r(not__("p", list{ruleSelector}))->JSON.stringifyAny)->toBeJson({ ":not(p)": ruleJson, }) ) @@ -113,7 +113,7 @@ describe("Pseudo classes", () => { r(nthChild(#even, list{ruleSelector})), r(nthChild(#n(2), list{ruleSelector})), r(nthChild(#add(3, 4), list{ruleSelector})), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {":nth-child(odd)": ruleJson}, {":nth-child(even)": ruleJson}, @@ -129,7 +129,7 @@ describe("Pseudo classes", () => { r(nthLastChild(#even, list{ruleSelector})), r(nthLastChild(#n(2), list{ruleSelector})), r(nthLastChild(#add(3, 4), list{ruleSelector})), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {":nth-last-child(odd)": ruleJson}, {":nth-last-child(even)": ruleJson}, @@ -145,7 +145,7 @@ describe("Pseudo classes", () => { r(nthLastOfType(#even, list{ruleSelector})), r(nthLastOfType(#n(2), list{ruleSelector})), r(nthLastOfType(#add(3, 4), list{ruleSelector})), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {":nth-last-of-type(odd)": ruleJson}, {":nth-last-of-type(even)": ruleJson}, @@ -161,7 +161,7 @@ describe("Pseudo classes", () => { r(nthOfType(#even, list{ruleSelector})), r(nthOfType(#n(2), list{ruleSelector})), r(nthOfType(#add(3, 4), list{ruleSelector})), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {":nth-of-type(odd)": ruleJson}, {":nth-of-type(even)": ruleJson}, @@ -181,7 +181,7 @@ describe("Pseudo classes", () => r(firstLine(list{ruleSelector})), r(placeholder(list{ruleSelector})), r(selection(list{ruleSelector})), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"::after": ruleJson}, {"::before": ruleJson}, @@ -201,7 +201,7 @@ describe("Combinators", () => r(children(list{ruleSelector})), r(siblings(list{ruleSelector})), r(directSibling(list{ruleSelector})), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(({" > li": ruleJson}, {" > *": ruleJson}, {" ~ ": ruleJson}, {" + ": ruleJson})) ) ) diff --git a/tests/syntax_tests/data/idempotency/bs-css/Svg_test.res b/tests/syntax_tests/data/idempotency/bs-css/Svg_test.res index 51e9ed86274..cb52cc7b1bf 100644 --- a/tests/syntax_tests/data/idempotency/bs-css/Svg_test.res +++ b/tests/syntax_tests/data/idempotency/bs-css/Svg_test.res @@ -15,7 +15,7 @@ open Jest open Expect open CssForTest -let toBeJson = x => Expect.toBe(x->Js.Json.stringifyAny) +let toBeJson = x => Expect.toBe(x->JSON.stringifyAny) let r = x => toJson(list{x}) /* simple rule for more readable tests */ describe("Fill", () => @@ -27,7 +27,7 @@ describe("Fill", () => r(SVG.fill(#contextFill)), r(SVG.fill(#contextStroke)), r(SVG.fill(#none)), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"fill": "#FF0044"}, {"fill": "url(#mydef)"}, @@ -47,7 +47,7 @@ describe("strokeDasharray", () => r(SVG.strokeDasharray(#dasharray(list{1->px, 2.->pct, 3->px, 4.->pct}))), r(SVG.strokeDasharray(#dasharray(list{1.->pct, 2->px, 3.->pct, 4->px}))), r(SVG.strokeDasharray(#none)), - )->Js.Json.stringifyAny, + )->JSON.stringifyAny, )->toBeJson(( {"stroke-dasharray": "1px 2px 3px 4px"}, {"stroke-dasharray": "1% 2% 3% 4%"}, diff --git a/tests/syntax_tests/data/idempotency/bs-fetch/reason_examples.res b/tests/syntax_tests/data/idempotency/bs-fetch/reason_examples.res index ebce2dfac68..155012f5c1d 100644 --- a/tests/syntax_tests/data/idempotency/bs-fetch/reason_examples.res +++ b/tests/syntax_tests/data/idempotency/bs-fetch/reason_examples.res @@ -1,39 +1,39 @@ let _ = { - open Js.Promise + open Promise Fetch.fetch("/api/hellos/1") ->then_(Fetch.Response.text) ->then_(text => print_endline(text)->resolve) } let _ = { - open Js.Promise + open Promise Fetch.fetchWithInit("/api/hello", Fetch.RequestInit.make(~method_=Post, ())) ->then_(Fetch.Response.text) ->then_(text => print_endline(text)->resolve) } let _ = { - open Js.Promise + open Promise Fetch.fetch("/api/fruit") /* assume server returns `["apple", "banana", "pear", ...]` */ ->then_(Fetch.Response.json) - ->then_(json => Js.Json.decodeArray(json)->resolve) + ->then_(json => JSON.decodeArray(json)->resolve) ->then_(opt => Belt.Option.getExn(opt)->resolve) ->then_(items => - items->Js.Array.map(item => item->Js.Json.decodeString->Belt.Option.getExn)->resolve + items->Array.map(item => item->JSON.decodeString->Belt.Option.getExn)->resolve ) } /* makes a post request with the following json payload { hello: "world" } */ let _ = { - let payload = Js.Dict.empty() - Js.Dict.set(payload, "hello", Js.Json.string("world")) - open Js.Promise + let payload = Dict.make() + Dict.set(payload, "hello", JSON.string("world")) + open Promise Fetch.fetchWithInit( "/api/hello", Fetch.RequestInit.make( ~method_=Post, - ~body=Fetch.BodyInit.make(Js.Json.stringify(Js.Json.object_(payload))), + ~body=Fetch.BodyInit.make(JSON.stringify(JSON.object_(payload))), ~headers=Fetch.HeadersInit.make({"Content-Type": "application/json"}), (), ), diff --git a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Canvas/Webapi__Canvas__Canvas2d.res b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Canvas/Webapi__Canvas__Canvas2d.res index 17b0eec391c..f12461b1956 100644 --- a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Canvas/Webapi__Canvas__Canvas2d.res +++ b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Canvas/Webapi__Canvas__Canvas2d.res @@ -121,7 +121,7 @@ let reifyStyle = (type a, x: 'a): (style
, a) => { } ( - if Js.typeof(x) == "string" { + if typeof(x) == "string" { Obj.magic(String) } else if Internal.instanceOf(x, Internal.canvasGradient) { Obj.magic(Gradient) diff --git a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Canvas/Webapi__Canvas__WebGl.res b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Canvas/Webapi__Canvas__WebGl.res index 07fa2cd41c8..78c732a9f34 100644 --- a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Canvas/Webapi__Canvas__WebGl.res +++ b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Canvas/Webapi__Canvas__WebGl.res @@ -80,9 +80,9 @@ let _DYNAMIC_DRAW: int = 35048 @send external createBuffer: glT => bufferT = "createBuffer" @send external deleteBuffer: (glT, bufferT) => unit = "deleteBuffer" @send external bindBuffer: (glT, int, bufferT) => unit = "bindBuffer" -@send external bufferData: (glT, int, Js.Typed_array.Uint16Array.t, int) => unit = "bufferData" +@send external bufferData: (glT, int, Uint16Array.t, int) => unit = "bufferData" @send -external bufferFloatData: (glT, int, Js.Typed_array.Float32Array.t, int) => unit = "bufferData" +external bufferFloatData: (glT, int, Float32Array.t, int) => unit = "bufferData" @send external createProgram: glT => programT = "createProgram" @send external linkProgram: (glT, programT) => unit = "linkProgram" @send external useProgram: (glT, programT) => unit = "useProgram" diff --git a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__Document.res b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__Document.res index 4e2093c7fb0..2499fb6df4d 100644 --- a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__Document.res +++ b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__Document.res @@ -5,14 +5,14 @@ module Impl = ( ) => { external asDocument: T.t => Dom.document = "%identity" - let asHtmlDocument: T.t => Js.null = %raw(` + let asHtmlDocument: T.t => null = %raw(` function (document) { return document.doctype.name === "html" ? document : null; } `) @deprecated("Will fail if no doctype is defined, consider using unsafeAsHtmlDocument instead") let asHtmlDocument: T.t => option = self => - Js.Null.toOption(asHtmlDocument(self)) + Null.toOption(asHtmlDocument(self)) external unsafeAsHtmlDocument: T.t => Dom.htmlDocument = "%identity" diff --git a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__Element.res b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__Element.res index 86d4e1cf1fd..6f3cb2533b6 100644 --- a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__Element.res +++ b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__Element.res @@ -7,14 +7,14 @@ module Impl = ( type t }, ) => { - let asHtmlElement: T.t => Js.null = %raw(` + let asHtmlElement: T.t => null = %raw(` function (element) { // BEWARE: Assumes "contentEditable" uniquely identifies an HTMLELement return element.contentEditable !== undefined ? element : null; } `) @deprecated("asHtmlElement uses a weak heuristic, consider using unsafeAsHtmlElement instead") - let asHtmlElement: T.t => option = self => Js.Null.toOption(asHtmlElement(self)) + let asHtmlElement: T.t => option = self => Null.toOption(asHtmlElement(self)) external unsafeAsHtmlElement: T.t => Dom.htmlElement = "%identity" let ofNode: Dom.node => option = ofNode diff --git a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__HtmlElement.res b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__HtmlElement.res index 0313ed643c1..a0f0bb74815 100644 --- a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__HtmlElement.res +++ b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__HtmlElement.res @@ -5,14 +5,14 @@ module Impl = ( ) => { type t_htmlElement = T.t - let ofElement: Dom.element => Js.null = %raw(` + let ofElement: Dom.element => null = %raw(` function (element) { // BEWARE: Assumes "contentEditable" uniquely identifies an HTMLELement return element.contentEditable !== undefined ? element : null; } `) @deprecated("Consider using Element.asHtmlElement or Element.unsafeAsHtmlElement instead") - let ofElement: Dom.element => option = self => Js.Null.toOption(ofElement(self)) + let ofElement: Dom.element => option = self => Null.toOption(ofElement(self)) @get external accessKey: t_htmlElement => string = "" @set external setAccessKey: (t_htmlElement, string) => unit = "accessKey" @@ -38,14 +38,14 @@ module Impl = ( setDir(self, Webapi__Dom__Types.encodeDir(value)) @get external draggable: t_htmlElement => bool = "" @set external setDraggable: (t_htmlElement, bool) => unit = "draggable" - /* let setDraggable : t_htmlElement => bool => unit = fun self value => setDraggable self (Js.Boolean.to_js_boolean value); */ /* temproarily removed to reduce codegen size */ + /* let setDraggable : t_htmlElement => bool => unit = fun self value => setDraggable self (Bool.fromBool value); */ /* temproarily removed to reduce codegen size */ @get external dropzone: t_htmlElement => Dom.domSettableTokenList = "" @get external hidden: t_htmlElement => bool = "" @set external setHidden: (t_htmlElement, bool) => unit = "hidden" - /* let setHidden : t_htmlElement => bool => unit = fun self value => setHidden self (Js.Boolean.to_js_boolean value); */ /* temproarily removed to reduce codegen size */ + /* let setHidden : t_htmlElement => bool => unit = fun self value => setHidden self (Bool.fromBool value); */ /* temproarily removed to reduce codegen size */ @get external itemScope: t_htmlElement => bool = "" /* experimental */ @set external setItemScope: (t_htmlElement, bool) => unit = "itemScope" - /* let setItemScope : t_htmlElement => bool => unit = fun self value => setItemScope self (Js.Boolean.to_js_boolean value); */ /* experimental */ /* temproarily removed to reduce codegen size */ + /* let setItemScope : t_htmlElement => bool => unit = fun self value => setItemScope self (Bool.fromBool value); */ /* experimental */ /* temproarily removed to reduce codegen size */ @get external itemType: t_htmlElement => Dom.domSettableTokenList = "" /* experimental */ @get external itemId: t_htmlElement => string = "" /* experimental */ @set external setItemId: (t_htmlElement, string) => unit = "itemId" /* experimental */ @@ -64,7 +64,7 @@ module Impl = ( /* external properties : r => HTMLPropertiesCollection.t = "properties" [@@get]; /* experimental */ */ @get external spellcheck: t_htmlElement => bool = "" @set external setSpellcheck: (t_htmlElement, bool) => unit = "spellcheck" - /* let setSpellcheck : t_htmlElement => bool => unit = fun self value => setSpellcheck self (Js.Boolean.to_js_boolean value); */ /* temproarily removed to reduce codegen size */ + /* let setSpellcheck : t_htmlElement => bool => unit = fun self value => setSpellcheck self (Bool.fromBool value); */ /* temproarily removed to reduce codegen size */ @get external style: t_htmlElement => Dom.cssStyleDeclaration = "" @set external setStyle: (t_htmlElement, Dom.cssStyleDeclaration) => unit = "style" @get external tabIndex: t_htmlElement => int = "" @@ -73,7 +73,7 @@ module Impl = ( @set external setTitle: (t_htmlElement, string) => unit = "title" @get external translate: t_htmlElement => bool = "" /* experimental */ @set external setTranslate: (t_htmlElement, bool) => unit = "translate" /* experimental */ - /* let setTranslate : t_htmlElement => bool => unit = fun self value => setTranslate self (Js.Boolean.to_js_boolean value); */ /* temproarily removed to reduce codegen size */ + /* let setTranslate : t_htmlElement => bool => unit = fun self value => setTranslate self (Bool.fromBool value); */ /* temproarily removed to reduce codegen size */ /* TODO: element-spcific, should be pulled out */ diff --git a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__HtmlImageElement.res b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__HtmlImageElement.res index 7f3e21fd382..e770a40b620 100644 --- a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__HtmlImageElement.res +++ b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__HtmlImageElement.res @@ -12,8 +12,8 @@ type t @get external sizes: t => string = "" @set external setSizes: (t, string) => unit = "sizes" @get @return(nullable) external crossOrigin: t => option = "" -@set external setCrossOrigin: (t, Js.null) => unit = "crossOrigin" -let setCrossOrigin = (self, value) => setCrossOrigin(self, Js.Null.fromOption(value)) +@set external setCrossOrigin: (t, null) => unit = "crossOrigin" +let setCrossOrigin = (self, value) => setCrossOrigin(self, Null.fromOption(value)) @get external useMap: t => string = "" @set external setUseMap: (t, string) => unit = "useMap" @get external isMap: t => bool = "" diff --git a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__HtmlInputElement.res b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__HtmlInputElement.res index 62c73157be7..324b13bb7c8 100644 --- a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__HtmlInputElement.res +++ b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__HtmlInputElement.res @@ -102,8 +102,8 @@ module Impl = ( @get external labels: t_htmlInputElement => array = "" @get external step: t_htmlInputElement => string = "" @set external setStep: (t_htmlInputElement, string) => unit = "step" - @get @return(nullable) external valueAsDate: t_htmlInputElement => option = "" - @set external setValueAsDate: (t_htmlInputElement, Js.Date.t) => unit = "valueAsDate" + @get @return(nullable) external valueAsDate: t_htmlInputElement => option = "" + @set external setValueAsDate: (t_htmlInputElement, Date.t) => unit = "valueAsDate" @get external valueAsNumber: t_htmlInputElement => float = "" diff --git a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__Image.res b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__Image.res index 08bd26bde95..b7d48390d53 100644 --- a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__Image.res +++ b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__Image.res @@ -2,13 +2,13 @@ type t @new external makeWithData: ( - ~array: Js.Typed_array.Uint8ClampedArray.t, + ~array: Uint8ClampedArray.t, ~width: float, ~height: float, ) => t = "ImageData" @new external make: (~width: float, ~height: float) => t = "ImageData" -@get external data: t => Js.Typed_array.Uint8ClampedArray.t = "" +@get external data: t => Uint8ClampedArray.t = "" @get external height: t => float = "" @get external width: t => float = "" diff --git a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__Node.res b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__Node.res index a256898b7d7..5ab0fc2b9f4 100644 --- a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__Node.res +++ b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__Node.res @@ -17,8 +17,8 @@ module Impl = ( let nodeType: T.t => Webapi__Dom__Types.nodeType = self => Webapi__Dom__Types.decodeNodeType(nodeType(self)) @get @return(nullable) external nodeValue: T.t => option = "" - @set external setNodeValue: (T.t, Js.null) => unit = "nodeValue" - /* let setNodeValue : T.t => option string => unit = fun self value => setNodeValue self (Js.Null.fromOption value); */ /* temporarily removed to reduce codegen size */ + @set external setNodeValue: (T.t, null) => unit = "nodeValue" + /* let setNodeValue : T.t => option string => unit = fun self value => setNodeValue self (Null.fromOption value); */ /* temporarily removed to reduce codegen size */ /* Not supported yet external setNodeValue : T.t => string => unit = "nodeValue" [@@set]; external clearNodeValue : T.t => _ [@as {json|null|json}] => unit = "nodeValue" [@@set]; diff --git a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__StorageEvent.res b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__StorageEvent.res index 416929afca6..1da281b0d54 100644 --- a/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__StorageEvent.res +++ b/tests/syntax_tests/data/idempotency/bs-webapi/src/Webapi/Webapi__Dom/Webapi__Dom__StorageEvent.res @@ -8,7 +8,7 @@ include Webapi__Dom__Event.Impl({ @new external makeWithOptions: (string, {..}) => t = "StorageEvent" @get external key: t => string = "" -@get external newValue: t => Js.Nullable.t = "" -@get external oldValue: t => Js.Nullable.t = "" +@get external newValue: t => nullable = "" +@get external oldValue: t => nullable = "" @get external storageArea: t => Dom.Storage.t = "" @get external url: t => string = "" diff --git a/tests/syntax_tests/data/idempotency/bs-webapi/tests/Webapi/Webapi__Canvas/Webapi__Canvas__Canvas2d__test.res b/tests/syntax_tests/data/idempotency/bs-webapi/tests/Webapi/Webapi__Canvas/Webapi__Canvas__Canvas2d__test.res index 58fbaa2c14b..67f3c5c1b67 100644 --- a/tests/syntax_tests/data/idempotency/bs-webapi/tests/Webapi/Webapi__Canvas/Webapi__Canvas__Canvas2d__test.res +++ b/tests/syntax_tests/data/idempotency/bs-webapi/tests/Webapi/Webapi__Canvas/Webapi__Canvas__Canvas2d__test.res @@ -26,13 +26,13 @@ setFillStyle(ctx, String, "red") switch fillStyle(ctx) { | (Gradient, g) => g->addColorStop(0.0, "red") -| (String, s) => Js.log(s) +| (String, s) => Console.log(s) | _ => () } switch strokeStyle(ctx) { | (Gradient, g) => g->addColorStop(1.2, "blue") -| (String, s) => Js.log(s) +| (String, s) => Console.log(s) | _ => () } diff --git a/tests/syntax_tests/data/idempotency/bs-webapi/tests/Webapi/Webapi__Dom/Webapi__Dom__Image__test.res b/tests/syntax_tests/data/idempotency/bs-webapi/tests/Webapi/Webapi__Dom/Webapi__Dom__Image__test.res index 48f4decbdea..ad1c1176c7d 100644 --- a/tests/syntax_tests/data/idempotency/bs-webapi/tests/Webapi/Webapi__Dom/Webapi__Dom__Image__test.res +++ b/tests/syntax_tests/data/idempotency/bs-webapi/tests/Webapi/Webapi__Dom/Webapi__Dom__Image__test.res @@ -2,7 +2,7 @@ open Webapi.Dom.Image let imageData = make(~width=0.0, ~height=0.0) -let arr = Js.Typed_array.Uint8ClampedArray.make([]) +let arr = Uint8ClampedArray.make([]) let _ = makeWithData(~array=arr, ~width=0.0, ~height=0.0) let _ = height(imageData) diff --git a/tests/syntax_tests/data/idempotency/bs-webapi/tests/Webapi/Webapi__Dom/Webapi__Dom__NodeList__test.res b/tests/syntax_tests/data/idempotency/bs-webapi/tests/Webapi/Webapi__Dom/Webapi__Dom__NodeList__test.res index a29c18369ac..a37ba59c774 100644 --- a/tests/syntax_tests/data/idempotency/bs-webapi/tests/Webapi/Webapi__Dom/Webapi__Dom__NodeList__test.res +++ b/tests/syntax_tests/data/idempotency/bs-webapi/tests/Webapi/Webapi__Dom/Webapi__Dom__NodeList__test.res @@ -3,4 +3,4 @@ open NodeList let items = document->Document.querySelectorAll(".item") -forEach((item, _) => Js.log(item), items) +forEach((item, _) => Console.log(item), items) diff --git a/tests/syntax_tests/data/idempotency/bs-webapi/tests/Webapi/Webapi__Dom/Webapi__Dom__Node__test.res b/tests/syntax_tests/data/idempotency/bs-webapi/tests/Webapi/Webapi__Dom/Webapi__Dom__Node__test.res index d2f13a0a57c..cf276ab1322 100644 --- a/tests/syntax_tests/data/idempotency/bs-webapi/tests/Webapi/Webapi__Dom/Webapi__Dom__Node__test.res +++ b/tests/syntax_tests/data/idempotency/bs-webapi/tests/Webapi/Webapi__Dom/Webapi__Dom__Node__test.res @@ -12,7 +12,7 @@ let _ = nextSibling(node) let _ = nodeName(node) let _ = nodeType(node) let _ = nodeValue(node) -let _ = setNodeValue(node, Js.Null.return("foo")) +let _ = setNodeValue(node, Null.make("foo")) /* Not supported yet let _ = setNodeValue(node, "foo"); let _ = clearNodeValue(node); diff --git a/tests/syntax_tests/data/idempotency/bs-webapi/tests/Webapi/Webapi__Url__test.res b/tests/syntax_tests/data/idempotency/bs-webapi/tests/Webapi/Webapi__Url__test.res index 134797a9671..dde60a003d4 100644 --- a/tests/syntax_tests/data/idempotency/bs-webapi/tests/Webapi/Webapi__Url__test.res +++ b/tests/syntax_tests/data/idempotency/bs-webapi/tests/Webapi/Webapi__Url__test.res @@ -1,4 +1,4 @@ open Webapi.Url let params = URLSearchParams.make("key1=value1&key2=value2") -URLSearchParams.forEach(Js.log2, params) +URLSearchParams.forEach(Console.log2, params) diff --git a/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Chart.res b/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Chart.res index 346818ab83a..5aa2ac15c45 100644 --- a/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Chart.res +++ b/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Chart.res @@ -9,24 +9,16 @@ external string_to_domain: string => domain = "%identity" @get external clientHeight: Dom.element => float = "clientHeight" let calculateMaxValue = (dataType, locations, data) => - Js.Array.reduce( - (maxValue, {Data.values: values}) => - Js.Array.reduce( - (maxValue, location) => + Array.reduce(data, 1, (maxValue, {Data.values: values}) => + Array.reduce(locations, maxValue, (maxValue, location) => values(location.Location.id) - ->Js.Option.map((value) => Js.Math.max_int(maxValue, Data.getValue(dataType, value))) - ->Js.Option.getWithDefault(maxValue), - maxValue, - locations, - ), - 1, - data, - ) + ->Option.map((value) => Math.Int.max(maxValue, Data.getValue(dataType, value))) + ->Option.getWithDefault(maxValue))) let ordinalSuffix = i => { let j = mod(i, 10) let k = mod(i, 100) - let i = Js.Int.toString(i) + let i = Int.toString(i) if j == 1 && k != 11 { i ++ "st" } else if j == 2 && k != 12 { @@ -40,8 +32,8 @@ let ordinalSuffix = i => { let renderTooltipValues = (~chartType, ~payload, ~separator) => payload - ->Js.Array.filter(payload => payload.R.Tooltip.name !== "daily-growth-indicator") - ->Js.Array.map(payload => { + ->Array.filter(payload => payload.R.Tooltip.name !== "daily-growth-indicator") + ->Array.map(payload => { let currentDataItem = (payload: R.Tooltip.payload).payload.Data.values(payload.R.Tooltip.name) @@ -52,35 +44,35 @@ let renderTooltipValues = (~chartType, ~payload, ~separator) => | Filters.Number(dataType) => let growthString = currentDataItem - ->Js.Option.map((dataItem) => - " (+" ++ ((Data.getGrowth(dataType, dataItem) *. 100.->Js.Float.toFixed) ++ "%)") + ->Option.map((dataItem) => + " (+" ++ ((Data.getGrowth(dataType, dataItem) *. 100.->Float.toFixed) ++ "%)") ) - ->Js.Option.getWithDefault("") - (separator ++ Js.Int.toString(R.Line.toInt(payload.value)), growthString) + ->Option.getWithDefault("") + (separator ++ Int.toString(R.Line.toInt(payload.value)), growthString) | Filters.PercentageGrowthOfCases => let growthString = currentDataItem - ->Js.Option.map((dataItem) => - " (+" ++ ((Data.getDailyNewCases(dataItem).confirmed->Js.Int.toString) ++ ")") + ->Option.map((dataItem) => + " (+" ++ ((Data.getDailyNewCases(dataItem).confirmed->Int.toString) ++ ")") ) - ->Js.Option.getWithDefault("") + ->Option.getWithDefault("") ( separator ++ ("+" ++ - ((R.Line.toFloat(payload.value) *. 100.->Js.Float.toFixed) ++ "%")), + ((R.Line.toFloat(payload.value) *. 100.->Float.toFixed) ++ "%")), growthString, ) | Filters.TotalMortalityRate => let growthString = currentDataItem - ->Js.Option.map((dataItem) => { + ->Option.map((dataItem) => { let {Data.confirmed: confirmed, deaths} = Data.getRecord(dataItem) - " (" ++ (Js.Int.toString(deaths) ++ ("/" ++ Js.Int.toString(confirmed)) ++ ")") + " (" ++ (Int.toString(deaths) ++ ("/" ++ Int.toString(confirmed)) ++ ")") }) - ->Js.Option.getWithDefault("") + ->Option.getWithDefault("") ( separator ++ - (Js.Float.toFixedWithPrecision(R.Line.toFloat(payload.value) *. 100., ~digits=2) ++ + (Float.toFixedWithPrecision(R.Line.toFloat(payload.value) *. 100., ~digits=2) ++ "%"), growthString, ) @@ -131,9 +123,9 @@ let make = ( | (Filters.Number(Data.Confirmed), Filters.RelativeToThreshold, Filters.Logarithmic) => let dailyGrowth = 1.33 let exponent = { - let threshold = Js.Int.toFloat(threshold) + let threshold = Int.toFloat(threshold) let maxValue = calculateMaxValue(Data.Confirmed, locations, data) - log((maxValue->Belt.Int.toFloat) /. threshold) /. log(dailyGrowth)->Js.Math.ceil + log((maxValue->Belt.Int.toFloat) /. threshold) /. log(dailyGrowth)->Math.ceil } if item.Data.index <= exponent { - Js.Null.return( - Js.Int.toFloat(threshold) *. - Js.Math.pow_float(~base=dailyGrowth, ~exp=item.Data.index->Belt.Int.toFloat) + Null.make( + Int.toFloat(threshold) *. + Math.pow(~base=dailyGrowth, ~exp=item.Data.index->Belt.Int.toFloat) ->int_of_float ->R.Line.int, ) } else { - Js.null + null }} /> | _ => React.null } - let divRef = React.useRef(Js.Nullable.null) + let divRef = React.useRef(Nullable.null) let (dot, setDot) = React.useState(() => true) React.useEffect1(() => { - let opt = divRef->React.Ref.current->Js.Nullable.toOption + let opt = divRef->React.Ref.current->Nullable.toOption switch opt { | Some(ref) => setDot(_ => clientHeight(ref) > 500.) | None => () @@ -185,7 +177,7 @@ let make = ( growthBaseline - {Js.Array.map(({Location.id: id, primaryColor}) => + {Array.map(locations, ({Location.id: id, primaryColor}) => let value = Data.getValue(dataType, x) if value != 0 { - Js.Null.return(R.Line.int(value)) + Null.make(R.Line.int(value)) } else { - Js.null + null } | Filters.PercentageGrowthOfCases => - Js.Null.return(R.Line.float(Data.getGrowth(Data.Confirmed, x))) + Null.make(R.Line.float(Data.getGrowth(Data.Confirmed, x))) | Filters.TotalMortalityRate => - Js.Null.return(R.Line.float(Data.getTotalMortailityRate(x))) + Null.make(R.Line.float(Data.getTotalMortailityRate(x))) } - | _ => Js.Null.empty + | _ => Null.null }} stroke=primaryColor strokeWidth=2. @@ -222,11 +214,10 @@ let make = ( "fill": Colors.colors["white"], "stroke": primaryColor, })} - /> - , locations)->Js.Array.reverseInPlace->React.array} + />)->Array.toReversed->React.array} - switch Js.Null.toOption(payload) { + switch Null.toOption(payload) { | Some(payload) =>
@@ -242,7 +233,7 @@ let make = ( dataKey={item => switch item.Data.x { | Day(int) => R.XAxis.int(int) - | Date(date) => R.XAxis.string(Js.Date.toLocaleDateString(date)) + | Date(date) => R.XAxis.string(Date.toLocaleDateString(date)) }} padding={"left": 0, "right": 30} axisLine=false @@ -270,10 +261,10 @@ let make = ( domain=("dataMin"->R.YAxis.string, "dataMax"->R.YAxis.string) tickFormatter={x => switch chartType { - | Filters.Number(_) => Js.Int.toString(R.Line.toInt(x)) + | Filters.Number(_) => Int.toString(R.Line.toInt(x)) | Filters.TotalMortalityRate | Filters.PercentageGrowthOfCases => - (R.Line.toFloat(x) *. 100.->Js.Float.toFixed) ++ "%" + (R.Line.toFloat(x) *. 100.->Float.toFixed) ++ "%" }} /> diff --git a/tests/syntax_tests/data/idempotency/covid-19charts.com/src/ColorStack.res b/tests/syntax_tests/data/idempotency/covid-19charts.com/src/ColorStack.res index fb0e78eb9e8..4b3ff31868b 100644 --- a/tests/syntax_tests/data/idempotency/covid-19charts.com/src/ColorStack.res +++ b/tests/syntax_tests/data/idempotency/covid-19charts.com/src/ColorStack.res @@ -28,7 +28,7 @@ let colors = [ let initialColors = { let stack = Stack.make() - Js.Array.forEach(color => Stack.push(stack, color), colors) + Array.forEach(colors, color => Stack.push(stack, color)) stack } @@ -41,10 +41,10 @@ let popColor = colorQueue => let make = (~locations) => { let colors = Stack.copy(initialColors) { - associations: Js.Array.reduce((associations, location) => { + associations: Array.reduce(locations, Map.empty, (associations, location) => { let color = popColor(colors) Map.set(associations, location, color) - }, Map.empty, locations), + }), colors: colors, } } diff --git a/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Data.res b/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Data.res index a4dd6aa8d1b..91964b635b4 100644 --- a/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Data.res +++ b/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Data.res @@ -11,14 +11,14 @@ module Map: { let empty: unit => t<'key, 'value> } = { type t<'key, 'value> = dict<'value> constraint 'key = string - let keys = Js.Dict.keys - let get = Js.Dict.unsafeGet - let get_opt = Js.Dict.get - let map = Js.Dict.map - let entries = Js.Dict.entries - let fromArray = Js.Dict.fromArray - let set = Js.Dict.set - let empty = Js.Dict.empty + let keys = Dict.keysToArray + let get = Dict.getUnsafe + let get_opt = Dict.get + let map = Dict.mapValues + let entries = Dict.toArray + let fromArray = Dict.fromArray + let set = Dict.set + let empty = Dict.make } @val external require: string => 'a = "require" @@ -41,13 +41,13 @@ let days: array = require("../data/days.json") let data: Map.t = require("../data/data.json") let countryIds = Map.keys(locations) -let startDate = Js.Date.fromString(days[0]) -let endDate = Js.Date.fromString(days[Js.Array.length(days) - 1]) +let startDate = Date.fromString(days[0]) +let endDate = Date.fromString(days[Array.length(days) - 1]) -let dayToIndex = Js.Array.mapi((day, index) => (day, index), days)->Map.fromArray +let dayToIndex = Array.mapWithIndex(days, (day, index) => (day, index))->Map.fromArray type xValue = - | Date(Js.Date.t) + | Date(Date.t) | Day(int) type value = @@ -56,10 +56,10 @@ type value = let dataWithGrowth = Map.entries(data) - ->Js.Array.map(((countryId, dataPoints)) => { + ->Array.map(((countryId, dataPoints)) => { let data = Lazy.from_fun(() => { let countryDataWithGrowth = Map.empty() - let _ = Js.Array.reduce((prevRecord, day) => { + let _ = Array.reduce(days, None, (prevRecord, day) => { let record = Map.get(dataPoints, day) Map.set( countryDataWithGrowth, @@ -70,7 +70,7 @@ let dataWithGrowth = }, ) Some(record) - }, None, days) + }) countryDataWithGrowth }) (countryId, data) @@ -85,39 +85,35 @@ type item = { type t = array -let calendar: t = Js.Array.mapi((day, index) => { - let values = Belt.HashMap.String.make(~hintSize=Js.Array.length(countryIds)) - Js.Array.forEach( - countryId => +let calendar: t = Array.mapWithIndex(days, (day, index) => { + let values = Belt.HashMap.String.make(~hintSize=Array.length(countryIds)) + Array.forEach(countryIds, countryId => Belt.HashMap.String.set( values, Map.get(locations, countryId).name, Lazy.from_fun(() => Map.get(Belt.Map.String.getExn(dataWithGrowth, countryId)->Lazy.force, day)), - ), - countryIds, - ) + )) { - x: Date(Js.Date.fromString(day)), + x: Date(Date.fromString(day)), index: index, values: countryId => - Belt.HashMap.String.get(values, countryId)->Js.Option.map((x) => Lazy.force(x)), + Belt.HashMap.String.get(values, countryId)->Option.map((x) => Lazy.force(x)), } -}, days) +}) let isInitialRange = (selectedStartDate, selectedEndDate) => - Js.Date.getTime(selectedEndDate) == Js.Date.getTime(endDate) && - Js.Date.getDate(selectedStartDate) == Js.Date.getTime(startDate) + Date.getTime(selectedEndDate) == Date.getTime(endDate) && + Date.getDate(selectedStartDate) == Date.getTime(startDate) let calendar = (selectedStartDate, selectedEndDate) => if isInitialRange(selectedStartDate, selectedEndDate) { calendar } else { - Js.Array.filter(({x}) => + Array.filter(calendar, ({x}) => switch x { | Date(date) => date >= selectedStartDate && date <= selectedEndDate | _ => false - } - , calendar) + }) } type dataType = @@ -143,20 +139,20 @@ let alignToDay0 = (dataType, threshold) => { Lazy.from_fun(() => { let dataPoints = Lazy.force(dataPoints) Map.entries(dataPoints) - ->Js.Array.map(((date, value)) => (Map.get(dayToIndex, date), value)) - ->Js.Array.sortInPlaceWith((a, b) => compare(a->fst, b->fst)) - ->Js.Array.map(((_, value)) => value) - ->Js.Array.filter(value => getValue(dataType, value) >= threshold) - ->Js.Array.mapi((value, index) => (index, value)) + ->Array.map(((date, value)) => (Map.get(dayToIndex, date), value)) + ->Array.toSorted((a, b) => Ordering.fromInt(((a, b) => compare(a->fst, b->fst))(a, b))) + ->Array.map(((_, value)) => value) + ->Array.filter(value => getValue(dataType, value) >= threshold) + ->Array.mapWithIndex((value, index) => (index, value)) ->Belt.Map.Int.fromArray }) ) - Array.init(Js.Array.length(days), day => { + Array.init(Array.length(days), day => { x: Day(day), index: day, values: countryId => - Belt.Map.String.get(data, countryId)->Js.Option.andThen((countryData) => + Belt.Map.String.get(data, countryId)->Option.andThen((countryData) => Belt.Map.Int.get(Lazy.force(countryData), day) ), }) @@ -166,18 +162,18 @@ let getGrowth = (dataType, x) => switch x { | First(_) => 0. | Pair({prevRecord, record}) => - let numberOfCasesF = Js.Int.toFloat(getValueFromRecord(dataType, record)) + let numberOfCasesF = Int.toFloat(getValueFromRecord(dataType, record)) let prevNumberOfCases = getValueFromRecord(dataType, prevRecord) - let prevNumberOfCasesF = Js.Int.toFloat(prevNumberOfCases) + let prevNumberOfCasesF = Int.toFloat(prevNumberOfCases) prevNumberOfCases == 0 ? 0. : numberOfCasesF /. prevNumberOfCasesF -. 1. } let getTotalMortailityRate = x => switch x { | First({confirmed, deaths}) if confirmed > 0 => - Js.Int.toFloat(deaths) /. Js.Int.toFloat(confirmed) + Int.toFloat(deaths) /. Int.toFloat(confirmed) | Pair({record: {confirmed, deaths}}) if confirmed > 0 => - Js.Int.toFloat(deaths) /. Js.Int.toFloat(confirmed) + Int.toFloat(deaths) /. Int.toFloat(confirmed) | _ => 0. } @@ -193,7 +189,7 @@ let getDailyNewCases = x => let getDailyMortailityRate = x => { let {confirmed, deaths} = getDailyNewCases(x) if confirmed > 0 { - Js.Int.toFloat(deaths) /. Js.Int.toFloat(confirmed) + Int.toFloat(deaths) /. Int.toFloat(confirmed) } else { 0. } @@ -202,9 +198,9 @@ let getDailyMortailityRate = x => { /* * let allLocations = * Map.entries(locations) - * ->Js.Array.map(((locationId, value)) => + * ->Array.map(((locationId, value)) => * {ReactSelect.label: value.name, value: locationId} - * ); + *); */ /* Workaround Datepicker bug/feature. diff --git a/tests/syntax_tests/data/idempotency/covid-19charts.com/src/DatePicker.res b/tests/syntax_tests/data/idempotency/covid-19charts.com/src/DatePicker.res index 4260ff0ca14..a9e690321e8 100644 --- a/tests/syntax_tests/data/idempotency/covid-19charts.com/src/DatePicker.res +++ b/tests/syntax_tests/data/idempotency/covid-19charts.com/src/DatePicker.res @@ -1,11 +1,11 @@ @module("react-datepicker") @react.component external make: ( - ~selected: Js.Date.t, - ~onChange: Js.Date.t => unit, + ~selected: Date.t, + ~onChange: Date.t => unit, ~customInput: React.element, ~selectsStart: bool=?, ~selectsEnd: bool=?, - ~startDate: Js.Date.t=?, - ~endDate: Js.Date.t=?, - ~minDate: Js.Date.t=?, + ~startDate: Date.t=?, + ~endDate: Date.t=?, + ~minDate: Date.t=?, ) => React.element = "default" diff --git a/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Filters.res b/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Filters.res index d2cf56b222a..2dfdd9545b7 100644 --- a/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Filters.res +++ b/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Filters.res @@ -17,9 +17,9 @@ module Input = { onChange value={switch value { | Float(float) => - float->Js.Option.map((int) => Js.Float.toString(int))->Js.Option.getWithDefault("") + float->Option.map((int) => Float.toString(int))->Option.getWithDefault("") | Number(int) => - int->Js.Option.map((int) => Js.Int.toString(int))->Js.Option.getWithDefault("") + int->Option.map((int) => Int.toString(int))->Option.getWithDefault("") | Text(text) => text }} placeholder=label @@ -92,7 +92,7 @@ module Radio = { } } @react.component - let make = (~values, ~selectedValue, ~format, ~getKey=Js.String.make, ~onChange) => + let make = (~values, ~selectedValue, ~format, ~getKey=String.make, ~onChange) =>
{Belt.Array.mapU(values, (value) => { let text = format(value) @@ -165,7 +165,7 @@ module Locations = { key=location.Location.id location onClick={removedId => - setLocations(locations => Js.Array.filter(id => id != removedId, locations))} + setLocations(locations => Array.filter(locations, id => id != removedId))} /> )->React.array}
@@ -174,10 +174,10 @@ module Locations = { ReactSelect.value: id, label: text, })} - components={"IndicatorSeparator": Js.null} + components={"IndicatorSeparator": null} styles={ "control": base => - Js.Obj.assign( + Object.assign( base, { "color": Colors.colors["fggray"], @@ -192,8 +192,8 @@ module Locations = { "borderRadius": "4px", }, ), - "option": base => Js.Obj.assign(base, {"fontSize": "14px"}), - "noOptionsMessage": base => Js.Obj.assign(base, {"fontSize": "14px"}), + "option": base => Object.assign(base, {"fontSize": "14px"}), + "noOptionsMessage": base => Object.assign(base, {"fontSize": "14px"}), } controlShouldRenderValue=false isMulti=true @@ -202,7 +202,7 @@ module Locations = { placeholder="Add location" isClearable=false onChange={newSelection => - switch Js.Nullable.toOption(newSelection) { + switch Nullable.toOption(newSelection) { | Some(newSelection) => setLocations(_ => Belt.Array.mapU(newSelection, ({ReactSelect.value: value}) => value) @@ -245,10 +245,10 @@ module CalendarInput = { ) =>
) diff --git a/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Index.res b/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Index.res index 604ae1f2ca2..609fe22e375 100644 --- a/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Index.res +++ b/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Index.res @@ -30,7 +30,7 @@ module App = { ~queryFragment, ~coder={ encode: x => SerializeQueryParam.string.encode(encode(x)), - decode: x => SerializeQueryParam.string.decode(x)->Js.Option.andThen((x) => decode(x)), + decode: x => SerializeQueryParam.string.decode(x)->Option.andThen((x) => decode(x)), }, ) @@ -102,7 +102,7 @@ module App = { ~queryFragment="threshold", ~coder={ encode: x => Belt.Option.getWithDefault(x, 1)->SerializeQueryParam.int.encode, - decode: x => SerializeQueryParam.int.decode(x)->Js.Option.map((x) => Some(x)), + decode: x => SerializeQueryParam.int.decode(x)->Option.map((x) => Some(x)), }, ) let startDate = UseQueryParam.hook( diff --git a/tests/syntax_tests/data/idempotency/covid-19charts.com/src/ReactSelect.res b/tests/syntax_tests/data/idempotency/covid-19charts.com/src/ReactSelect.res index faace744d02..2b7e43c033b 100644 --- a/tests/syntax_tests/data/idempotency/covid-19charts.com/src/ReactSelect.res +++ b/tests/syntax_tests/data/idempotency/covid-19charts.com/src/ReactSelect.res @@ -19,6 +19,6 @@ external make: ( ~maxHeight: int=?, ~placeholder: string=?, ~isClearable: bool=?, - ~onChange: Js.Nullable.t>> => unit=?, + ~onChange: nullable>> => unit=?, ~noOptionsMessage: unit => option, ) => React.element = "default" diff --git a/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Recharts.res b/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Recharts.res index cfb78a6e355..5076af280a7 100644 --- a/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Recharts.res +++ b/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Recharts.res @@ -2,7 +2,7 @@ module PctOrPx = { type t external px: float => t = "%identity" external pct: string => t = "%identity" - let pct = float => pct(Js.Float.toString(float) ++ "%") + let pct = float => pct(Float.toString(float) ++ "%") } let px = PctOrPx.px @@ -62,7 +62,7 @@ module Make = ( | #stepBefore | #stepAfter ]=?, - ~dataKey: Config.dataItem => Js.null, + ~dataKey: Config.dataItem => null, ~stroke: string=?, ~strokeWidth: float=?, ~strokeDasharray: string=?, @@ -123,7 +123,7 @@ module Make = ( } type data = { - payload: Js.null>, + payload: null>, label: string, separator: string, } diff --git a/tests/syntax_tests/data/idempotency/covid-19charts.com/src/SerializeQueryParam.res b/tests/syntax_tests/data/idempotency/covid-19charts.com/src/SerializeQueryParam.res index f12085be0aa..b6ab33d38ae 100644 --- a/tests/syntax_tests/data/idempotency/covid-19charts.com/src/SerializeQueryParam.res +++ b/tests/syntax_tests/data/idempotency/covid-19charts.com/src/SerializeQueryParam.res @@ -13,7 +13,7 @@ external string: coder = "StringParam" @module("serialize-query-params") @val external stringArray: coder> = "ArrayParam" @module("serialize-query-params") @val -external date: coder = "DateParam" +external date: coder = "DateParam" type locationFragments = { protocol: string, diff --git a/tests/syntax_tests/data/idempotency/covid-19charts.com/src/UseQueryParam.res b/tests/syntax_tests/data/idempotency/covid-19charts.com/src/UseQueryParam.res index 548c15e9e73..1d365439dd1 100644 --- a/tests/syntax_tests/data/idempotency/covid-19charts.com/src/UseQueryParam.res +++ b/tests/syntax_tests/data/idempotency/covid-19charts.com/src/UseQueryParam.res @@ -8,7 +8,7 @@ let hook = (makeInitial, ~queryFragment, ~coder) => { { open Belt.Option forEach( - flatMap(Js.Dict.get(pathname, queryFragment), coder.SerializeQueryParam.decode), + flatMap(Dict.get(pathname, queryFragment), coder.SerializeQueryParam.decode), x => setValue(_ => x), ) } @@ -16,8 +16,8 @@ let hook = (makeInitial, ~queryFragment, ~coder) => { React.Ref.setCurrent(isInitialRender, false) None } else { - let obj = Js.Dict.empty() - Js.Dict.set(obj, queryFragment, coder.encode(value)) + let obj = Dict.make() + Dict.set(obj, queryFragment, coder.encode(value)) let { SerializeQueryParam.protocol: protocol, host, diff --git a/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Victory.res b/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Victory.res index 69c1eea72cf..475a3c84a5b 100644 --- a/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Victory.res +++ b/tests/syntax_tests/data/idempotency/covid-19charts.com/src/Victory.res @@ -43,7 +43,7 @@ module Line = { type xValue<'a> = XValue('a) let ofInt = (x: int) => XValue(x) - let ofDate = (x: Js.Date.t) => XValue(x) + let ofDate = (x: Date.t) => XValue(x) let ofString = (x: string) => XValue(x) @module("victory") @react.component @@ -61,7 +61,7 @@ module Line = { module Axis = { type tick - external tickToDate: tick => Js.Date.t = "%identity" + external tickToDate: tick => Date.t = "%identity" external tickToInt: tick => int = "%identity" @module("victory") @react.component external make: ( diff --git a/tests/syntax_tests/data/idempotency/genType/src/TranslateStructure.res b/tests/syntax_tests/data/idempotency/genType/src/TranslateStructure.res index 9176b1efcd3..0ed3928ca20 100644 --- a/tests/syntax_tests/data/idempotency/genType/src/TranslateStructure.res +++ b/tests/syntax_tests/data/idempotency/genType/src/TranslateStructure.res @@ -14,12 +14,12 @@ let rec addAnnotationsToTypes_ = (~config, ~expr: Typedtree.expression, argTypes | list{"Js", "Fn", _arity} => true | _ => false } => - // let uncurried1: Js.Fn.arity1(_) = {I: x => x->string_of_int}; + // let uncurried1: function(_) = {I: x => x->string_of_int}; addAnnotationsToTypes_(~config, ~expr=exprRecord, argTypes) | (Texp_apply({exp_desc: Texp_ident(path, _, _)}, list{(_, Some(expr1))}), _, _) => switch path->TranslateTypeExprFromTypes.pathToList->List.rev { | list{"Js", "Internal", fn_mk} - // Uncurried function definition uses Js.Internal.fn_mkX(...) + // Uncurried function definition uses Internal.fn_mkX(...) if String.length(fn_mk) >= 5 && String.sub(fn_mk, 0, 5) == "fn_mk" => argTypes->addAnnotationsToTypes_(~config, ~expr=expr1) | _ => argTypes diff --git a/tests/syntax_tests/data/idempotency/genType/src/TranslateTypeExprFromTypes.res b/tests/syntax_tests/data/idempotency/genType/src/TranslateTypeExprFromTypes.res index 6af723f097d..c5902937938 100644 --- a/tests/syntax_tests/data/idempotency/genType/src/TranslateTypeExprFromTypes.res +++ b/tests/syntax_tests/data/idempotency/genType/src/TranslateTypeExprFromTypes.res @@ -552,7 +552,7 @@ and translateTypeExprFromTypes_ = ( {dependencies: list{}, type_: type_} | {noPayloads: list{}, payloads: list{(_label, t)}, unknowns: list{}} => - /* Handle ReScript's "Arity_" encoding in first argument of Js.Internal.fn(_,_) for uncurried functions. + /* Handle ReScript's "Arity_" encoding in first argument of Internal.fn(_, _) for uncurried functions. Return the argument tuple. */ t->translateTypeExprFromTypes_( ~config, diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/API.res b/tests/syntax_tests/data/idempotency/nook-exchange/API.res index 440011849c3..0dbd6c17f74 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/API.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/API.res @@ -3,7 +3,7 @@ let makeAuthenticatedPostRequest = (~url, ~bodyJson, ~sessionId) => url, Fetch.RequestInit.make( ~method_=Post, - ~body=Fetch.BodyInit.make(Js.Json.stringify(Json.Encode.object_(bodyJson))), + ~body=Fetch.BodyInit.make(JSON.stringify(Json.Encode.object_(bodyJson))), ~headers=Fetch.HeadersInit.make({ "X-Client-Version": Constants.gitCommitRef, "Content-Type": "application/json", @@ -27,7 +27,7 @@ let setItemStatus = (~userId, ~sessionId, ~itemId, ~variant, ~status) => }, ~sessionId, ) - Promise.resolved(responseResult) + Promise.resolve(responseResult) }) let setItemStatusBatch = (~sessionId, ~items: array<(int, int)>, ~status) => { @@ -38,7 +38,7 @@ let setItemStatusBatch = (~sessionId, ~items: array<(int, int)>, ~status) => { Fetch.RequestInit.make( ~method_=Post, ~body=Fetch.BodyInit.make( - Js.Json.stringify({ + JSON.stringify({ open Json.Encode object_(list{ ("items", array(tuple2(int, int), items)), @@ -56,7 +56,7 @@ let setItemStatusBatch = (~sessionId, ~items: array<(int, int)>, ~status) => { (), ), ) - Promise.resolved(responseResult) + Promise.resolve(responseResult) }) } @@ -69,7 +69,7 @@ let setItemNote = (~userId, ~sessionId, ~itemId, ~variant, ~note) => ~bodyJson=list{("note", Json.Encode.string(note)), ("userId", Json.Encode.string(userId))}, ~sessionId, ) - Promise.resolved(responseResult) + Promise.resolve(responseResult) }) let setItemPriority = (~sessionId, ~itemId, ~variant, ~isPriority) => @@ -81,7 +81,7 @@ let setItemPriority = (~sessionId, ~itemId, ~variant, ~isPriority) => ~bodyJson=list{("isPriority", Json.Encode.bool(isPriority))}, ~sessionId, ) - Promise.resolved(responseResult) + Promise.resolve(responseResult) }) let importItems = (~sessionId, ~updates: array<((int, int), User.itemStatus)>) => @@ -101,7 +101,7 @@ let importItems = (~sessionId, ~updates: array<((int, int), User.itemStatus)>) = }, ~sessionId, ) - Promise.resolved(responseResult) + Promise.resolve(responseResult) }) let removeItem = (~userId, ~sessionId, ~itemId, ~variant) => { @@ -115,7 +115,7 @@ let removeItem = (~userId, ~sessionId, ~itemId, ~variant) => { Fetch.RequestInit.make( ~method_=Delete, ~body=Fetch.BodyInit.make( - Js.Json.stringify(Json.Encode.object_(list{("userId", Json.Encode.string(userId))})), + JSON.stringify(Json.Encode.object_(list{("userId", Json.Encode.string(userId))})), ), ~headers=Fetch.HeadersInit.make({ "X-Client-Version": Constants.gitCommitRef, @@ -127,7 +127,7 @@ let removeItem = (~userId, ~sessionId, ~itemId, ~variant) => { (), ), ) - Promise.resolved(responseResult) + Promise.resolve(responseResult) }) } @@ -139,7 +139,7 @@ let removeItems = (~sessionId, ~items: array<(int, int)>) => { Fetch.RequestInit.make( ~method_=Delete, ~body=Fetch.BodyInit.make( - Js.Json.stringify({ + JSON.stringify({ open Json.Encode object_(list{("items", array(tuple2(int, int), items))}) }), @@ -154,7 +154,7 @@ let removeItems = (~sessionId, ~items: array<(int, int)>) => { (), ), ) - Promise.resolved(responseResult) + Promise.resolve(responseResult) }) } @@ -168,7 +168,7 @@ let updateProfileText = (~userId, ~sessionId, ~profileText) => }, ~sessionId, ) - Promise.resolved(responseResult) + Promise.resolve(responseResult) }) let updateSetting = (~userId, ~sessionId, ~settingKey, ~settingValue) => { @@ -179,7 +179,7 @@ let updateSetting = (~userId, ~sessionId, ~settingKey, ~settingValue) => { Fetch.RequestInit.make( ~method_=Patch, ~body=Fetch.BodyInit.make( - Js.Json.stringify( + JSON.stringify( Json.Encode.object_(list{ ("key", Json.Encode.string(settingKey)), ("value", settingValue), @@ -197,7 +197,7 @@ let updateSetting = (~userId, ~sessionId, ~settingKey, ~settingValue) => { (), ), ) - Promise.resolved(responseResult) + Promise.resolve(responseResult) }) } @@ -210,20 +210,20 @@ let patchMe = (~userId, ~sessionId, ~username, ~newPassword, ~email, ~oldPasswor Fetch.RequestInit.make( ~method_=Patch, ~body=Fetch.BodyInit.make( - Js.Json.stringify( - Js.Json.object_( - Js.Dict.fromArray( + JSON.stringify( + JSON.object_( + Dict.fromArray( Array.keepMap( [ - Option.map(username, username => ("username", Js.Json.string(username))), + Option.map(username, username => ("username", JSON.string(username))), Option.map(newPassword, newPassword => ( "password", - Js.Json.string(newPassword), + JSON.string(newPassword), )), - Option.map(email, email => ("email", Js.Json.string(email))), + Option.map(email, email => ("email", JSON.string(email))), Option.map(oldPassword, oldPassword => ( "oldPassword", - Js.Json.string(oldPassword), + JSON.string(oldPassword), )), ], x => x, @@ -242,7 +242,7 @@ let patchMe = (~userId, ~sessionId, ~username, ~newPassword, ~email, ~oldPasswor (), ), ) - Promise.resolved(response) + Promise.resolve(response) }) } @@ -262,7 +262,7 @@ let getUserLists = (~sessionId) => { (), ), ) - Promise.resolved(responseResult) + Promise.resolve(responseResult) }) } @@ -274,7 +274,7 @@ let createItemList = (~sessionId, ~items: array<(int, int)>) => { Fetch.RequestInit.make( ~method_=Post, ~body=Fetch.BodyInit.make( - Js.Json.stringify({ + JSON.stringify({ open Json.Encode object_(list{("items", array(tuple2(int, int), items))}) }), @@ -289,7 +289,7 @@ let createItemList = (~sessionId, ~items: array<(int, int)>) => { (), ), ) - Promise.resolved(responseResult) + Promise.resolve(responseResult) }) } @@ -309,7 +309,7 @@ let cloneItemList = (~sessionId, ~listId) => { (), ), ) - Promise.resolved(responseResult) + Promise.resolve(responseResult) }) } @@ -321,7 +321,7 @@ let updateItemList = (~sessionId, ~listId, ~title=?, ~items: option { (), ), ) - Promise.resolved(responseResult) + Promise.resolve(responseResult) }) } @@ -383,7 +383,7 @@ let getItemList = (~listId: string) => { (), ), ) - Promise.resolved(responseResult) + Promise.resolve(responseResult) }) } @@ -404,11 +404,11 @@ let followUser = (~userId, ~sessionId) => ), ) if Fetch.Response.status(response) < 300 { - Promise.resolved(Ok()) + Promise.resolve(Ok()) } else { %Repromise.JsExn({ let text = Fetch.Response.text(response) - Promise.resolved(Error(text)) + Promise.resolve(Error(text)) }) } }) @@ -430,11 +430,11 @@ let unfollowUser = (~userId, ~sessionId) => ), ) if Fetch.Response.status(response) < 300 { - Promise.resolved(Ok()) + Promise.resolve(Ok()) } else { %Repromise.JsExn({ let text = Fetch.Response.text(response) - Promise.resolved(Error(text)) + Promise.resolve(Error(text)) }) } }) @@ -454,7 +454,7 @@ let getFolloweesItem = (~sessionId, ~itemId) => (), ), ) - Promise.resolved(response) + Promise.resolve(response) }) let connectDiscordAccount = (~sessionId, ~code) => @@ -464,7 +464,7 @@ let connectDiscordAccount = (~sessionId, ~code) => Fetch.RequestInit.make( ~method_=Post, ~body=Fetch.BodyInit.make( - Js.Json.stringify(Json.Encode.object_(list{("code", Js.Json.string(code))})), + JSON.stringify(Json.Encode.object_(list{("code", JSON.string(code))})), ), ~headers=Fetch.HeadersInit.make({ "X-Client-Version": Constants.gitCommitRef, @@ -476,7 +476,7 @@ let connectDiscordAccount = (~sessionId, ~code) => (), ), ) - Promise.resolved(response) + Promise.resolve(response) }) let removeAllItems = (~sessionId) => @@ -495,7 +495,7 @@ let removeAllItems = (~sessionId) => (), ), ) - Promise.resolved(responseResult) + Promise.resolve(responseResult) }) let deleteAccount = (~sessionId, ~userId) => @@ -514,5 +514,5 @@ let deleteAccount = (~sessionId, ~userId) => (), ), ) - Promise.resolved(responseResult) + Promise.resolve(responseResult) }) diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/App.res b/tests/syntax_tests/data/idempotency/nook-exchange/App.res index c712f1282b0..98a4bf23a65 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/App.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/App.res @@ -59,22 +59,22 @@ let make = () => { let url = ReasonReactRouter.useUrl() let (showLogin, setShowLogin) = React.useState(() => false) let itemDetails = { - let result = url.hash->Js.Re.exec_(/i(-?\d+)(:(\d+))?/g) + let result = url.hash->RegExp.exec(/i(-?\d+)(:(\d+))?/g) switch result { | Some(match_) => - let captures = Js.Re.captures(match_) - let itemId = captures[1]->Js.Nullable.toOption->Belt.Option.getExn + let captures = RegExp.Result.matches(match_) + let itemId = captures[1]->Nullable.toOption->Belt.Option.getExn Item.itemMap - ->Js.Dict.get(itemId) + ->Dict.get(itemId) ->Belt.Option.map(item => ( item, - captures[3]->Js.Nullable.toOption->Belt.Option.map(int_of_string), + captures[3]->Nullable.toOption->Belt.Option.map(int_of_string), )) | None => None } } - let pathString = "/" ++ Js.Array.joinWith("/", Belt.List.toArray(url.path)) + let pathString = "/" ++ Array.joinUnsafe(Belt.List.toArray(url.path), "/") React.useEffect0(() => { Analytics.Amplitude.logEventWithProperties( ~eventName="Session Started", @@ -143,9 +143,9 @@ let make = () => { } DiscordOauth.process( ~code, - ~isLogin=state->Js.String.startsWith("login"), - ~isRegister=state->Js.String.startsWith("register"), - ~isConnect=state->Js.String.startsWith("connect"), + ~isLogin=state->String.startsWith("login"), + ~isRegister=state->String.startsWith("register"), + ~isConnect=state->String.startsWith("connect"), )->ignore ReasonReactRouter.replace("/") | _ => () diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/Constants.res b/tests/syntax_tests/data/idempotency/nook-exchange/Constants.res index 8bb2cbb91a5..8edf69ffcf9 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/Constants.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/Constants.res @@ -2,7 +2,7 @@ external nodeEnv: option = "NODE_ENV" @val @scope(("process", "env")) external gitCommitRef: option = "COMMIT_REF" -let gitCommitRef = Belt.Option.getWithDefault(gitCommitRef, "")->Js.String.slice(~from=0, ~to_=8) +let gitCommitRef = Belt.Option.getWithDefault(gitCommitRef, "")->String.slice(~start=0, ~end=8) let apiUrl = nodeEnv === Some("paul-development") ? "http://localhost:3000" : "https://a.nook.exchange" diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/DeleteFromCatalog.res b/tests/syntax_tests/data/idempotency/nook-exchange/DeleteFromCatalog.res index a8bf6792b9e..b0e920a6cfa 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/DeleteFromCatalog.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/DeleteFromCatalog.res @@ -2,7 +2,7 @@ module PersistConfig = { let key = "confirm_catalog_delete" let value = ref(Dom.Storage.localStorage->Dom.Storage.getItem(key)) let confirm = () => { - let nowString = Js.Date.now()->Js.Float.toString + let nowString = Date.now()->Float.toString value := Some(nowString) Dom.Storage.localStorage->Dom.Storage.setItem(key, nowString) } diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/DiscordBotUpsell.res b/tests/syntax_tests/data/idempotency/nook-exchange/DiscordBotUpsell.res index a6a95e49e6e..44f2fec3f89 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/DiscordBotUpsell.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/DiscordBotUpsell.res @@ -2,7 +2,7 @@ module PersistConfig = { let key = "dismiss_discord_bot_notice" let value = ref(Dom.Storage.localStorage->Dom.Storage.getItem(key)) let dismiss = () => { - let nowString = Js.Date.now()->Js.Float.toString + let nowString = Date.now()->Float.toString value := Some(nowString) Dom.Storage.localStorage->Dom.Storage.setItem(key, nowString) } diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/DiscordOauth.res b/tests/syntax_tests/data/idempotency/nook-exchange/DiscordOauth.res index 84d408e5b39..3ab32999738 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/DiscordOauth.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/DiscordOauth.res @@ -57,7 +57,7 @@ let process = (~code, ~isLogin, ~isRegister, ~isConnect) => | Error(_) => Error.showPopup(~message="Something went wrong. Sorry! Please reload and try again.") } - Promise.resolved() + Promise.resolve() })->ignore } else if isConnect { UserStore.connectDiscordAccount(~code)->ignore diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/Emoji.res b/tests/syntax_tests/data/idempotency/nook-exchange/Emoji.res index efb2e03b2a0..97ab7f03c83 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/Emoji.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/Emoji.res @@ -37,45 +37,39 @@ let parseText = (text: string): React.element => { let children = [] let iter = ref(0) - let resultRef = ref(text->Js.Re.exec_(emojiRegex)) + let resultRef = ref(text->RegExp.exec(emojiRegex)) while resultRef.contents != None { let result = Belt.Option.getExn(resultRef.contents) - let matches = Js.Re.captures(result) - let emojiColons = Belt.Option.getExn(Js.Nullable.toOption(matches[2])) + let matches = RegExp.Result.matches(result) + let emojiColons = Belt.Option.getExn(Nullable.toOption(matches[2])) let offset = - Js.Re.index(result) + Belt.Option.getExn(Js.Nullable.toOption(matches[1]))->Js.String.length + RegExp.Result.index(result) + Belt.Option.getExn(Nullable.toOption(matches[1]))->String.length if iter.contents < offset { children - ->Js.Array.push( - - {React.string(text->Js.String.substring(~from=iter.contents, ~to_=offset))} - , - ) + ->Array.push( + {React.string(text->String.substring(~start=iter.contents, ~end=offset))} + ) ->ignore } children - ->Js.Array.push( - switch emojiColons { - | ":nmt:" => - | ":bell:" => + ->Array.push(switch emojiColons { + | ":nmt:" => + | ":bell:" => | _ => - + - }, - ) + }) ->ignore - resultRef := text->Js.Re.exec_(emojiRegex) - iter := offset + Js.String.length(emojiColons) + resultRef := text->RegExp.exec(emojiRegex) + iter := offset + String.length(emojiColons) } - if iter.contents < Js.String.length(text) { + if iter.contents < String.length(text) { children - ->Js.Array.push( - - {React.string(text->Js.String.substringToEnd(~from=iter.contents))} - , - ) + ->Array.push( + {React.string(text->String.substring(~start=iter.contents))} + ) ->ignore } React.array(children) diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/Experiment.res b/tests/syntax_tests/data/idempotency/nook-exchange/Experiment.res index 6a4f41a2c39..d99ac7948cb 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/Experiment.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/Experiment.res @@ -7,18 +7,18 @@ let triggerKey = "triggered_experiments" let triggeredMap = ref( (Dom.Storage.localStorage->Dom.Storage.getItem(triggerKey)) ->Belt.Option.map(value => { - let json = Js.Json.parseExn(value) + let json = JSON.parseOrThrow(value) open Json.Decode dict(string, json) }) - ->Belt.Option.getWithDefault(Js.Dict.empty()), + ->Belt.Option.getWithDefault(Dict.make()), ) let addTrigger = (key, value) => { - triggeredMap.contents->Js.Dict.set(key, value) + triggeredMap.contents->Dict.set(key, value) open Dom.Storage localStorage->setItem( triggerKey, - Js.Json.stringify({ + JSON.stringify({ open Json.Encode dict(string, triggeredMap.contents) }), @@ -30,7 +30,7 @@ let getBucketHash = () => switch bucketHash.contents { | Some(bucketHash) => bucketHash | None => - let value = Js.Math.random_int(0, max_int) + let value = Math.Int.random(0, max_int) bucketHash := Some(value) Dom.Storage.localStorage->Dom.Storage.setItem(key, string_of_int(value)) value @@ -55,7 +55,7 @@ let getBucketIdForExperiment = (~experimentId) => } let trigger = (~experimentId, ~bucketId) => - if triggeredMap.contents->Js.Dict.get(experimentId) != Some(bucketId) { + if triggeredMap.contents->Dict.get(experimentId) != Some(bucketId) { addTrigger(experimentId, bucketId) Analytics.Amplitude.addExperimentBucket(~experimentId, ~bucketId) Analytics.Amplitude.logEventWithProperties( diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/FriendsPage.res b/tests/syntax_tests/data/idempotency/nook-exchange/FriendsPage.res index 08fe81649c8..1aa95fa4d0a 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/FriendsPage.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/FriendsPage.res @@ -38,7 +38,7 @@ let fetchFeed = () => ->array(json => { let items = (json->field("items", dict(User.itemFromJson))) - ->Js.Dict.entries + ->Dict.toArray ->Belt.Array.keepMap(((itemKey, item)) => item->Belt.Option.flatMap(item => User.fromItemKey(~key=itemKey)->Belt.Option.map(((itemId, variant)) => ( @@ -48,9 +48,8 @@ let fetchFeed = () => )) ) ) - ->Js.Array.sortInPlaceWith(((_, _, aItem: User.item), (_, _, bItem: User.item)) => - compareOptionTimestamps(aItem.timeUpdated, bItem.timeUpdated) - ) + ->Array.toSorted((a, b) => Ordering.fromInt((((_, _, aItem: User.item), (_, _, bItem: User.item)) => + compareOptionTimestamps(aItem.timeUpdated, bItem.timeUpdated))(a, b))) { id: json->field("id", string), username: json->field("username", string), @@ -60,8 +59,8 @@ let fetchFeed = () => items: items, } }) - ->Js.Array.sortInPlaceWith((a, b) => compareOptionTimestamps(a.lastUpdate, b.lastUpdate)) - Promise.resolved(feed) + ->Array.toSorted((a, b) => Ordering.fromInt(((a, b) => compareOptionTimestamps(a.lastUpdate, b.lastUpdate))(a, b))) + Promise.resolve(feed) }) }) @@ -206,7 +205,7 @@ module Followee = { ) | Error(_) => () } - Promise.resolved() + Promise.resolve() })->ignore }} className=Styles.unfollowLink> @@ -217,18 +216,17 @@ module Followee = { {!unfollowed ?
{followee.items - ->Js.Array.slice(~start=0, ~end_=numCards - 1) - ->Js.Array.map(((itemId, variant, userItem)) => + ->Array.slice(~start=0, ~end=numCards - 1) + ->Array.map(((itemId, variant, userItem)) => - ) + />) ->React.array} - {Js.Array.length(followee.items) > 0 + {Array.length(followee.items) > 0 ? Some(feed)) Analytics.Amplitude.logEventWithProperties( ~eventName="Friend Page Viewed", - ~eventProperties={"numFollowees": Js.Array.length(feed)}, + ~eventProperties={"numFollowees": Array.length(feed)}, ) - Promise.resolved() + Promise.resolve() })->ignore None }) @@ -296,10 +294,10 @@ module WithViewer = { {switch feed { | Some(feed) => - Js.Array.length(feed) > 0 + Array.length(feed) > 0 ?
{feed - ->Js.Array.map(followee => ) + ->Array.map(followee => ) ->React.array}
:
diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/HeaderBar.res b/tests/syntax_tests/data/idempotency/nook-exchange/HeaderBar.res index eff9d252270..ead5a309962 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/HeaderBar.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/HeaderBar.res @@ -81,7 +81,7 @@ let userHasFriends = (user: option) => switch user { | Some(me) => switch me.followeeIds { - | Some(followeeIds) => Js.Array.length(followeeIds) > 0 + | Some(followeeIds) => Array.length(followeeIds) > 0 | None => false } | None => false diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/ImportPage.res b/tests/syntax_tests/data/idempotency/nook-exchange/ImportPage.res index 931ee44660b..741f7f4f23c 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/ImportPage.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/ImportPage.res @@ -174,7 +174,7 @@ module VariantRow = { Styles.radioButton, Cn.ifTrue( Styles.radioButtonSelected, - Js.Dict.get(itemsState, User.getItemKey(~itemId=item.id, ~variation=variant)) == + Dict.get(itemsState, User.getItemKey(~itemId=item.id, ~variation=variant)) == Some(destination), ), })}> @@ -241,7 +241,7 @@ module ResultRowWithItem = { className=Styles.itemRowNameLink> {React.string(Item.getName(item))} - {Js.Array.length(variants) > 1 + {Array.length(variants) > 1 ?
{React.string("Quick")}
@@ -256,9 +256,8 @@ module ResultRowWithItem = {
{variants - ->Js.Array.map(variant => - - ) + ->Array.map(variant => + ) ->React.array}
@@ -269,7 +268,7 @@ module BulkActions = { @react.component let make = (~setItemStates) => { let (showPopup, setShowPopup) = React.useState(() => false) - let reference = React.useRef(Js.Nullable.null) + let reference = React.useRef(Nullable.null) <>
itemStates - ->Js.Dict.entries - ->Js.Array.map(((key, _value)) => (key, #Ignore)) - ->Js.Dict.fromArray + ->Dict.toArray + ->Array.map(((key, _value)) => (key, #Ignore)) + ->Dict.fromArray ) setShowPopup(_ => false) Analytics.Amplitude.logEventWithProperties( @@ -323,9 +322,9 @@ module BulkActions = { ReactEvent.Mouse.preventDefault(e) setItemStates(itemStates => itemStates - ->Js.Dict.entries - ->Js.Array.map(((key, _value)) => (key, #ForTrade)) - ->Js.Dict.fromArray + ->Dict.toArray + ->Array.map(((key, _value)) => (key, #ForTrade)) + ->Dict.fromArray ) setShowPopup(_ => false) Analytics.Amplitude.logEventWithProperties( @@ -341,9 +340,9 @@ module BulkActions = { ReactEvent.Mouse.preventDefault(e) setItemStates(itemStates => itemStates - ->Js.Dict.entries - ->Js.Array.map(((key, _value)) => (key, #CatalogOnly)) - ->Js.Dict.fromArray + ->Dict.toArray + ->Array.map(((key, _value)) => (key, #CatalogOnly)) + ->Dict.fromArray ) setShowPopup(_ => false) Analytics.Amplitude.logEventWithProperties( @@ -359,8 +358,8 @@ module BulkActions = { ReactEvent.Mouse.preventDefault(e) setItemStates(itemStates => itemStates - ->Js.Dict.entries - ->Js.Array.map(((key, value)) => { + ->Dict.toArray + ->Array.map(((key, value)) => { let (itemId, _variant) = User.fromItemKey(~key)->Option.getExn let item = Item.getItem(~itemId) ( @@ -372,7 +371,7 @@ module BulkActions = { }, ) }) - ->Js.Dict.fromArray + ->Dict.fromArray ) setShowPopup(_ => false) Analytics.Amplitude.logEventWithProperties( @@ -388,9 +387,9 @@ module BulkActions = { ReactEvent.Mouse.preventDefault(e) setItemStates(itemStates => itemStates - ->Js.Dict.entries - ->Js.Array.map(((key, _value)) => (key, #Wishlist)) - ->Js.Dict.fromArray + ->Dict.toArray + ->Array.map(((key, _value)) => (key, #Wishlist)) + ->Dict.fromArray ) setShowPopup(_ => false) Analytics.Amplitude.logEventWithProperties( @@ -421,7 +420,7 @@ module Results = { ~onReset, ) => { let (itemsState, setItemStates) = React.useState(() => - Js.Dict.fromArray( + Dict.fromArray( Array.concatMany( matches->Array.map(((item, variants)) => variants->Belt.Array.map(variant => ( @@ -464,7 +463,7 @@ module Results = { {React.string("!")}
: React.null} - {Js.Array.length(misses) > 0 + {Array.length(misses) > 0 ?
{React.string("Items without matches")}
{misses @@ -474,7 +473,7 @@ module Results = { ->React.array}
: React.null} - {Js.Array.length(matches) > 0 + {Array.length(matches) > 0 ?
{matches ->Belt.Array.map(((item, variants)) => @@ -485,7 +484,7 @@ module Results = { onChange={(itemId, variant, destination) => setItemStates(itemsState => { let clone = Utils.cloneJsDict(itemsState) - clone->Js.Dict.set(User.getItemKey(~itemId, ~variation=variant), destination) + clone->Dict.set(User.getItemKey(~itemId, ~variation=variant), destination) clone })} key={string_of_int(item.id)} @@ -528,7 +527,7 @@ module Results = { let numCatalog = ref(0) let numWishlist = ref(0) itemsState - ->Js.Dict.entries + ->Dict.toArray ->Array.forEach(((_itemKey, destination)) => switch destination { | #ForTrade => numForTrade := numForTrade.contents + 1 @@ -546,9 +545,7 @@ module Results = { ) { ConfirmDialog.confirm( ~bodyText="This will add " ++ - (Js.Array.joinWith( - ", ", - Array.keepMap( + (Array.joinUnsafe(Array.keepMap( [ switch numForTrade.contents { | 0 => None @@ -568,8 +565,7 @@ module Results = { }, ], x => x, - ), - ) ++ + ), ", ") ++ " items. Are you sure you want to continue?"), ~confirmLabel="Do it!", ~cancelLabel="Never mind", @@ -577,7 +573,7 @@ module Results = { setSubmitState(_ => Some(Submitting)) let updates = itemsState - ->Js.Dict.entries + ->Dict.toArray ->Array.keepMap(((itemKey, value)) => switch value { | #Ignore => None @@ -606,10 +602,10 @@ module Results = { ~eventProperties={ "numMismatch": numMissingRows, "numMatch": numMatchingRows, - "numUpdates": Js.Array.length(updates), + "numUpdates": Array.length(updates), }, ) - Promise.resolved() + Promise.resolve() } else { %Repromise.JsExn({ let text = Fetch.Response.text(response) @@ -619,16 +615,16 @@ module Results = { "error": text, "numMismatch": numMissingRows, "numMatch": numMatchingRows, - "numUpdates": Js.Array.length(updates), + "numUpdates": Array.length(updates), }, ) setSubmitState(_ => Some(Error(text))) - Promise.resolved() + Promise.resolve() }) } | Error(_error) => setSubmitState(_ => Some(Error("Something went wrong. Sorry!"))) - Promise.resolved() + Promise.resolve() } })->ignore }, @@ -648,18 +644,18 @@ module Results = { let process = value => { let rows = value - ->Js.String.split("\n") - ->Js.Array.map(str => str->Js.String.trim) - ->Js.Array.filter(x => x != "") - let resultMap = Js.Dict.empty() + ->String.split("\n") + ->Array.map(str => str->String.trim) + ->Array.filter(x => x != "") + let resultMap = Dict.make() let missingQueries = [] rows->Array.forEach(row => { - let result = row->Js.Re.exec_(/(.*?) \[(.*?)\]$/g) + let result = row->RegExp.exec(/(.*?) \[(.*?)\]$/g) let itemWithVariant = switch result { | Some(match_) => - let captures = Js.Re.captures(match_) - let itemName = Array.getUnsafe(captures, 1)->Js.Nullable.toOption - let variantName = Array.getUnsafe(captures, 2)->Js.Nullable.toOption + let captures = RegExp.Result.matches(match_) + let itemName = Array.getUnsafe(captures, 1)->Nullable.toOption + let variantName = Array.getUnsafe(captures, 2)->Nullable.toOption switch (itemName, variantName) { | (Some(itemName), Some(variantName)) => Item.getByName(~name=itemName)->Option.flatMap(item => @@ -676,28 +672,26 @@ let process = value => { } switch itemWithVariants { | Some((item, variants)) => - let resultMapVariants = switch resultMap->Js.Dict.get(string_of_int(item.id)) { + let resultMapVariants = switch resultMap->Dict.get(string_of_int(item.id)) { | Some(arr) => arr | None => let arr = [] - resultMap->Js.Dict.set(string_of_int(item.id), arr) + resultMap->Dict.set(string_of_int(item.id), arr) arr } - variants->Js.Array.forEach(variant => - if !(resultMapVariants->Js.Array.includes(variant)) { - resultMapVariants->Js.Array.push(variant)->ignore - } - ) - | None => missingQueries->Js.Array.push(row)->ignore + variants->Array.forEach(variant => + if !(resultMapVariants->Array.includes(variant)) { + resultMapVariants->Array.push(variant)->ignore + }) + | None => missingQueries->Array.push(row)->ignore } }) ( resultMap - ->Js.Dict.entries + ->Dict.toArray ->Array.map(((itemId, variants)) => (Item.getItem(~itemId=int_of_string(itemId)), variants)) - ->Js.Array.sortInPlaceWith(((aItem, _), (bItem, _)) => - ItemFilters.compareItemsABC(aItem, bItem) - ), + ->Array.toSorted((a, b) => Ordering.fromInt((((aItem, _), (bItem, _)) => + ItemFilters.compareItemsABC(aItem, bItem))(a, b))), missingQueries, ) } @@ -739,15 +733,15 @@ let make = (~showLogin, ~url: ReasonReactRouter.url) => { %Repromise.JsExn({ let text = Fetch.Response.text(response) setResults(_ => Some(process(text))) - Promise.resolved() + Promise.resolve() }) } else { - Promise.resolved() + Promise.resolve() } - | Error(_) => Promise.resolved() + | Error(_) => Promise.resolve() } }) - | None => Promise.resolved() + | None => Promise.resolve() }->ignore Analytics.Amplitude.logEvent(~eventName="Import Page Viewed") None diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/Item.res b/tests/syntax_tests/data/idempotency/nook-exchange/Item.res index 91565bd442f..755e0ed1bbe 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/Item.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/Item.res @@ -73,10 +73,10 @@ let clothingCategories = [ "wetsuits", ] -@val @scope("window") external itemsJson: Js.Json.t = "items" -@val @scope("window") external variantsJson: Js.Json.t = "variants" +@val @scope("window") external itemsJson: JSON.t = "items" +@val @scope("window") external variantsJson: JSON.t = "variants" -let loadTranslation: (string, Js.Json.t => unit) => unit = %raw(`function(language, callback) { +let loadTranslation: (string, JSON.t => unit) => unit = %raw(`function(language, callback) { import(/* webpackChunkName */ './translations/' + language + '.json').then(j => callback(j.default)) }`) @@ -85,18 +85,18 @@ exception UnexpectedType(string) let spaceRegex = /\s/g exception Unexpected -let jsonToItems = (json: Js.Json.t) => { +let jsonToItems = (json: JSON.t) => { open Json.Decode let flags = json->field("flags", int) let recipeInfo = json->optional( field("recipe", json => { - let jsonArray = Js.Json.decodeArray(json)->Belt.Option.getExn + let jsonArray = JSON.decodeArray(json)->Belt.Option.getExn ( -int(jsonArray[0]), string(jsonArray[1]), jsonArray - ->Js.Array.sliceFrom(2) - ->Js.Array.map(json => { + ->Array.slice(~start=2) + ->Array.map(json => { let (quantity, itemName) = json->tuple2(int, string) (itemName, quantity) }), @@ -148,27 +148,27 @@ let jsonToItems = (json: Js.Json.t) => { ] | None => [item] } - items->Js.Array.map((item: t) => { + items->Array.map((item: t) => { let extraTags = [] switch item.source { | Some(source) => if source == "Jolly Redd's Treasure Trawler" { - extraTags->Js.Array.push("redd")->ignore + extraTags->Array.push("redd")->ignore } | None => () } - {...item, tags: item.tags->Js.Array.concat(extraTags)} + {...item, tags: item.tags->Array.concat(extraTags)} }) } let all = itemsJson->Json.Decode.array(jsonToItems)->Belt.Array.concatMany let itemMap = { - let itemMap = Js.Dict.empty() - all->Belt.Array.forEach(item => itemMap->Js.Dict.set(string_of_int(item.id), item)) + let itemMap = Dict.make() + all->Belt.Array.forEach(item => itemMap->Dict.set(string_of_int(item.id), item)) itemMap } -let getItem = (~itemId) => itemMap->Js.Dict.unsafeGet(string_of_int(itemId)) +let getItem = (~itemId) => itemMap->Dict.getUnsafe(string_of_int(itemId)) exception UnexpectedVersion(string) let getImageUrl = (~item, ~variant) => @@ -253,7 +253,7 @@ let variantNames: dict = variantsJson->{ ) } -let loadTranslation: (string, Js.Json.t => unit) => unit = %raw(`function(language, callback) { +let loadTranslation: (string, JSON.t => unit) => unit = %raw(`function(language, callback) { import(/* webpackChunkName */ './translations/' + language + '.json').then(j => callback(j.default)) }`) type translationItem = { @@ -272,7 +272,7 @@ let setTranslations = json => { items: json->field( "items", dict(json => { - let row = Js.Json.decodeArray(json)->Belt.Option.getExn + let row = JSON.decodeArray(json)->Belt.Option.getExn { name: string(row[0]), variants: Belt.Option.map(Belt.Array.get(row, 1), json => @@ -294,13 +294,13 @@ let getName = (item: t) => | Recipe(itemId) => open Belt translations.contents - ->Option.flatMap(translations => Js.Dict.get(translations.items, string_of_int(itemId))) + ->Option.flatMap(translations => Dict.get(translations.items, string_of_int(itemId))) ->Option.map(translation => translation.name ++ " DIY") ->Option.getWithDefault(item.name) | Item(_) => open Belt translations.contents - ->Option.flatMap(translations => Js.Dict.get(translations.items, string_of_int(item.id))) + ->Option.flatMap(translations => Dict.get(translations.items, string_of_int(item.id))) ->Option.map(translation => translation.name) ->Option.getWithDefault(item.name) } @@ -311,10 +311,10 @@ let getVariantName = (~item: t, ~variant: int, ~hideBody=false, ~hidePattern=fal | Single => None | OneDimension(_) => switch translations.contents - ->Option.flatMap(translations => Js.Dict.get(translations.items, string_of_int(item.id))) + ->Option.flatMap(translations => Dict.get(translations.items, string_of_int(item.id))) ->Option.flatMap(translationItem => translationItem.variants) { | Some(value) => Some(value) - | None => variantNames->Js.Dict.get(_, string_of_int(item.id)) + | None => variantNames->Dict.get(_, string_of_int(item.id)) }->Option.flatMap(value => switch value { | NameOneDimension(names) => Some(Option.getExn(names[variant])) @@ -323,10 +323,10 @@ let getVariantName = (~item: t, ~variant: int, ~hideBody=false, ~hidePattern=fal ) | TwoDimensions(_a, b) => switch translations.contents - ->Option.flatMap(translations => Js.Dict.get(translations.items, string_of_int(item.id))) + ->Option.flatMap(translations => Dict.get(translations.items, string_of_int(item.id))) ->Option.flatMap(translationItem => translationItem.variants) { | Some(value) => Some(value) - | None => variantNames->Js.Dict.get(_, string_of_int(item.id)) + | None => variantNames->Dict.get(_, string_of_int(item.id)) }->Belt.Option.flatMap(value => switch value { | NameTwoDimensions((nameA, nameB)) => @@ -349,11 +349,11 @@ let getVariantName = (~item: t, ~variant: int, ~hideBody=false, ~hidePattern=fal let getMaterialName = (material: string) => { open Belt translations.contents - ->Option.flatMap(translations => Js.Dict.get(translations.materials, material)) + ->Option.flatMap(translations => Dict.get(translations.materials, material)) ->Option.getWithDefault(material) } -let getCanonicalName = text => Js.String.toLowerCase(text)->Js.String.replaceByRe(spaceRegex, "-") +let getCanonicalName = text => String.toLowerCase(text)->String.replaceRegExp(spaceRegex, "-") let getByName = (~name: string) => { let searchName = getCanonicalName(name) all->Belt.Array.getBy((item: t) => diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/ItemBrowser.res b/tests/syntax_tests/data/idempotency/nook-exchange/ItemBrowser.res index 18b2b9ecf0b..21efaddf21f 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/ItemBrowser.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/ItemBrowser.res @@ -63,7 +63,7 @@ let getNumResultsPerPage = () => { let getUrl = (~url: ReasonReactRouter.url, ~urlSearchParams: Webapi.Url.URLSearchParams.t) => "/" ++ - (Js.Array.joinWith("/", Belt.List.toArray(url.path)) ++ + (Array.joinUnsafe(Belt.List.toArray(url.path), "/") ++ switch Webapi.Url.URLSearchParams.toString(urlSearchParams) { | "" => "" | search => "?" ++ search @@ -97,7 +97,7 @@ let make = (~showLogin, ~url: ReasonReactRouter.url) => { React.Ref.setCurrent(numFiltersChangeLogged, React.Ref.current(numFiltersChangeLogged) + 1) } } - let rootRef = React.useRef(Js.Nullable.null) + let rootRef = React.useRef(Nullable.null) let setPageOffset = f => { let nextPageOffset = f(pageOffset) let urlSearchParams = Webapi.Url.URLSearchParams.makeWithArray( @@ -105,43 +105,43 @@ let make = (~showLogin, ~url: ReasonReactRouter.url) => { ) ReasonReactRouter.push(getUrl(~url, ~urlSearchParams)) } - let excludeString = filters.exclude->Js.Array.joinWith(",") + let excludeString = filters.exclude->Array.joinUnsafe(",") let excludeUserItemIds = React.useMemo2(() => - if isLoggedIn && Js.Array.length(filters.exclude) > 0 { + if isLoggedIn && Array.length(filters.exclude) > 0 { let userItems = UserStore.getUser().items - let userItemMap = Js.Dict.empty() + let userItemMap = Dict.make() userItems - ->Js.Dict.entries + ->Dict.toArray ->Belt.Array.forEach(((itemKey, userItem)) => if ( switch userItem.status { - | Wishlist => filters.exclude->Js.Array.includes(ItemFilters.Wishlist) + | Wishlist => filters.exclude->Array.includes(ItemFilters.Wishlist) | CanCraft => - filters.exclude->Js.Array.includes(ItemFilters.Catalog) || - filters.exclude->Js.Array.includes(ItemFilters.CanCraft) + filters.exclude->Array.includes(ItemFilters.Catalog) || + filters.exclude->Array.includes(ItemFilters.CanCraft) | CatalogOnly | ForTrade => - filters.exclude->Js.Array.includes(ItemFilters.Catalog) + filters.exclude->Array.includes(ItemFilters.Catalog) } ) { let (itemId, variant) = User.fromItemKey(~key=itemKey)->Belt.Option.getExn - let itemVariantList = switch Js.Dict.get(userItemMap, string_of_int(itemId)) { + let itemVariantList = switch Dict.get(userItemMap, string_of_int(itemId)) { | Some(list) => list | None => let list = [] - userItemMap->Js.Dict.set(string_of_int(itemId), list) + userItemMap->Dict.set(string_of_int(itemId), list) list } - itemVariantList->Js.Array.push(variant)->ignore + itemVariantList->Array.push(variant)->ignore } ) userItemMap - ->Js.Dict.entries + ->Dict.toArray ->Belt.Array.keepMap(((itemId, variantList)) => { let itemId = int_of_string(itemId) let numVariations = Item.getCollapsedVariants(~item=Item.getItem(~itemId)) // Exclude item only if user has all variants - if Js.Array.length(variantList) >= Js.Array.length(numVariations) { + if Array.length(variantList) >= Array.length(numVariations) { Some(itemId) } else { None @@ -155,12 +155,12 @@ let make = (~showLogin, ~url: ReasonReactRouter.url) => { () => Item.all->Belt.Array.keep(item => !( - Js.Array.includes(item.id, excludeUserItemIds) || + Array.includes(excludeUserItemIds, item.id) || (Item.isRecipe(~item) && - Js.Array.includes(Item.getItemIdForRecipe(~recipe=item), excludeUserItemIds)) + Array.includes(excludeUserItemIds, Item.getItemIdForRecipe(~recipe=item))) ) && ItemFilters.doesItemMatchFilters(~item, ~filters) - )->Js.Array.sortInPlaceWith(ItemFilters.getSort(~sort=filters.sort)), + )->Array.toSorted((a, b) => Ordering.fromInt((ItemFilters.getSort(~sort=filters.sort))(a, b))), (filters, excludeUserItemIds), ) let numResults = filteredItems->Belt.Array.length @@ -212,7 +212,7 @@ let make = (~showLogin, ~url: ReasonReactRouter.url) => { numResults pageOffset numResultsPerPage setPageOffset={f => setPageOffset(f)} />
- {if Js.Array.length(filteredItems) == 0 { + {if Array.length(filteredItems) == 0 {
{React.string("There are no results. Try changing or ")} { let (showLayer, setShowLayer) = React.useState(() => false) - let iconRef = React.useRef(Js.Nullable.null) + let iconRef = React.useRef(Nullable.null) let isMountedRef = React.useRef(true) React.useEffect0(() => Some(() => React.Ref.setCurrent(isMountedRef, false))) <> @@ -233,8 +233,8 @@ module RecipeIcon = { Cn.ifTrue(MetaIconStyles.iconClickable, onClick !== None), Cn.unpack(className), })} - onMouseEnter={_ => Js.Global.setTimeout(() => setShowLayer(_ => true), 10)->ignore} - onMouseLeave={_ => Js.Global.setTimeout(() => + onMouseEnter={_ => setTimeout(() => setShowLayer(_ => true), 10)->ignore} + onMouseLeave={_ => setTimeout(() => if React.Ref.current(isMountedRef) { setShowLayer(_ => false) } @@ -449,7 +449,7 @@ let make = (~item: Item.t, ~isLoggedIn, ~showLogin) => { if variation > numVariations { setVariation(_ => 0) } - let variation = Js.Math.min_int(variation, numVariations - 1) + let variation = Math.Int.min(variation, numVariations - 1) let userItem = UserStore.useItem(~itemId=item.id, ~variation) let hasQuicklist = QuicklistStore.useHasQuicklist() @@ -476,7 +476,7 @@ let make = (~item: Item.t, ~isLoggedIn, ~showLogin) => { { let collapsedVariants = Item.getCollapsedVariants(~item) - if Js.Array.length(collapsedVariants) === 1 { + if Array.length(collapsedVariants) === 1 { React.null } else {
diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/ItemDetailOverlay.res b/tests/syntax_tests/data/idempotency/nook-exchange/ItemDetailOverlay.res index 51a7ece4395..c29d657b935 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/ItemDetailOverlay.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/ItemDetailOverlay.res @@ -302,7 +302,7 @@ module TwoDimensionVariants = {
{React.string(patternName)} @@ -493,7 +493,7 @@ module FriendsSection = { status: json->field("status", int)->User.itemStatusFromJs->Belt.Option.getExn, }) setFriendItems(_ => Some(friendItems)) - Promise.resolved() + Promise.resolve() }) })->ignore None @@ -501,12 +501,12 @@ module FriendsSection = { switch friendItems { | Some(friendItems) => - if Js.Array.length(friendItems) > 0 { + if Array.length(friendItems) > 0 {
{friendItems - ->Js.Array.slice(~start=0, ~end_=showLimit) - ->Js.Array.map(friendItem => + ->Array.slice(~start=0, ~end=showLimit) + ->Array.map(friendItem =>
@@ -534,10 +534,9 @@ module FriendsSection = { {React.string(User.itemStatusToString(friendItem.status))} -
- ) +
) ->React.array} - {Js.Array.length(friendItems) > showLimit + {Array.length(friendItems) > showLimit ?
- {if item.tags->Js.Array.length > 0 { + {if item.tags->Array.length > 0 {
{item.tags @@ -719,7 +718,7 @@ let make = (~item: Item.t, ~variant, ~isInitialLoad) => {
{switch me->Belt.Option.flatMap(me => me.followeeIds) { | Some(followeeIds) => - if Js.Array.length(followeeIds) > 0 { + if Array.length(followeeIds) > 0 { } else { React.null diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/ItemFilters.res b/tests/syntax_tests/data/idempotency/nook-exchange/ItemFilters.res index e1fa96f327a..a4873d67b64 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/ItemFilters.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/ItemFilters.res @@ -109,25 +109,25 @@ let serializeSort = (~sort, ~defaultSort) => let serialize = (~filters, ~defaultSort, ~pageOffset) => { let p = [] switch serializeSort(~sort=filters.sort, ~defaultSort) { - | Some(param) => p->Js.Array.push(param)->ignore + | Some(param) => p->Array.push(param)->ignore | None => () } if filters.text != "" { - p->Js.Array.push(("q", filters.text))->ignore + p->Array.push(("q", filters.text))->ignore } switch filters.mask { - | Some(Orderable) => p->Js.Array.push(("orderable", ""))->ignore - | Some(NotOrderable) => p->Js.Array.push(("not-orderable", ""))->ignore - | Some(Craftable) => p->Js.Array.push(("craftable", ""))->ignore + | Some(Orderable) => p->Array.push(("orderable", ""))->ignore + | Some(NotOrderable) => p->Array.push(("not-orderable", ""))->ignore + | Some(Craftable) => p->Array.push(("craftable", ""))->ignore | None => () } switch filters.category { - | Some(category) => p->Js.Array.push(("c", category))->ignore + | Some(category) => p->Array.push(("c", category))->ignore | None => () } - if Js.Array.length(filters.exclude) > 0 { + if Array.length(filters.exclude) > 0 { p - ->Js.Array.push(( + ->Array.push(( "e", filters.exclude->Belt.Array.map(exclude => switch exclude { @@ -135,12 +135,12 @@ let serialize = (~filters, ~defaultSort, ~pageOffset) => { | CanCraft => "can-craft" | Wishlist => "wishlist" } - )->Js.Array.joinWith(","), + )->Array.joinUnsafe(","), )) ->ignore } if pageOffset != 0 { - p->Js.Array.push(("p", string_of_int(pageOffset + 1)))->ignore + p->Array.push(("p", string_of_int(pageOffset + 1)))->ignore } p } @@ -172,7 +172,7 @@ let fromUrlSearch = (~urlSearch, ~defaultSort) => { ? Some(NotOrderable) : None, category: Option.flatMap(searchParams->get("c"), category => - if Item.validCategoryStrings->Js.Array.includes(category) { + if Item.validCategoryStrings->Array.includes(category) { Some(category) } else { None @@ -180,7 +180,7 @@ let fromUrlSearch = (~urlSearch, ~defaultSort) => { ), exclude: switch searchParams->get("e") { | Some(e) => - (e->Js.String.split(",")) + (e->String.split(",")) ->Belt.Array.keepMap(fragment => switch fragment { | "wishlist" => Some(Wishlist) @@ -199,30 +199,30 @@ let fromUrlSearch = (~urlSearch, ~defaultSort) => { let doesItemMatchCategory = (~item: Item.t, ~category: string) => switch category { - | "furniture" => Item.furnitureCategories->Js.Array.includes(item.category) - | "clothing" => Item.clothingCategories->Js.Array.includes(item.category) + | "furniture" => Item.furnitureCategories->Array.includes(item.category) + | "clothing" => Item.clothingCategories->Array.includes(item.category) | "recipes" => Item.isRecipe(~item) | category => item.category == category } let removeAccents = str => - str->Js.String.normalizeByForm("NFD")->Js.String.replaceByRe(/[\u0300-\u036f]/g, "") + str->String.normalizeByForm("NFD")->String.replaceRegExp(/[\u0300-\u036f]/g, "") let doesItemMatchFilters = (~item: Item.t, ~filters: t) => switch filters.text { | "" => true | text => - let textLower = Js.String.toLowerCase(text) + let textLower = String.toLowerCase(text) switch item.source { - | Some(source) => textLower == Js.String.toLowerCase(source) + | Some(source) => textLower == String.toLowerCase(source) | None => false } || { let fragments = - (textLower->Js.String.splitByRe(/[\s-]+/))->Belt.Array.keepMap(x => x) + (textLower->String.splitByRegExp(/[\s-]+/))->Belt.Array.keepMap(x => x) fragments->Belt.Array.every(fragment => - Js.String.toLowerCase(Item.getName(item)) + String.toLowerCase(Item.getName(item)) ->removeAccents - ->Js.String.includes(removeAccents(fragment)) || item.tags->Js.Array.includes(fragment) + ->String.includes(removeAccents(fragment)) || item.tags->Array.includes(fragment) ) } } && @@ -240,7 +240,7 @@ let doesItemMatchFilters = (~item: Item.t, ~filters: t) => let compareArrays = (a, b) => { let rv = ref(None) let i = ref(0) - while i.contents < Js.Array.length(a) && rv.contents === None { + while i.contents < Array.length(a) && rv.contents === None { if a[i.contents] < b[i.contents] { rv := Some(-1) } else if a[i.contents] > b[i.contents] { @@ -253,9 +253,9 @@ let compareArrays = (a, b) => { let compareItemsABC = (a: Item.t, b: Item.t) => { // hack to sort "wooden-" before "wooden " - let aName = Item.getName(a)->Js.String.replaceByRe(/-/g, " ") - let bName = Item.getName(b)->Js.String.replaceByRe(/-/g, " ") - int_of_float(Js.String.localeCompare(bName, aName)) + let aName = Item.getName(a)->String.replaceRegExp(/-/g, " ") + let bName = Item.getName(b)->String.replaceRegExp(/-/g, " ") + int_of_float(String.localeCompare(aName, bName)) } let compareItemsSellPriceDesc = (a: Item.t, b: Item.t) => compareArrays( @@ -316,21 +316,21 @@ let getUserItemSort = (~prioritizeViewerStatuses: array=[], ~so [ switch UserStore.getItem(~itemId=aId, ~variation=aVariant) { | Some(aUserItem) => - prioritizeViewerStatuses->Js.Array.includes(aUserItem.status) ? -1. : 0. + prioritizeViewerStatuses->Array.includes(aUserItem.status) ? -1. : 0. | None => 0. }, -.Belt.Option.getWithDefault(aPriorityTimestamp, 0.), - Item.categories->Js.Array.indexOf(aItem.category)->float_of_int, + Item.categories->Array.indexOf(aItem.category)->float_of_int, float_of_int(compareItemsABC(aItem, bItem)), ], [ switch UserStore.getItem(~itemId=bId, ~variation=bVariant) { | Some(bUserItem) => - prioritizeViewerStatuses->Js.Array.includes(bUserItem.status) ? -1. : 0. + prioritizeViewerStatuses->Array.includes(bUserItem.status) ? -1. : 0. | None => 0. }, -.Belt.Option.getWithDefault(bPriorityTimestamp, 0.), - Item.categories->Js.Array.indexOf(bItem.category)->float_of_int, + Item.categories->Array.indexOf(bItem.category)->float_of_int, 0., ], ) @@ -356,7 +356,7 @@ let getUserItemSort = (~prioritizeViewerStatuses: array=[], ~so switch (aUserItem.note, bUserItem.note) { | ("", _) => 1 | (_, "") => -1 - | (a, b) => int_of_float(a->Js.String.localeCompare(b)) + | (a, b) => int_of_float(a->String.localeCompare(b)) }, compareItemsABC(aItem, bItem), ], @@ -386,7 +386,7 @@ module Pager = { "Showing " ++ (string_of_int(pageOffset * numResultsPerPage + 1) ++ (" - " ++ - (string_of_int(Js.Math.min_int((pageOffset + 1) * numResultsPerPage, numResults)) ++ + (string_of_int(Math.Int.min((pageOffset + 1) * numResultsPerPage, numResults)) ++ (" of " ++ string_of_int(numResults))))), )} {pageOffset < (numResults - 1) / numResultsPerPage @@ -486,7 +486,7 @@ module CategoryButtons = { {renderButton("clothing")} Js.Array.includes(Catalog)} + checked={filters.exclude->Array.includes(Catalog)} onChange={onChangeCheckbox(Catalog)} /> @@ -596,7 +596,7 @@ module AdvancedFilter = { Js.Array.includes(CanCraft)} + checked={filters.exclude->Array.includes(CanCraft)} onChange={onChangeCheckbox(CanCraft)} /> @@ -607,7 +607,7 @@ module AdvancedFilter = { Js.Array.includes(Wishlist)} + checked={filters.exclude->Array.includes(Wishlist)} onChange={onChangeCheckbox(Wishlist)} /> @@ -769,7 +769,7 @@ let make = ( ~className=?, (), ) => { - let inputTextRef = React.useRef(Js.Nullable.null) + let inputTextRef = React.useRef(Nullable.null) let updateTextTimeoutRef = React.useRef(None) React.useEffect1(() => { { @@ -782,7 +782,7 @@ let make = ( Some( () => { switch React.Ref.current(updateTextTimeoutRef) { - | Some(updateTextTimeout) => Js.Global.clearTimeout(updateTextTimeout) + | Some(updateTextTimeout) => clearTimeout(updateTextTimeout) | None => () } React.Ref.setCurrent(updateTextTimeoutRef, None) @@ -798,12 +798,12 @@ let make = ( | "Escape" => let url = ReasonReactRouter.dangerouslyGetInitialUrl() // don't trigger if ItemDetailOverlay is shown - if !(url.hash->Js.Re.test_(/i(-?\d+)(:(\d+))?/g)) { + if !(url.hash->RegExp.test(/i(-?\d+)(:(\d+))?/g)) { onChange({...filters, text: ""}) } | "/" => if !isInputActiveElement() { - Js.Global.setTimeout( + setTimeout( () => Utils.getElementForDomRef(inputTextRef) ->unsafeAsHtmlInputElement @@ -827,10 +827,10 @@ let make = ( onChange={e => { let value = ReactEvent.Form.target(e)["value"] switch React.Ref.current(updateTextTimeoutRef) { - | Some(updateTextTimeout) => Js.Global.clearTimeout(updateTextTimeout) + | Some(updateTextTimeout) => clearTimeout(updateTextTimeout) | None => () } - React.Ref.setCurrent(updateTextTimeoutRef, Some(Js.Global.setTimeout(() => { + React.Ref.setCurrent(updateTextTimeoutRef, Some(setTimeout(() => { React.Ref.setCurrent(updateTextTimeoutRef, None) onChange({...filters, text: value}) }, 500))) diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/ItemImage.res b/tests/syntax_tests/data/idempotency/nook-exchange/ItemImage.res index 83a22a87e84..45f5ab85248 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/ItemImage.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/ItemImage.res @@ -83,7 +83,7 @@ let make = (
{numCollapsedVariants > 1 ?
{numCollapsedVariants > 1 ?
{switch list { | Some((list, _)) => - if Js.Array.length(list.itemIds) >= 4 { + if Array.length(list.itemIds) >= 4 { { let p = [] switch ItemFilters.serializeSort(~sort, ~defaultSort=ListTimeAdded) { - | Some(param) => p->Js.Array.push(param)->ignore + | Some(param) => p->Array.push(param)->ignore | None => () } let urlSearchParams = Webapi.Url.URLSearchParams.makeWithArray(p) @@ -423,7 +423,7 @@ let make = (~listId, ~url: ReasonReactRouter.url) => { "view": "list", "listId": listId, "numItems": switch list { - | Some((list, _)) => Js.Array.length(list.itemIds) + | Some((list, _)) => Array.length(list.itemIds) | None => 0 }, }, @@ -450,7 +450,7 @@ let make = (~listId, ~url: ReasonReactRouter.url) => { "view": "grid", "listId": listId, "numItems": switch list { - | Some((list, _)) => Js.Array.length(list.itemIds) + | Some((list, _)) => Array.length(list.itemIds) | None => 0 }, }, @@ -468,7 +468,7 @@ let make = (~listId, ~url: ReasonReactRouter.url) => { {React.string("Grid")} {switch list { - | Some((list, _)) => Js.Array.length(list.itemIds) > 8 + | Some((list, _)) => Array.length(list.itemIds) > 8 | None => false } ?
diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/MatchFeatureUpsell.res b/tests/syntax_tests/data/idempotency/nook-exchange/MatchFeatureUpsell.res index f94ef3d7f19..f9ea35b7458 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/MatchFeatureUpsell.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/MatchFeatureUpsell.res @@ -2,7 +2,7 @@ module PersistConfig = { let key = "dismiss_match_list_notice" let value = ref(Dom.Storage.localStorage->Dom.Storage.getItem(key)) let dismiss = () => { - let nowString = Js.Date.now()->Js.Float.toString + let nowString = Date.now()->Float.toString value := Some(nowString) Dom.Storage.localStorage->Dom.Storage.setItem(key, nowString) } diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/Modal.res b/tests/syntax_tests/data/idempotency/nook-exchange/Modal.res index 998f63ff3ea..c305a05a940 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/Modal.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/Modal.res @@ -98,7 +98,7 @@ module CloseButton = { let make = (~children, ~onBackdropClick=?, ()) => { let (transitionIn, setTransitionIn) = React.useState(() => false) React.useEffect0(() => { - Js.Global.setTimeout(() => setTransitionIn(_ => true), 20)->ignore + setTimeout(() => setTransitionIn(_ => true), 20)->ignore None }) diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/MyListsPage.res b/tests/syntax_tests/data/idempotency/nook-exchange/MyListsPage.res index 5dfd5dc6410..7fe78cba82f 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/MyListsPage.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/MyListsPage.res @@ -48,7 +48,7 @@ module WithViewer = { type listInfo = { id: string, - createTime: Js.Date.t, + createTime: Date.t, itemIds: array<(int, int)>, title: option, } @@ -70,18 +70,17 @@ module WithViewer = { title: (json->optional(field("title", string))) ->Belt.Option.flatMap(title => title == "" ? None : Some(title)), }) - }->Js.Array.sortInPlaceWith((a, b) => + }->Array.toSorted((a, b) => Ordering.fromInt(((a, b) => int_of_float({ - open Js.Date + open Date getTime(b.createTime) -. getTime(a.createTime) - }) - ) + }))(a, b))) setLists(_ => Some(lists)) Analytics.Amplitude.logEventWithProperties( ~eventName="My Lists Page Viewed", - ~eventProperties={"numLists": Js.Array.length(lists)}, + ~eventProperties={"numLists": Array.length(lists)}, ) - Promise.resolved() + Promise.resolve() }) })->ignore None @@ -117,7 +116,7 @@ module WithViewer = {
{lists - ->Js.Array.map(list => + ->Array.map(list =>
@@ -128,7 +127,7 @@ module WithViewer = {
{ - let numItems = Js.Array.length(list.itemIds) + let numItems = Array.length(list.itemIds) React.string( string_of_int(numItems) ++ (" item" ++ (numItems == 1 ? "" : "s")), ) @@ -137,8 +136,8 @@ module WithViewer = {
{list.itemIds - ->Js.Array.slice(~start=0, ~end_=8) - ->Js.Array.mapi(((itemId, variant), i) => { + ->Array.slice(~start=0, ~end=8) + ->Array.mapWithIndex(((itemId, variant), i) => { let item = Item.getItem(~itemId) React.array}
- - ) + ) ->React.array} - {if Js.Array.length(lists) == 0 { + {if Array.length(lists) == 0 {
{React.string("You have no custom lists. ")} QuicklistStore.startList()}> @@ -162,7 +160,7 @@ module WithViewer = { React.null }}
- {if Js.Array.length(lists) > 0 { + {if Array.length(lists) > 0 {
QuicklistStore.startList()}> {React.string("Create new custom list")} diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/MyPage.res b/tests/syntax_tests/data/idempotency/nook-exchange/MyPage.res index 39267c58e51..89c9bbfbe53 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/MyPage.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/MyPage.res @@ -65,7 +65,7 @@ module ProfileTextarea = { let (isEditing, setIsEditing) = React.useState(() => false) let (profileText, setProfileText) = React.useState(() => user.profileText) - let textareaRef = React.useRef(Js.Nullable.null) + let textareaRef = React.useRef(Nullable.null) React.useEffect1(() => { if isEditing { open Webapi.Dom @@ -157,11 +157,11 @@ let make = (~user: User.t, ~urlRest, ~url) => { {switch list { | Some(list) => | None => - if user.items->Js.Dict.keys->Js.Array.length > 0 { + if user.items->Dict.keysToArray->Array.length > 0 { Js.Dict.entries + ->Dict.toArray ->Belt.Array.mapU(((itemKey, item)) => ( Belt.Option.getExn(User.fromItemKey(~key=itemKey)), item, diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/PasswordResetPage.res b/tests/syntax_tests/data/idempotency/nook-exchange/PasswordResetPage.res index 0579758e7f6..f60b35103f1 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/PasswordResetPage.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/PasswordResetPage.res @@ -37,10 +37,10 @@ let make = (~url: ReasonReactRouter.url) => { Fetch.RequestInit.make( ~method_=Post, ~body=Fetch.BodyInit.make( - Js.Json.stringify( + JSON.stringify( Json.Encode.object_(list{ - ("token", Js.Json.string(token)), - ("password", Js.Json.string(password)), + ("token", JSON.string(token)), + ("password", JSON.string(password)), }), ), ), @@ -65,7 +65,7 @@ let make = (~url: ReasonReactRouter.url) => { ~eventName="Reset Password Changed Success", ~eventProperties={"token": token, "username": username}, ) - Promise.resolved() + Promise.resolve() }) } else { %Repromise.JsExn({ @@ -75,11 +75,11 @@ let make = (~url: ReasonReactRouter.url) => { ~eventName="Reset Password Changed Failure", ~eventProperties={"token": token, "error": text}, ) - Promise.resolved() + Promise.resolve() }) } setIsSubmitting(_ => false) - Promise.resolved() + Promise.resolve() }) })->ignore | None => setStatus(_ => Some(Error("Missing token"))) diff --git a/tests/syntax_tests/data/idempotency/nook-exchange/QuicklistOverlay.res b/tests/syntax_tests/data/idempotency/nook-exchange/QuicklistOverlay.res index 6d21fd7bee1..ce04c55a413 100644 --- a/tests/syntax_tests/data/idempotency/nook-exchange/QuicklistOverlay.res +++ b/tests/syntax_tests/data/idempotency/nook-exchange/QuicklistOverlay.res @@ -315,7 +315,7 @@ let make = () => { switch url.path { | list{"u", username, ..._} => switch me { - | Some(me) => me.username != username || Js.Dict.keys(me.items)->Js.Array.length >= 8 + | Some(me) => me.username != username || Dict.keysToArray(me.items)->Array.length >= 8 | None => true } | _ => false @@ -345,7 +345,7 @@ let make = () => { : switch quicklist { | Some(quicklist) => - let numItems = quicklist.itemIds->Js.Array.length + let numItems = quicklist.itemIds->Array.length let dropDownContents = criteria - ->Js.Array.filter(criterion => - Sortable.criterion(criterion) != Sortable.criterion(selectedCriterion) - ) + ->Array.filter(criterion => + Sortable.criterion(criterion) != Sortable.criterion(selectedCriterion)) ->Array.map(criterion =>
// https://github.com/rescript-lang/syntax/issues/113 -
{Js.log(a <= 10)}
-
{Js.log(a <= 10)}
-
Js.log(a <= 10) }>
{Js.log(a <= 10)}
+
{Console.log(a <= 10)}
+
{Console.log(a <= 10)}
+
Console.log(a <= 10) }>
{Console.log(a <= 10)}
module App = { @react.component diff --git a/tests/syntax_tests/data/printer/expr/let.res b/tests/syntax_tests/data/printer/expr/let.res index f687ec4522a..4b567ee3ed7 100644 --- a/tests/syntax_tests/data/printer/expr/let.res +++ b/tests/syntax_tests/data/printer/expr/let.res @@ -40,14 +40,14 @@ let highlight_dumb = (ppf, lb, loc) => { let f = x => { let a = x - ->Js.Dict.get("wm-received") - ->Option.flatMap(Js.Json.decodeString) - ->Option.map(Js.Date.fromString) + ->Dict.get("wm-received") + ->Option.flatMap(JSON.decodeString) + ->Option.map(Date.fromString) let b = x - ->Js.Dict.get("wm-property") - ->Option.flatMap(Js.Json.decodeString) + ->Dict.get("wm-property") + ->Option.flatMap(JSON.decodeString) ->Option.flatMap(x => switch x { | "like-of" => Some(#like) diff --git a/tests/syntax_tests/data/printer/expr/polyvariant.res b/tests/syntax_tests/data/printer/expr/polyvariant.res index 1d395058298..cfaa6091bb9 100644 --- a/tests/syntax_tests/data/printer/expr/polyvariant.res +++ b/tests/syntax_tests/data/printer/expr/polyvariant.res @@ -86,8 +86,8 @@ let math = if discriminant < 0. { #None } else { #Some(( - (-.b -. Js.Math.sqrt(discriminant)) /. (2. *. a), - (-.b +. Js.Math.sqrt(discriminant)) /. (2. *. a), + (-.b -. Math.sqrt(discriminant)) /. (2. *. a), + (-.b +. Math.sqrt(discriminant)) /. (2. *. a), )) } diff --git a/tests/syntax_tests/data/printer/expr/smartPipe.res b/tests/syntax_tests/data/printer/expr/smartPipe.res index 2bc8183937b..07172da0c2a 100644 --- a/tests/syntax_tests/data/printer/expr/smartPipe.res +++ b/tests/syntax_tests/data/printer/expr/smartPipe.res @@ -12,13 +12,13 @@ let myFunc = (strA, strB) => strA ++ strB ->myFunc("expr3")->myFunc("expr4") myPromise->Promise.then(v => { - Js.log(v) + Console.log(v) Promise.resolve(v) }) myPromise ->Promise.then(v => { - Js.log(v) + Console.log(v) Promise.resolve(v) }) diff --git a/tests/syntax_tests/data/printer/expr/switch.res b/tests/syntax_tests/data/printer/expr/switch.res index 107a9e6d4c4..0313cab633e 100644 --- a/tests/syntax_tests/data/printer/expr/switch.res +++ b/tests/syntax_tests/data/printer/expr/switch.res @@ -35,7 +35,7 @@ switch count { // Block | 6 => { let _ = 123 - Js.Console.log("Must be block") + Console.log("Must be block") } } diff --git a/tests/syntax_tests/data/printer/expr/templateLiteral.res b/tests/syntax_tests/data/printer/expr/templateLiteral.res index d5089f8b880..b4c8eeed673 100644 --- a/tests/syntax_tests/data/printer/expr/templateLiteral.res +++ b/tests/syntax_tests/data/printer/expr/templateLiteral.res @@ -56,10 +56,10 @@ let s = `${(s: string)}` `my ${language.name} is ` ++ `Bond, ${jamesbond.firstName}.` `my ${language.name} is ` ++ `${jamesbond.lastName}. James Bond.` -(`my ${language.name} is ` ++ `Bond, ${jamesbond.firstName}.`)->Js.log -(`my ${name} is ` ++ `Bond`)->Js.log +(`my ${language.name} is ` ++ `Bond, ${jamesbond.firstName}.`)->Console.log +(`my ${name} is ` ++ `Bond`)->Console.log `my ${kitchen.quality} kitched` ++ ` is ${language.big} ` ++ ` of the ${kitchen.things}.` -json`null`->Js.log +json`null`->Console.log a ++ ` x ` ++ b a ++ (` x ` ++ b) diff --git a/tests/syntax_tests/data/printer/expr/try.res b/tests/syntax_tests/data/printer/expr/try.res index 0eb82572a3a..710882a5cb3 100644 --- a/tests/syntax_tests/data/printer/expr/try.res +++ b/tests/syntax_tests/data/printer/expr/try.res @@ -3,12 +3,12 @@ try { let y = 2 dangerousCall() } catch { -| Foo => Js.log() -| Exit => Js.log() +| Foo => Console.log() +| Exit => Console.log() } try myDangerousFn() catch { -| Foo => Js.log() +| Foo => Console.log() } let x = { @@ -22,12 +22,12 @@ let x = { @attr @attr2 try myDangerousFn() catch { -| Foo => Js.log() +| Foo => Console.log() } let () = @attr @attr2 try myDangerousFn() catch { - | Foo => Js.log() + | Foo => Console.log() } diff --git a/tests/syntax_tests/data/printer/ffi/expected/export.res.txt b/tests/syntax_tests/data/printer/ffi/expected/export.res.txt index 4066aa0d8cb..42775debc75 100644 --- a/tests/syntax_tests/data/printer/ffi/expected/export.res.txt +++ b/tests/syntax_tests/data/printer/ffi/expected/export.res.txt @@ -28,7 +28,7 @@ 4 │ export type t = int and s = string 5 │ type t = int and export s = string 6 │ - 7 │ export let callback = _ => Js.log("Clicked") + 7 │ export let callback = _ => Console.log("Clicked") consecutive statements on a line must be separated by ';' or a newline @@ -36,7 +36,7 @@ Syntax error! tests/printer/ffi/export.res:10:40-41 - 8 │ export callback = _ => Js.log("Clicked") + 8 │ export callback = _ => Console.log("Clicked") 9 │ 10 │ export let x = "hello world" and export y = 2 11 │ export x = "hello world" and export y = 2 diff --git a/tests/syntax_tests/data/printer/other/expected/fatSlider.res.txt b/tests/syntax_tests/data/printer/other/expected/fatSlider.res.txt index 6e065f0ac47..62bf5b7504f 100644 --- a/tests/syntax_tests/data/printer/other/expected/fatSlider.res.txt +++ b/tests/syntax_tests/data/printer/other/expected/fatSlider.res.txt @@ -50,7 +50,7 @@ let make = (~min=50, ~max=250, ~meterSuffix=?) => { />
- {values[0]->Js.Int.toString->string} + {values[0]->Int.toString->string} {meterSuffix->Belt.Option.getWithDefault(null)}
diff --git a/tests/syntax_tests/data/printer/other/expected/nesting.res.txt b/tests/syntax_tests/data/printer/other/expected/nesting.res.txt index 0cafca836cf..5a1fa837942 100644 --- a/tests/syntax_tests/data/printer/other/expected/nesting.res.txt +++ b/tests/syntax_tests/data/printer/other/expected/nesting.res.txt @@ -1,15 +1,15 @@ -let unitsCommands = state.units->Js.Array2.mapi(( +let unitsCommands = state.units->Array.mapWithIndex(( {unit: targetUnit, coordinates: targetCoordinates}, i, ) => { // n^2 let res = [] - state.units->Js.Array2.forEachi(( + state.units->Array.forEachWithIndex(( {unit: unitThatMightBeAttacking, coordinates: unitThatMightBeAttackingCoordinates}, j, ) => { if i !== j { - switch Js.Array2.unsafe_get( + switch Array.getUnsafe( unitThatMightBeAttacking.timeline, unitThatMightBeAttacking.currentFrame, ).effect { @@ -41,9 +41,9 @@ let unitsCommands = state.units->Js.Array2.mapi(( ), coordinates: {x: sparksX, y: sparksY, z: 0.}, } - particlesToAdd->Js.Array2.push(spark)->ignore + particlesToAdd->Array.push(spark)->ignore - res->Js.Array2.push(Unit.CommandAttacked({damage: damage}))->ignore + res->Array.push(Unit.CommandAttacked({damage: damage}))->ignore } | _ => () } diff --git a/tests/syntax_tests/data/printer/other/expected/reasonFile.res.txt b/tests/syntax_tests/data/printer/other/expected/reasonFile.res.txt index 578b0289e84..ea9cf100847 100644 --- a/tests/syntax_tests/data/printer/other/expected/reasonFile.res.txt +++ b/tests/syntax_tests/data/printer/other/expected/reasonFile.res.txt @@ -1,5 +1,5 @@ /* parses reason file */ let () = { let msg = "test" - msg->Js.log + msg->Console.log } diff --git a/tests/syntax_tests/data/printer/other/fatSlider.res b/tests/syntax_tests/data/printer/other/fatSlider.res index 8e7fb24d3c7..119ff32e77d 100644 --- a/tests/syntax_tests/data/printer/other/fatSlider.res +++ b/tests/syntax_tests/data/printer/other/fatSlider.res @@ -50,7 +50,7 @@ let make = (~min=50, ~max=250, ~meterSuffix=?) => { />
- {values[0]->Js.Int.toString->string} {meterSuffix->Belt.Option.getWithDefault(null)} + {values[0]->Int.toString->string} {meterSuffix->Belt.Option.getWithDefault(null)}
} diff --git a/tests/syntax_tests/data/printer/other/nesting.res b/tests/syntax_tests/data/printer/other/nesting.res index 70b0798d5ef..adb1bdf2680 100644 --- a/tests/syntax_tests/data/printer/other/nesting.res +++ b/tests/syntax_tests/data/printer/other/nesting.res @@ -1,18 +1,15 @@ -let unitsCommands = state.units->Js.Array2.mapi(({ +let unitsCommands = state.units->Array.mapWithIndex(({ unit: targetUnit, coordinates: targetCoordinates, }, i) => { // n^2 let res = [] - state.units->Js.Array2.forEachi(({ + state.units->Array.forEachWithIndex(({ unit: unitThatMightBeAttacking, coordinates: unitThatMightBeAttackingCoordinates, }, j) => { if i !== j { - switch Js.Array2.unsafe_get( - unitThatMightBeAttacking.timeline, - unitThatMightBeAttacking.currentFrame, - ).effect { + switch Array.getUnsafe(unitThatMightBeAttacking.timeline, unitThatMightBeAttacking.currentFrame).effect { | Some(UnitAttack({damage, hitBox: _})) => let unitThatMightBeAttackingHitBox_ = Unit.hitBox(unitThatMightBeAttacking) let unitThatMightBeAttackingHitBox = { @@ -41,9 +38,9 @@ let unitsCommands = state.units->Js.Array2.mapi(({ ), coordinates: {x: sparksX, y: sparksY, z: 0.}, } - particlesToAdd->Js.Array2.push(spark)->ignore + particlesToAdd->Array.push(spark)->ignore - res->Js.Array2.push(Unit.CommandAttacked({damage: damage}))->ignore + res->Array.push(Unit.CommandAttacked({damage: damage}))->ignore } | _ => () } diff --git a/tests/syntax_tests/data/printer/other/reasonFile.res b/tests/syntax_tests/data/printer/other/reasonFile.res index 578b0289e84..ea9cf100847 100644 --- a/tests/syntax_tests/data/printer/other/reasonFile.res +++ b/tests/syntax_tests/data/printer/other/reasonFile.res @@ -1,5 +1,5 @@ /* parses reason file */ let () = { let msg = "test" - msg->Js.log + msg->Console.log } diff --git a/tests/syntax_tests/data/printer/pattern/construct.res b/tests/syntax_tests/data/printer/pattern/construct.res index f2f86f77a73..671b79dea58 100644 --- a/tests/syntax_tests/data/printer/pattern/construct.res +++ b/tests/syntax_tests/data/printer/pattern/construct.res @@ -11,8 +11,8 @@ let Rgb(rrrrrrrrrrrrrrrrrrrrrrrrr, ggggggggggggggggggggggggg, bbbbbbbbbbbbbbbbbb let Units((), (), ()) = 1 switch truth { -| true => Js.log("true") -| false => Js.log("false") +| true => Console.log("true") +| false => Console.log("false") } switch sphere->intersect(~ray) { diff --git a/tests/syntax_tests/data/printer/pattern/dict.res b/tests/syntax_tests/data/printer/pattern/dict.res index 7bd4ee0bf52..7b41b9e0250 100644 --- a/tests/syntax_tests/data/printer/pattern/dict.res +++ b/tests/syntax_tests/data/printer/pattern/dict.res @@ -13,8 +13,8 @@ let foo = () => { // Comment right in the pattern "one", } => - Js.log("one") - | _ => Js.log("not one") + Console.log("one") + | _ => Console.log("not one") } let _ = switch someDict { @@ -28,8 +28,8 @@ let foo = () => { "fooooour": 4, "fiiiive": 5, } => - Js.log("one") - | _ => Js.log("not one") + Console.log("one") + | _ => Console.log("not one") } let _ = switch someDict { @@ -43,7 +43,7 @@ let foo = () => { "fooooour": 4, "fiiiive": 5, } => - Js.log("one") - | _ => Js.log("not one") + Console.log("one") + | _ => Console.log("not one") } } diff --git a/tests/syntax_tests/data/printer/pattern/expected/construct.res.txt b/tests/syntax_tests/data/printer/pattern/expected/construct.res.txt index d464746d974..261d2cc30fb 100644 --- a/tests/syntax_tests/data/printer/pattern/expected/construct.res.txt +++ b/tests/syntax_tests/data/printer/pattern/expected/construct.res.txt @@ -11,8 +11,8 @@ let Rgb(rrrrrrrrrrrrrrrrrrrrrrrrr, ggggggggggggggggggggggggg, bbbbbbbbbbbbbbbbbb let Units((), (), ()) = 1 switch truth { -| true => Js.log("true") -| false => Js.log("false") +| true => Console.log("true") +| false => Console.log("false") } switch sphere->intersect(~ray) { diff --git a/tests/syntax_tests/data/printer/pattern/expected/dict.res.txt b/tests/syntax_tests/data/printer/pattern/expected/dict.res.txt index 7bd4ee0bf52..7b41b9e0250 100644 --- a/tests/syntax_tests/data/printer/pattern/expected/dict.res.txt +++ b/tests/syntax_tests/data/printer/pattern/expected/dict.res.txt @@ -13,8 +13,8 @@ let foo = () => { // Comment right in the pattern "one", } => - Js.log("one") - | _ => Js.log("not one") + Console.log("one") + | _ => Console.log("not one") } let _ = switch someDict { @@ -28,8 +28,8 @@ let foo = () => { "fooooour": 4, "fiiiive": 5, } => - Js.log("one") - | _ => Js.log("not one") + Console.log("one") + | _ => Console.log("not one") } let _ = switch someDict { @@ -43,7 +43,7 @@ let foo = () => { "fooooour": 4, "fiiiive": 5, } => - Js.log("one") - | _ => Js.log("not one") + Console.log("one") + | _ => Console.log("not one") } } diff --git a/tests/syntax_tests/data/printer/pattern/expected/variant.res.txt b/tests/syntax_tests/data/printer/pattern/expected/variant.res.txt index 1f45a8182db..cc471adf5b1 100644 --- a/tests/syntax_tests/data/printer/pattern/expected/variant.res.txt +++ b/tests/syntax_tests/data/printer/pattern/expected/variant.res.txt @@ -40,7 +40,7 @@ switch x { switch numericPolyVar { | #42 => () -| #3(x, y, z) => Js.log3(x, y, z) +| #3(x, y, z) => Console.log3(x, y, z) } let e = #"" diff --git a/tests/syntax_tests/data/printer/pattern/variant.res b/tests/syntax_tests/data/printer/pattern/variant.res index 08e54f36564..a76d2904afd 100644 --- a/tests/syntax_tests/data/printer/pattern/variant.res +++ b/tests/syntax_tests/data/printer/pattern/variant.res @@ -40,7 +40,7 @@ switch x { switch numericPolyVar { | #42 => () -| #3(x, y, z) => Js.log3(x, y, z) +| #3(x, y, z) => Console.log3(x, y, z) } let e = #"" \ No newline at end of file diff --git a/tests/syntax_tests/data/printer/structure/expected/include.res.txt b/tests/syntax_tests/data/printer/structure/expected/include.res.txt index ea087838eab..3e013044097 100644 --- a/tests/syntax_tests/data/printer/structure/expected/include.res.txt +++ b/tests/syntax_tests/data/printer/structure/expected/include.res.txt @@ -12,8 +12,8 @@ include ( external apply: ('theFunction, 'theContext, 'arguments) => 'returnTypeOfTheFunction = "apply" let createElementVariadic = (domClassName, ~props=?, children) => { - let variadicArguments = [Obj.magic(domClassName), Obj.magic(props)]->Js.Array.concat(children) - createElementInternalHack->apply(Js.Nullable.null, variadicArguments) + let variadicArguments = [Obj.magic(domClassName), Obj.magic(props)]->Array.concat(children) + createElementInternalHack->apply(Nullable.null, variadicArguments) } }: { let createElementVariadic: (string, ~props: props=?, array) => React.element diff --git a/tests/syntax_tests/data/printer/structure/expected/moduleBinding.res.txt b/tests/syntax_tests/data/printer/structure/expected/moduleBinding.res.txt index 54150c35f64..d23a0b8f478 100644 --- a/tests/syntax_tests/data/printer/structure/expected/moduleBinding.res.txt +++ b/tests/syntax_tests/data/printer/structure/expected/moduleBinding.res.txt @@ -1,7 +1,7 @@ module React = { type t - let render = () => Js.log("foo") + let render = () => Console.log("foo") } module Make: () => S = (_: Config, ()) => {} diff --git a/tests/syntax_tests/data/printer/structure/include.res b/tests/syntax_tests/data/printer/structure/include.res index 53b8e05e7c3..c375b752b48 100644 --- a/tests/syntax_tests/data/printer/structure/include.res +++ b/tests/syntax_tests/data/printer/structure/include.res @@ -17,8 +17,8 @@ include ( let createElementVariadic = (domClassName, ~props=?, children) => { let variadicArguments = - [Obj.magic(domClassName), Obj.magic(props)]->Js.Array.concat(children) - createElementInternalHack->apply(Js.Nullable.null, variadicArguments) + [Obj.magic(domClassName), Obj.magic(props)]->Array.concat(children) + createElementInternalHack->apply(Nullable.null, variadicArguments) } }: { let createElementVariadic: ( diff --git a/tests/syntax_tests/data/printer/structure/moduleBinding.res b/tests/syntax_tests/data/printer/structure/moduleBinding.res index 2d92d89b92f..3613f5ce995 100644 --- a/tests/syntax_tests/data/printer/structure/moduleBinding.res +++ b/tests/syntax_tests/data/printer/structure/moduleBinding.res @@ -1,7 +1,7 @@ module React = { type t - let render = () => Js.log("foo") + let render = () => Console.log("foo") } module Make: () => S = (Config, ()) => {} diff --git a/tests/syntax_tests/data/printer/typexpr/arrow.res b/tests/syntax_tests/data/printer/typexpr/arrow.res index 8959b19ec62..f774f795500 100644 --- a/tests/syntax_tests/data/printer/typexpr/arrow.res +++ b/tests/syntax_tests/data/printer/typexpr/arrow.res @@ -103,8 +103,8 @@ let prepare_expansion: ((type_expr, type_expr)) => (type_expr, type_expr) = f type getInitialPropsFn<'a> = { "query": dict, - "req": Js.Nullable.t>, -} => Js.Promise.t> + "req": nullable<{..}>, +} => Promise.t<{..}> // keep parens external fromPoly: ([> ] as 'a) => t = "%identity" diff --git a/tests/syntax_tests/data/printer/typexpr/expected/arrow.res.txt b/tests/syntax_tests/data/printer/typexpr/expected/arrow.res.txt index 65f2550ff02..9708f5202fd 100644 --- a/tests/syntax_tests/data/printer/typexpr/expected/arrow.res.txt +++ b/tests/syntax_tests/data/printer/typexpr/expected/arrow.res.txt @@ -216,10 +216,7 @@ type arrows = (int, (float => unit) => unit, float) => unit // tuple as single parameter let prepare_expansion: ((type_expr, type_expr)) => (type_expr, type_expr) = f -type getInitialPropsFn<'a> = { - "query": dict, - "req": Js.Nullable.t>, -} => Js.Promise.t> +type getInitialPropsFn<'a> = {"query": dict, "req": nullable<{..}>} => Promise.t<{..}> // keep parens external fromPoly: ([> ] as 'a) => t = "%identity" diff --git a/tests/syntax_tests/data/printer/typexpr/expected/objectTypeSpreading.res.txt b/tests/syntax_tests/data/printer/typexpr/expected/objectTypeSpreading.res.txt index 81446937c17..3531336594e 100644 --- a/tests/syntax_tests/data/printer/typexpr/expected/objectTypeSpreading.res.txt +++ b/tests/syntax_tests/data/printer/typexpr/expected/objectTypeSpreading.res.txt @@ -14,10 +14,10 @@ let steve: {...user, "age": int} = {"name": "Steve", "age": 30} let steve = ({"name": "Steve", "age": 30}: {...user, "age": int}) let steve = {({"name": "Steve", "age": 30}: {...user, "age": int})} -let printFullUser = (steve: {...user, "age": int}) => Js.log(steve) -let printFullUser = (~user: {...user, "age": int}) => Js.log(steve) -let printFullUser = (~user: {...user, "age": int}) => Js.log(steve) -let printFullUser = (~user=steve: {...user, "age": int}) => Js.log(steve) +let printFullUser = (steve: {...user, "age": int}) => Console.log(steve) +let printFullUser = (~user: {...user, "age": int}) => Console.log(steve) +let printFullUser = (~user: {...user, "age": int}) => Console.log(steve) +let printFullUser = (~user=steve: {...user, "age": int}) => Console.log(steve) @val external steve: {...user, "age": int} = "steve" diff --git a/tests/syntax_tests/data/printer/typexpr/expected/typeConstr.res.txt b/tests/syntax_tests/data/printer/typexpr/expected/typeConstr.res.txt index e10deda863e..c4ee5cb61b5 100644 --- a/tests/syntax_tests/data/printer/typexpr/expected/typeConstr.res.txt +++ b/tests/syntax_tests/data/printer/typexpr/expected/typeConstr.res.txt @@ -79,6 +79,6 @@ let t: @attrs list<{"age": int}> = x external color: @attr colour<'t> = "c_color" @send @return(nullable) -external getAttribute: (Js.t<'a>, string) => option = "getAttribute" +external getAttribute: ({..}, string) => option = "getAttribute" -let dangerousHtml: string => Js.t<'a> = html => {"__html": html} +let dangerousHtml: string => {..} = html => {"__html": html} diff --git a/tests/syntax_tests/data/printer/typexpr/expected/variant.res.txt b/tests/syntax_tests/data/printer/typexpr/expected/variant.res.txt index e9594f4b881..4837afcf085 100644 --- a/tests/syntax_tests/data/printer/typexpr/expected/variant.res.txt +++ b/tests/syntax_tests/data/printer/typexpr/expected/variant.res.txt @@ -36,7 +36,7 @@ external make: ( | #stepBefore | #stepAfter ]=?, - ~dataKey: Config.dataItem => Js.null, + ~dataKey: Config.dataItem => null, ~stroke: string=?, ~strokeWidth: float=?, ~strokeDasharray: string=?, diff --git a/tests/syntax_tests/data/printer/typexpr/objectTypeSpreading.res b/tests/syntax_tests/data/printer/typexpr/objectTypeSpreading.res index 8e2d2e05b12..c6d08071900 100644 --- a/tests/syntax_tests/data/printer/typexpr/objectTypeSpreading.res +++ b/tests/syntax_tests/data/printer/typexpr/objectTypeSpreading.res @@ -15,10 +15,10 @@ let steve: {...user, "age": int} = {"name": "Steve", "age": 30} let steve = ({"name": "Steve", "age": 30}: {...user, "age": int}) let steve = {({"name": "Steve", "age": 30}: {...user, "age": int})} -let printFullUser = (steve: {...user, "age": int}) => Js.log(steve) -let printFullUser = (~user: {...user, "age": int}) => Js.log(steve) -let printFullUser = (~user: {...user, "age": int}) => Js.log(steve) -let printFullUser = (~user = steve : {...user, "age": int}) => Js.log(steve) +let printFullUser = (steve: {...user, "age": int}) => Console.log(steve) +let printFullUser = (~user: {...user, "age": int}) => Console.log(steve) +let printFullUser = (~user: {...user, "age": int}) => Console.log(steve) +let printFullUser = (~user = steve : {...user, "age": int}) => Console.log(steve) @val external steve: {...user, "age": int} = "steve" diff --git a/tests/syntax_tests/data/printer/typexpr/typeConstr.res b/tests/syntax_tests/data/printer/typexpr/typeConstr.res index 224df6e40af..540943b07e9 100644 --- a/tests/syntax_tests/data/printer/typexpr/typeConstr.res +++ b/tests/syntax_tests/data/printer/typexpr/typeConstr.res @@ -27,6 +27,6 @@ let t: @attrs list<{"age": int}> = x external color : @attr colour<'t> = "c_color" @send @return(nullable) -external getAttribute: (Js.t<'a>, string) => option = "getAttribute" +external getAttribute: ({..}, string) => option = "getAttribute" -let dangerousHtml: string => Js.t<'a> = html => {"__html": html} +let dangerousHtml: string => {..} = html => {"__html": html} diff --git a/tests/syntax_tests/data/printer/typexpr/variant.res b/tests/syntax_tests/data/printer/typexpr/variant.res index 7368ce89c21..913bdfd732e 100644 --- a/tests/syntax_tests/data/printer/typexpr/variant.res +++ b/tests/syntax_tests/data/printer/typexpr/variant.res @@ -36,7 +36,7 @@ external make: ( | #stepBefore | #stepAfter ]=?, - ~dataKey: Config.dataItem => Js.null, + ~dataKey: Config.dataItem => null, ~stroke: string=?, ~strokeWidth: float=?, ~strokeDasharray: string=?, diff --git a/tests/syntax_tests/res_test.ml b/tests/syntax_tests/res_test.ml index 699dd5fbca3..47810416ede 100644 --- a/tests/syntax_tests/res_test.ml +++ b/tests/syntax_tests/res_test.ml @@ -11,9 +11,9 @@ let () = = {|// test file if true { - Js.log("true") + Console.log("true") } else { - Js.log("false") + Console.log("false") } |}) diff --git a/tests/tests/src/DictInference.mjs b/tests/tests/src/DictInference.mjs index 736a58c63e7..0fa525f939f 100644 --- a/tests/tests/src/DictInference.mjs +++ b/tests/tests/src/DictInference.mjs @@ -1,6 +1,5 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Js_dict from "@rescript/runtime/lib/es6/Js_dict.mjs"; let dict = {}; @@ -8,7 +7,7 @@ dict["someKey1"] = 1; dict["someKey2"] = 2; -let asArray = Js_dict.values(dict); +let asArray = Object.values(dict); export { dict, diff --git a/tests/tests/src/DictInference.res b/tests/tests/src/DictInference.res index a267ae2e6ef..01d86fa042d 100644 --- a/tests/tests/src/DictInference.res +++ b/tests/tests/src/DictInference.res @@ -1,6 +1,6 @@ -let dict = Js.Dict.empty() -dict->Js.Dict.set("someKey1", 1) -dict->Js.Dict.set("someKey2", 2) -let asArray = dict->Js.Dict.values +let dict = Dict.make() +dict->Dict.set("someKey1", 1) +dict->Dict.set("someKey2", 2) +let asArray = dict->Dict.valuesToArray let _: dict = dict diff --git a/tests/tests/src/Import.mjs b/tests/tests/src/Import.mjs index dc80cfb686a..9107520fe8f 100644 --- a/tests/tests/src/Import.mjs +++ b/tests/tests/src/Import.mjs @@ -1,13 +1,12 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Js_promise from "@rescript/runtime/lib/es6/Js_promise.mjs"; async function eachIntAsync(list, f) { return (await import("@rescript/runtime/lib/es6/Belt_List.mjs").then(m => m.forEach))(list, f); } function eachIntLazy(list, f) { - return Js_promise.then_(each => Promise.resolve(each(list, f)), import("@rescript/runtime/lib/es6/Belt_List.mjs").then(m => m.forEach)); + return import("@rescript/runtime/lib/es6/Belt_List.mjs").then(m => m.forEach).then(each => Promise.resolve(each(list, f))); } eachIntLazy({ diff --git a/tests/tests/src/Import.res b/tests/tests/src/Import.res index 78b17e4c49b..d3ec0107235 100644 --- a/tests/tests/src/Import.res +++ b/tests/tests/src/Import.res @@ -1,18 +1,18 @@ let eachIntAsync = async (list: list, f: int => unit) => { - list->(await Js.import(Belt.List.forEach))(f) + list->(await import(Belt.List.forEach))(f) } let eachIntLazy = (list: list, f: int => unit) => - Js.Promise.then_(each => list->each(f)->Js.Promise.resolve, Js.import(Belt.List.forEach)) + Promise.then(import(Belt.List.forEach), each => list->each(f)->Promise.resolve) let _ = list{1, 2, 3}->eachIntLazy(n => Console.log2("lazy", n)) let _ = list{1, 2, 3}->eachIntAsync(n => Console.log2("async", n)) module type BeltList = module type of Belt.List -let beltAsModule = await Js.import(module(Belt.List: BeltList)) +let beltAsModule = await import(module(Belt.List: BeltList)) // module type BeltList0 = module type of Belt.List -// module M = unpack(@res.await Js.import(module(Belt.List: BeltList0))) +// module M = unpack(@res.await import(module(Belt.List: BeltList0))) module M = await Belt.List let each = M.forEach diff --git a/tests/tests/src/ImportAttributes.res b/tests/tests/src/ImportAttributes.res index e5619ba3865..c9ddcc8ded6 100644 --- a/tests/tests/src/ImportAttributes.res +++ b/tests/tests/src/ImportAttributes.res @@ -1,5 +1,5 @@ @module({from: "./myJson.json", with: {type_: "json", \"some-identifier": "yep"}}) -external myJson: Js.Json.t = "default" +external myJson: JSON.t = "default" Console.log(myJson) diff --git a/tests/tests/src/SafePromises.mjs b/tests/tests/src/SafePromises.mjs index 50bcd5bad00..879adff567a 100644 --- a/tests/tests/src/SafePromises.mjs +++ b/tests/tests/src/SafePromises.mjs @@ -1,16 +1,15 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Js_promise from "@rescript/runtime/lib/es6/Js_promise.mjs"; -import * as Js_promise2 from "@rescript/runtime/lib/es6/Js_promise2.mjs"; +import * as Stdlib_Promise from "@rescript/runtime/lib/es6/Stdlib_Promise.mjs"; async function nestedPromise(xxx) { let xx = await xxx; - Js_promise2.then(xx, x => Promise.resolve((console.log("Promise2.then", x), undefined))); - Js_promise2.$$catch(xx, x => { + xx.then(x => Promise.resolve((console.log("Promise2.then", x), undefined))); + Stdlib_Promise.$$catch(xx, x => { console.log("Promise2.catch_", x); return Promise.resolve(0); }); - Js_promise.then_(x => Promise.resolve((console.log("Promise.then_", x), undefined)), xx); + xx.then(x => Promise.resolve((console.log("Promise.then_", x), undefined))); } async function create(x) { diff --git a/tests/tests/src/SafePromises.res b/tests/tests/src/SafePromises.res index 8de4bcf0678..f1a7f6d12bd 100644 --- a/tests/tests/src/SafePromises.res +++ b/tests/tests/src/SafePromises.res @@ -1,16 +1,16 @@ -/*** Problematic example of nested promises is safe with Js.Promise2 */ +/*** Problematic example of nested promises is safe with the current Promise API. */ let nestedPromise = async (xxx: promise>) => { let xx = await xxx - let _ = xx->Js.Promise2.then(x => Js.Promise.resolve(Console.log2("Promise2.then", x))) - let _ = xx->Js.Promise2.catch(x => { + let _ = xx->Promise.then(x => Promise.resolve(Console.log2("Promise2.then", x))) + let _ = xx->Promise.catch(x => { Console.log2("Promise2.catch_", x) - Js.Promise.resolve(0) + Promise.resolve(0) }) // This crashes - let _ = Js.Promise.then_(x => Js.Promise.resolve(Console.log2("Promise.then_", x)), xx) + let _ = Promise.then(xx, x => Promise.resolve(Console.log2("Promise.then_", x))) } let create = async x => { diff --git a/tests/tests/src/UncurriedAlways.res b/tests/tests/src/UncurriedAlways.res index 68be69c634c..6cb10876759 100644 --- a/tests/tests/src/UncurriedAlways.res +++ b/tests/tests/src/UncurriedAlways.res @@ -14,7 +14,7 @@ let a = 3->foo(4) Console.log(a) // Test automatic uncurried application -let _ = Js.Array2.map([1], x => x + 1) +let _ = Array.map([1], x => x + 1) let ptl = foo(10, ...) // force partial application diff --git a/tests/tests/src/UntaggedVariants.mjs b/tests/tests/src/UntaggedVariants.mjs index b57405ea26e..ade41daad7f 100644 --- a/tests/tests/src/UntaggedVariants.mjs +++ b/tests/tests/src/UntaggedVariants.mjs @@ -1,6 +1,5 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Js_dict from "@rescript/runtime/lib/es6/Js_dict.mjs"; import * as Belt_Array from "@rescript/runtime/lib/es6/Belt_Array.mjs"; import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.mjs"; @@ -606,7 +605,7 @@ let AllInstanceofTypes = { function test(t) { switch (typeof t) { case "object" : - return Js_dict.get(t, "Hello"); + return t["Hello"]; case "string" : return t; case "function" : diff --git a/tests/tests/src/UntaggedVariants.res b/tests/tests/src/UntaggedVariants.res index 9ec7aa0d92c..822b0b0ce4f 100644 --- a/tests/tests/src/UntaggedVariants.res +++ b/tests/tests/src/UntaggedVariants.res @@ -167,7 +167,7 @@ module Json = { /* from js_json.ml let classify (x : t) : tagged_t = - let ty = Js.typeof x in + let ty = typeof x in if ty = "string" then JSONString (Obj.magic x) else if ty = "number" then @@ -175,9 +175,9 @@ let classify (x : t) : tagged_t = else if ty = "boolean" then if (Obj.magic x) = true then JSONTrue else JSONFalse - else if (Obj.magic x) == Js.null then + else if (Obj.magic x) == Null.null then JSONNull - else if Js_array2.isArray x then + else if Array.isArray x then JSONArray (Obj.magic x) else JSONObject (Obj.magic x) @@ -387,8 +387,8 @@ module Arr = { module AllInstanceofTypes = { type record = {userName: string} - @get external fileName: Js.File.t => string = "name" - @get external blobSize: Js.Blob.t => float = "size" + @get external fileName: File.t => string = "name" + @get external blobSize: Blob.t => float = "size" @unboxed type t = @@ -396,10 +396,10 @@ module AllInstanceofTypes = { | Array(array) | Promise(promise) | Object(record) - | Date(Js.Date.t) + | Date(Date.t) | RegExp(Stdlib_RegExp.t) - | File(Js.File.t) - | Blob(Js.Blob.t) + | File(File.t) + | Blob(Blob.t) | ArrayBuffer(ArrayBuffer.t) | Int8Array(Int8Array.t) | Int16Array(Int16Array.t) @@ -423,8 +423,8 @@ module AllInstanceofTypes = { | String(s) => Console.log(s) | Promise(p) => Console.log(await p) | Object({userName}) => Console.log(userName) - | Date(date) => Console.log(date->Js.Date.toString) - | RegExp(re) => Console.log(re->Js.Re.test_("test")) + | Date(date) => Console.log(date->Date.toString) + | RegExp(re) => Console.log(re->RegExp.test("test")) | Array(arr) => Console.log(arr->Belt.Array.joinWith("-", x => x)) | File(file) => Console.log(file->fileName) | Blob(blob) => Console.log(blob->blobSize) @@ -449,13 +449,13 @@ module AllInstanceofTypes = { } module Aliased = { - type dict = dict + type dict = Dict.t type fn = unit => option @unboxed type t = Object(dict) | String(string) | Function(fn) let test = (t: t) => { switch t { - | Object(d) => d->Js.Dict.get("Hello") + | Object(d) => d->Dict.get("Hello") | String(s) => Some(s) | Function(fn) => fn() } @@ -475,7 +475,7 @@ module MergeCases = { | Boolean(bool) | Object(obj) | Array(array) - | Date(Js.Date.t) + | Date(Date.t) let should_not_merge = x => switch x { diff --git a/tests/tests/src/a_scope_bug.res b/tests/tests/src/a_scope_bug.res index 104242a6f6b..9a7faff9db3 100644 --- a/tests/tests/src/a_scope_bug.res +++ b/tests/tests/src/a_scope_bug.res @@ -7,7 +7,7 @@ let rec odd = z => { let even = even * even even + 4 + even } - a->Js.Int.toString->Console.log + a->Int.toString->Console.log even(32) } and even = y => odd(y) diff --git a/tests/tests/src/arith_syntax.res b/tests/tests/src/arith_syntax.res index 14be6752f1b..aab5b409bc1 100644 --- a/tests/tests/src/arith_syntax.res +++ b/tests/tests/src/arith_syntax.res @@ -15,7 +15,7 @@ type rec expression = let rec str = e => switch e { - | Numeral(f) => f->Js.Float.toString + | Numeral(f) => f->Float.toString | Plus(a, b) => str(a) ++ ("+" ++ str(b)) | Minus(a, b) => str(a) ++ ("-" ++ str(b)) | Times(a, b) => str(a) ++ ("*" ++ str(b)) diff --git a/tests/tests/src/array_subtle_test.mjs b/tests/tests/src/array_subtle_test.mjs index df0e6fb01b6..2297aa4aa05 100644 --- a/tests/tests/src/array_subtle_test.mjs +++ b/tests/tests/src/array_subtle_test.mjs @@ -60,7 +60,7 @@ Mocha.describe("Array_subtle_test", () => { 3, 3 ]; - Test_utils.eq("File \"array_subtle_test.res\", line 43, characters 7-14", 5, v.push(3)); + v.push(3); Test_utils.eq("File \"array_subtle_test.res\", line 44, characters 7-14", 5, v.length); Test_utils.eq("File \"array_subtle_test.res\", line 45, characters 7-14", 5, v.length); }); diff --git a/tests/tests/src/array_subtle_test.res b/tests/tests/src/array_subtle_test.res index a360ae18c32..92d6a9348bb 100644 --- a/tests/tests/src/array_subtle_test.res +++ b/tests/tests/src/array_subtle_test.res @@ -4,11 +4,11 @@ open Test_utils let v = [1, 2, 3, 3] let f = v => { - switch Js.Array2.pop(v) { + switch Array.pop(v) { | Some(x) => Console.log("hi") | None => Console.log("hi2") } - Console.log(ignore(Js.Array2.pop(v))) + Console.log(ignore(Array.pop(v))) } let fff = x => Array.length(x) >= 0 @@ -40,9 +40,9 @@ describe(__MODULE__, () => { test("array_push_test", () => { let v = [1, 2, 3, 3] - eq(__LOC__, 5, Js.Array2.push(v, 3)) + Array.push(v, 3) + eq(__LOC__, 5, Array.length(v)) eq(__LOC__, 5, Array.length(v)) - eq(__LOC__, 5, Js.Array2.length(v)) }) test("array_mutation_test", () => { @@ -54,10 +54,10 @@ describe(__MODULE__, () => { test("array_pop_test", () => { let v = [1, 2, 3, 3] - while Js.Array2.length(v) > 0 { - ignore(Js.Array2.pop(v)) + while Array.length(v) > 0 { + ignore(Array.pop(v)) } - eq(__LOC__, 0, Js.Array2.length(v)) + eq(__LOC__, 0, Array.length(v)) }) test("array_function_tests", () => { diff --git a/tests/tests/src/async_await.res b/tests/tests/src/async_await.res index 805857bcca7..6fdeba0d6a0 100644 --- a/tests/tests/src/async_await.res +++ b/tests/tests/src/async_await.res @@ -2,7 +2,7 @@ let next = n => n + 1 let useNext = async () => next(3) module type Impl = { - let get: string => Js.Promise.t + let get: string => Promise.t } module Make = (I: Impl) => { @@ -16,7 +16,7 @@ let toplevelAwait = await topFoo() let toplevelAwait2 = arr[await topFoo()] let f = async (type input, value: input) => { - await Js.Promise.resolve(1) + await Promise.resolve(1) } module type MT = module type of Belt.Option diff --git a/tests/tests/src/async_inline.res b/tests/tests/src/async_inline.res index e86bfd2fc04..cad17d4bf47 100644 --- a/tests/tests/src/async_inline.res +++ b/tests/tests/src/async_inline.res @@ -5,7 +5,7 @@ let inlined = willBeInlined() let wrapSomethingAsync: unit => unit = () => { let _ = ( async _ => { - let test = await Js.Promise.resolve("Test") + let test = await Promise.resolve("Test") Console.log(test) } )(777) @@ -16,7 +16,7 @@ external ignorePromise: promise<'a> => unit = "%identity" let wrapSomethingAsync2 = () => ( async () => { - let test = await Js.Promise.resolve("Test") + let test = await Promise.resolve("Test") Console.log(test) } )()->ignorePromise diff --git a/tests/tests/src/async_inside_loop.res b/tests/tests/src/async_inside_loop.res index c76bec311f3..fb12b9b6275 100644 --- a/tests/tests/src/async_inside_loop.res +++ b/tests/tests/src/async_inside_loop.res @@ -2,7 +2,7 @@ let topLevelAsyncFunction = async () => { for innerScopeVal in 0 to 3 { let asyncClosureAccessingScopedVal = async () => { Console.log2("Accessing scoped var inside loop", innerScopeVal) - await Js.Promise.resolve() + await Promise.resolve() } await asyncClosureAccessingScopedVal() diff --git a/tests/tests/src/belt_list_test.res b/tests/tests/src/belt_list_test.res index 64361e2725e..9f84baa3dfd 100644 --- a/tests/tests/src/belt_list_test.res +++ b/tests/tests/src/belt_list_test.res @@ -268,8 +268,8 @@ describe(__MODULE__, () => { eq(__LOC__, N.some(list{1, 2, 5}, mod2), true) eq(__LOC__, N.some(list{1, 3, 5}, mod2), false) eq(__LOC__, N.some(list{}, mod2), false) - eq(__LOC__, N.has(list{1, 2, 3}, "2", (x, s) => Js.Int.toString(x) == s), true) - eq(__LOC__, N.has(list{1, 2, 3}, "0", (x, s) => Js.Int.toString(x) == s), false) + eq(__LOC__, N.has(list{1, 2, 3}, "2", (x, s) => Int.toString(x) == s), true) + eq(__LOC__, N.has(list{1, 2, 3}, "0", (x, s) => Int.toString(x) == s), false) ok(__LOC__, N.reduceReverse(list{1, 2, 3, 4}, 0, \"+") == 10) ok(__LOC__, N.reduceReverse(list{1, 2, 3, 4}, 10, \"-") == 0) diff --git a/tests/tests/src/bigint_test.res b/tests/tests/src/bigint_test.res index cba42734282..b2a5c842989 100644 --- a/tests/tests/src/bigint_test.res +++ b/tests/tests/src/bigint_test.res @@ -15,11 +15,11 @@ let bigint_lessequal = (x: bigint, y) => x <= y let generic_lessequal = \"<=" let bigint_greaterequal = (x: bigint, y) => x >= y let generic_greaterequal = \">=" -let bigint_land = Js.BigInt.land -let bigint_lor = Js.BigInt.lor -let bigint_lxor = Js.BigInt.lxor -let bigint_lsl = Js.BigInt.lsl -let bigint_asr = Js.BigInt.asr +let bigint_land = BigInt.bitwiseAnd +let bigint_lor = BigInt.lor +let bigint_lxor = BigInt.lxor +let bigint_lsl = BigInt.lsl +let bigint_asr = BigInt.asr describe(__MODULE__, () => { test("bigint_test", () => { diff --git a/tests/tests/src/bs_abstract_test.res b/tests/tests/src/bs_abstract_test.res index 314ce3081da..9aa77684661 100644 --- a/tests/tests/src/bs_abstract_test.res +++ b/tests/tests/src/bs_abstract_test.res @@ -1,12 +1,12 @@ @deriving(abstract) type rec linked_list<'a> = { hd: 'a, - mutable tl: Js.null>, + mutable tl: null>, } -let v = linked_list(~hd=3, ~tl=Js.null) +let v = linked_list(~hd=3, ~tl=Null.null) -tlSet(v, Js.Null.return(v)) +tlSet(v, Null.make(v)) type rec t = (int, int) => bool @deriving(abstract) diff --git a/tests/tests/src/bs_abstract_test.resi b/tests/tests/src/bs_abstract_test.resi index 640523dd599..52eba47b712 100644 --- a/tests/tests/src/bs_abstract_test.resi +++ b/tests/tests/src/bs_abstract_test.resi @@ -1,7 +1,7 @@ @deriving(abstract) type rec linked_list<'a> = private { /* hd : 'a ; */ - tl: Js.null>, + tl: null>, } type rec t = (int, int) => bool diff --git a/tests/tests/src/bs_array_test.mjs b/tests/tests/src/bs_array_test.mjs index 82e1d933a3b..b0cdf6d1c4d 100644 --- a/tests/tests/src/bs_array_test.mjs +++ b/tests/tests/src/bs_array_test.mjs @@ -4,6 +4,7 @@ import * as Mocha from "mocha"; import * as Belt_List from "@rescript/runtime/lib/es6/Belt_List.mjs"; import * as Belt_Array from "@rescript/runtime/lib/es6/Belt_Array.mjs"; import * as Test_utils from "./test_utils.mjs"; +import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.mjs"; import * as Primitive_int from "@rescript/runtime/lib/es6/Primitive_int.mjs"; import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.mjs"; @@ -11,12 +12,12 @@ function push(prim0, prim1) { prim0.push(prim1); } -console.log([ +console.log(Stdlib_Array.reduce([ 1, 2, 3, 4 -].filter(x => x > 2).map((x, i) => x + i | 0).reduce((x, y) => x + y | 0, 0)); +].filter(x => x > 2).map((x, i) => x + i | 0), 0, (x, y) => x + y | 0)); Mocha.describe("Bs_array_test", () => { Mocha.test("bs_array_test_1", () => { diff --git a/tests/tests/src/bs_array_test.res b/tests/tests/src/bs_array_test.res index e2684b966c6..bb30e50ea95 100644 --- a/tests/tests/src/bs_array_test.res +++ b/tests/tests/src/bs_array_test.res @@ -6,12 +6,12 @@ module L = Belt.List let {push} = module(A) -type t<'a> = Js.Array2.t<'a> +type t<'a> = array<'a> let () = [1, 2, 3, 4] - ->Js.Array2.filter(x => x > 2) - ->Js.Array2.mapi((x, i) => x + i) - ->Js.Array2.reduce((x, y) => x + y, 0) + ->Array.filter(x => x > 2) + ->Array.mapWithIndex((x, i) => x + i) + ->Array.reduce(0, (x, y) => x + y) ->Console.log describe(__MODULE__, () => { diff --git a/tests/tests/src/bs_auto_uncurry.res b/tests/tests/src/bs_auto_uncurry.res index 507ca2d8dc6..673049bcf99 100644 --- a/tests/tests/src/bs_auto_uncurry.res +++ b/tests/tests/src/bs_auto_uncurry.res @@ -134,27 +134,6 @@ let f : expected = " we auto-uncurry so the inferred type would be */ -/* -let v = ref 0 - - - -(** -There is a semantics mismatch when converting curried function into uncurried function -for example -`let u = f a b c in u d ` may have a side effect here when creating [u]. -We should document it clearly -*) -let a4 = Js.Internal.js_fn_mk4 (fun x y z -> incr v ; fun d -> 1 + d) - - -let () = - ignore @@ a4 0 1 2 3 [@bs] - ignore @@ a4 0 1 2 3 [@bs] - -;; -*/ - let unit_magic = () => { Console.log("noinline") Console.log("noinline") diff --git a/tests/tests/src/bs_auto_uncurry_test.mjs b/tests/tests/src/bs_auto_uncurry_test.mjs index f808a556585..46ec8a4fd53 100644 --- a/tests/tests/src/bs_auto_uncurry_test.mjs +++ b/tests/tests/src/bs_auto_uncurry_test.mjs @@ -2,6 +2,7 @@ import * as Mocha from "mocha"; import * as Test_utils from "./test_utils.mjs"; +import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.mjs"; function hi (cb){ cb (); @@ -53,16 +54,16 @@ Mocha.describe("Bs_auto_uncurry_test", () => { 3, 4 ]); - Test_utils.eq("File \"bs_auto_uncurry_test.res\", line 26, characters 7-14", [ + Test_utils.eq("File \"bs_auto_uncurry_test.res\", line 26, characters 7-14", Stdlib_Array.reduce([ 1, 2, 3 - ].reduce((x, y) => x + y | 0, 0), 6); - Test_utils.eq("File \"bs_auto_uncurry_test.res\", line 27, characters 7-14", [ + ], 0, (x, y) => x + y | 0), 6); + Test_utils.eq("File \"bs_auto_uncurry_test.res\", line 27, characters 7-14", Stdlib_Array.reduceWithIndex([ 1, 2, 3 - ].reduce((x, y, i) => (x + y | 0) + i | 0, 0), 9); + ], 0, (x, y, i) => (x + y | 0) + i | 0), 9); Test_utils.eq("File \"bs_auto_uncurry_test.res\", line 28, characters 7-14", [ 1, 2, diff --git a/tests/tests/src/bs_auto_uncurry_test.res b/tests/tests/src/bs_auto_uncurry_test.res index 967768fe27d..4bb9cb1bc47 100644 --- a/tests/tests/src/bs_auto_uncurry_test.res +++ b/tests/tests/src/bs_auto_uncurry_test.res @@ -22,10 +22,10 @@ describe(__MODULE__, () => { test("array_operations_test", () => { eq(__LOC__, [1, 2, 3]->map(x => x + 1), [2, 3, 4]) - eq(__LOC__, [1, 2, 3]->Js.Array2.map(x => x + 1), [2, 3, 4]) - eq(__LOC__, [1, 2, 3]->Js.Array2.reduce((x, y) => x + y, 0), 6) - eq(__LOC__, [1, 2, 3]->Js.Array2.reducei((x, y, i) => x + y + i, 0), 9) - eq(__LOC__, [1, 2, 3]->Js.Array2.some(x => x < 1), false) - eq(__LOC__, [1, 2, 3]->Js.Array2.every(x => x > 0), true) + eq(__LOC__, [1, 2, 3]->Array.map(x => x + 1), [2, 3, 4]) + eq(__LOC__, [1, 2, 3]->Array.reduce(0, (x, y) => x + y), 6) + eq(__LOC__, [1, 2, 3]->Array.reduceWithIndex(0, (x, y, i) => x + y + i), 9) + eq(__LOC__, [1, 2, 3]->Array.some(x => x < 1), false) + eq(__LOC__, [1, 2, 3]->Array.every(x => x > 0), true) }) }) diff --git a/tests/tests/src/bs_stack_test.mjs b/tests/tests/src/bs_stack_test.mjs index cfcd9809de1..12061f0c85e 100644 --- a/tests/tests/src/bs_stack_test.mjs +++ b/tests/tests/src/bs_stack_test.mjs @@ -2,7 +2,7 @@ import * as Mocha from "mocha"; import * as Test_utils from "./test_utils.mjs"; -import * as Js_undefined from "@rescript/runtime/lib/es6/Js_undefined.mjs"; +import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.mjs"; import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.mjs"; import * as Belt_MutableQueue from "@rescript/runtime/lib/es6/Belt_MutableQueue.mjs"; import * as Belt_MutableStack from "@rescript/runtime/lib/es6/Belt_MutableStack.mjs"; @@ -11,17 +11,17 @@ function inOrder(v) { let current = v; let s = Belt_MutableStack.make(); let q = Belt_MutableQueue.make(); - while (current !== undefined) { + while (Stdlib_Option.isSome(current)) { let v$1 = current; Belt_MutableStack.push(s, v$1); current = v$1.left; }; while (!Belt_MutableStack.isEmpty(s)) { - current = Belt_MutableStack.popOrThrow(s); + current = Primitive_option.some(Belt_MutableStack.popOrThrow(s)); let v$2 = current; Belt_MutableQueue.add(q, v$2.value); current = v$2.right; - while (current !== undefined) { + while (Stdlib_Option.isSome(current)) { let v$3 = current; Belt_MutableStack.push(s, v$3); current = v$3.left; @@ -34,7 +34,7 @@ function inOrder3(v) { let current = v; let s = Belt_MutableStack.make(); let q = Belt_MutableQueue.make(); - while (current !== undefined) { + while (Stdlib_Option.isSome(current)) { let v$1 = current; Belt_MutableStack.push(s, v$1); current = v$1.left; @@ -42,7 +42,7 @@ function inOrder3(v) { Belt_MutableStack.dynamicPopIter(s, popped => { Belt_MutableQueue.add(q, popped.value); let current = popped.right; - while (current !== undefined) { + while (Stdlib_Option.isSome(current)) { let v = current; Belt_MutableStack.push(s, v); current = v.left; @@ -51,60 +51,46 @@ function inOrder3(v) { return Belt_MutableQueue.toArray(q); } -function inOrder2(v) { - let todo = true; - let cursor = v; - let s = Belt_MutableStack.make(); - let q = Belt_MutableQueue.make(); - while (todo) { - if (cursor !== undefined) { - let v$1 = cursor; - Belt_MutableStack.push(s, v$1); - cursor = v$1.left; - } else if (Belt_MutableStack.isEmpty(s)) { - todo = false; - } else { - cursor = Belt_MutableStack.popOrThrow(s); - let current = cursor; - Belt_MutableQueue.add(q, current.value); - cursor = current.right; - } - }; -} - function n(l, r, a) { return { value: a, - left: Js_undefined.fromOption(l), - right: Js_undefined.fromOption(r) + left: l, + right: r }; } -let test1 = n(Primitive_option.some(n(Primitive_option.some(n(undefined, undefined, 4)), Primitive_option.some(n(undefined, undefined, 5)), 2)), Primitive_option.some(n(undefined, undefined, 3)), 1); - -function pushAllLeft(st1, s1) { - let current = st1; - while (current !== undefined) { - let v = current; - Belt_MutableStack.push(s1, v); - current = v.left; - }; -} - -let test2 = n(Primitive_option.some(n(Primitive_option.some(n(Primitive_option.some(n(Primitive_option.some(n(undefined, undefined, 4)), undefined, 2)), undefined, 5)), undefined, 1)), undefined, 3); - -let test3 = n(Primitive_option.some(n(Primitive_option.some(n(Primitive_option.some(n(undefined, undefined, 4)), undefined, 2)), undefined, 5)), Primitive_option.some(n(undefined, undefined, 3)), 1); +let test1 = { + value: 1, + left: { + value: 2, + left: { + value: 4, + left: undefined, + right: undefined + }, + right: { + value: 5, + left: undefined, + right: undefined + } + }, + right: { + value: 3, + left: undefined, + right: undefined + } +}; Mocha.describe("Bs_stack_test", () => { Mocha.test("tree in-order traversal", () => { - Test_utils.eq("File \"bs_stack_test.res\", line 99, characters 7-14", inOrder(test1), [ + Test_utils.eq("File \"bs_stack_test.res\", line 79, characters 7-14", inOrder(Primitive_option.some(test1)), [ 4, 2, 5, 1, 3 ]); - Test_utils.eq("File \"bs_stack_test.res\", line 100, characters 7-14", inOrder3(test1), [ + Test_utils.eq("File \"bs_stack_test.res\", line 80, characters 7-14", inOrder3(Primitive_option.some(test1)), [ 4, 2, 5, @@ -123,11 +109,7 @@ export { Q, inOrder, inOrder3, - inOrder2, n, test1, - pushAllLeft, - test2, - test3, } -/* test1 Not a pure module */ +/* Not a pure module */ diff --git a/tests/tests/src/bs_stack_test.res b/tests/tests/src/bs_stack_test.res index 2915ce64486..a2b517172d1 100644 --- a/tests/tests/src/bs_stack_test.res +++ b/tests/tests/src/bs_stack_test.res @@ -1,12 +1,27 @@ open Mocha open Test_utils +/* + This tests Belt.MutableStack with a small binary tree: + + 1 + / \ + 2 3 + / \ + 4 5 + + In-order traversal visits left branch, node, then right branch, so the + expected order is [4, 2, 5, 1, 3]. The two traversal implementations below + cover both manual stack popping and dynamicPopIter, which keeps popping while + the callback is allowed to push more work. +*/ + type rec node = { value: int, left: t, right: t, } -@deriving(abstract) and t = Js.undefined +@deriving(abstract) and t = option module S = Belt.MutableStack module Q = Belt.MutableQueue @@ -15,18 +30,18 @@ let inOrder = (v: t): array => { let current = ref(v) let s: S.t = S.make() let q: Q.t = Q.make() - while current.contents !== Js.undefined { - let v = Js.Undefined.getUnsafe(current.contents) + while current.contents->Option.isSome { + let v = current.contents->Option.getUnsafe S.push(s, v) current := leftGet(v) } while !S.isEmpty(s) { - current := Js.Undefined.return(S.popOrThrow(s)) - let v = Js.Undefined.getUnsafe(current.contents) + current := Some(S.popOrThrow(s)) + let v = current.contents->Option.getUnsafe Q.add(q, valueGet(v)) current := rightGet(v) - while current.contents !== Js.undefined { - let v = Js.Undefined.getUnsafe(current.contents) + while current.contents->Option.isSome { + let v = current.contents->Option.getUnsafe S.push(s, v) current := leftGet(v) } @@ -38,16 +53,16 @@ let inOrder3 = (v: t): array => { let current = ref(v) let s: S.t = S.make() let q: Q.t = Q.make() - while current.contents !== Js.undefined { - let v = Js.Undefined.getUnsafe(current.contents) + while current.contents->Option.isSome { + let v = current.contents->Option.getUnsafe S.push(s, v) current := leftGet(v) } S.dynamicPopIter(s, popped => { Q.add(q, valueGet(popped)) let current = ref(rightGet(popped)) - while current.contents !== Js.undefined { - let v = Js.Undefined.getUnsafe(current.contents) + while current.contents->Option.isSome { + let v = current.contents->Option.getUnsafe S.push(s, v) current := leftGet(v) } @@ -55,48 +70,13 @@ let inOrder3 = (v: t): array => { Q.toArray(q) } -let inOrder2 = (v: t) => { - let todo = ref(true) - let cursor = ref(v) - let s: S.t = S.make() - let q: Q.t = Q.make() - while todo.contents { - if cursor.contents !== Js.undefined { - let v = Js.Undefined.getUnsafe(cursor.contents) - S.push(s, v) - cursor := leftGet(v) - } else if !S.isEmpty(s) { - cursor := Js.Undefined.return(S.popOrThrow(s)) - let current = Js.Undefined.getUnsafe(cursor.contents) - Q.add(q, valueGet(current)) - cursor := rightGet(current) - } else { - todo := false - } - } -} - -let n = (~l=?, ~r=?, a) => - node(~value=a, ~left=Js.Undefined.fromOption(l), ~right=Js.Undefined.fromOption(r)) +let n = (~l=?, ~r=?, a) => node(~value=a, ~left=l, ~right=r) let test1 = n(1, ~l=n(2, ~l=n(4), ~r=n(5)), ~r=n(3)) -let pushAllLeft = (st1, s1) => { - let current = ref(st1) - while current.contents !== Js.undefined { - let v = Js.Undefined.getUnsafe(current.contents) - S.push(s1, v) - current := leftGet(v) - } -} - -let test2 = n(3, ~l=n(1, ~l=n(5, ~l=n(2, ~l=n(4))))) - -let test3 = n(1, ~l=n(5, ~l=n(2, ~l=n(4))), ~r=n(3)) - describe(__MODULE__, () => { test("tree in-order traversal", () => { - eq(__LOC__, inOrder(Js.Undefined.return(test1)), [4, 2, 5, 1, 3]) - eq(__LOC__, inOrder3(Js.Undefined.return(test1)), [4, 2, 5, 1, 3]) + eq(__LOC__, inOrder(Some(test1)), [4, 2, 5, 1, 3]) + eq(__LOC__, inOrder3(Some(test1)), [4, 2, 5, 1, 3]) }) }) diff --git a/tests/tests/src/bs_string_test.mjs b/tests/tests/src/bs_string_test.mjs index a4f1d0d1d5d..d73847ddd0f 100644 --- a/tests/tests/src/bs_string_test.mjs +++ b/tests/tests/src/bs_string_test.mjs @@ -2,9 +2,10 @@ import * as Mocha from "mocha"; import * as Test_utils from "./test_utils.mjs"; +import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.mjs"; Mocha.describe("Bs_string_test", () => { - Mocha.test("string split and reduce", () => Test_utils.eq("File \"bs_string_test.res\", line 7, characters 6-13", "ghso ghso g".split(" ").reduce((x, y) => x + ("-" + y), ""), "-ghso-ghso-g")); + Mocha.test("string split and reduce", () => Test_utils.eq("File \"bs_string_test.res\", line 7, characters 6-13", Stdlib_Array.reduce("ghso ghso g".split(" "), "", (x, y) => x + ("-" + y)), "-ghso-ghso-g")); }); /* Not a pure module */ diff --git a/tests/tests/src/bs_string_test.res b/tests/tests/src/bs_string_test.res index f6b3d3ef718..4e50f402f82 100644 --- a/tests/tests/src/bs_string_test.res +++ b/tests/tests/src/bs_string_test.res @@ -5,7 +5,7 @@ describe(__MODULE__, () => { test("string split and reduce", () => eq( __LOC__, - "ghso ghso g"->Js.String2.split(" ")->Js.Array2.reduce((x, y) => x ++ ("-" ++ y), ""), + "ghso ghso g"->String.split(" ")->Array.reduce("", (x, y) => x ++ ("-" ++ y)), "-ghso-ghso-g", ) ) diff --git a/tests/tests/src/caml_compare_test.res b/tests/tests/src/caml_compare_test.res index 3e294a7400d..5b5d0e95118 100644 --- a/tests/tests/src/caml_compare_test.res +++ b/tests/tests/src/caml_compare_test.res @@ -195,27 +195,27 @@ describe(__MODULE__, () => { }) test("null compare 1", () => { - eq(__LOC__, compare(Js.null, Js.Null.return(list{3})), -1) + eq(__LOC__, compare(Null.null, Null.make(list{3})), -1) }) test("null compare 2", () => { - eq(__LOC__, compare(Js.Null.return(list{3}), Js.null), 1) + eq(__LOC__, compare(Null.make(list{3}), Null.null), 1) }) test("null compare 3", () => { - eq(__LOC__, compare(Js.null, Js.Null.return(0)), -1) + eq(__LOC__, compare(Null.null, Null.make(0)), -1) }) test("null compare 4", () => { - eq(__LOC__, compare(Js.Null.return(0), Js.null), 1) + eq(__LOC__, compare(Null.make(0), Null.null), 1) }) test("undefined compare 1", () => { - eq(__LOC__, compare(Js.Nullable.undefined, Js.Nullable.return(0)), -1) + eq(__LOC__, compare(Nullable.undefined, Nullable.make(0)), -1) }) test("undefined compare 2", () => { - eq(__LOC__, compare(Js.Nullable.return(0), Js.Nullable.undefined), 1) + eq(__LOC__, compare(Nullable.make(0), Nullable.undefined), 1) }) test("additional option compare 1", () => { diff --git a/tests/tests/src/chn_test.mjs b/tests/tests/src/chn_test.mjs index 98ee2fb19a5..2fd6f1c3c38 100644 --- a/tests/tests/src/chn_test.mjs +++ b/tests/tests/src/chn_test.mjs @@ -1,8 +1,8 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Mocha from "mocha"; -import * as Belt_List from "@rescript/runtime/lib/es6/Belt_List.mjs"; import * as Test_utils from "./test_utils.mjs"; +import * as Stdlib_List from "@rescript/runtime/lib/es6/Stdlib_List.mjs"; console.log(`你好, 世界`); @@ -10,7 +10,7 @@ console.log(`你好, console.log(`\x3f\u003f\b\t\n\v\f\r\0"'`); function convert(s) { - return Belt_List.fromArray(Array.from(s, x => { + return Stdlib_List.fromArray(Array.from(s).map(x => { let x$1 = x.codePointAt(0); if (x$1 !== undefined) { return x$1; @@ -19,7 +19,7 @@ function convert(s) { RE_EXN_ID: "Assert_failure", _1: [ "chn_test.res", - 14, + 16, 16 ], Error: new Error() @@ -28,9 +28,9 @@ function convert(s) { } Mocha.describe("Chn_test", () => { - Mocha.test("Chinese string newline", () => Test_utils.eq("File \"chn_test.res\", line 23, characters 6-13", `你好, + Mocha.test("Chinese string newline", () => Test_utils.eq("File \"chn_test.res\", line 25, characters 6-13", `你好, 世界`, `你好,\n世界`)); - Mocha.test("Convert Chinese characters", () => Test_utils.eq("File \"chn_test.res\", line 32, characters 6-13", convert(`汉字是世界上最美丽的character`), { + Mocha.test("Convert Chinese characters", () => Test_utils.eq("File \"chn_test.res\", line 34, characters 6-13", convert(`汉字是世界上最美丽的character`), { hd: 27721, tl: { hd: 23383, @@ -88,7 +88,7 @@ Mocha.describe("Chn_test", () => { } } })); - Mocha.test("Convert hex escape", () => Test_utils.eq("File \"chn_test.res\", line 58, characters 38-45", convert(`\x3f\x3fa`), { + Mocha.test("Convert hex escape", () => Test_utils.eq("File \"chn_test.res\", line 60, characters 38-45", convert(`\x3f\x3fa`), { hd: 63, tl: { hd: 63, @@ -98,7 +98,7 @@ Mocha.describe("Chn_test", () => { } } })); - Mocha.test("Convert question marks", () => Test_utils.eq("File \"chn_test.res\", line 59, characters 42-49", convert(`??a`), { + Mocha.test("Convert question marks", () => Test_utils.eq("File \"chn_test.res\", line 61, characters 42-49", convert(`??a`), { hd: 63, tl: { hd: 63, @@ -108,7 +108,7 @@ Mocha.describe("Chn_test", () => { } } })); - Mocha.test("Convert unicode escape", () => Test_utils.eq("File \"chn_test.res\", line 60, characters 42-49", convert(`\u003f\x3fa`), { + Mocha.test("Convert unicode escape", () => Test_utils.eq("File \"chn_test.res\", line 62, characters 42-49", convert(`\u003f\x3fa`), { hd: 63, tl: { hd: 63, @@ -118,7 +118,7 @@ Mocha.describe("Chn_test", () => { } } })); - Mocha.test("Convert rocket emoji with a", () => Test_utils.eq("File \"chn_test.res\", line 62, characters 7-14", convert(`🚀🚀a`), { + Mocha.test("Convert rocket emoji with a", () => Test_utils.eq("File \"chn_test.res\", line 64, characters 7-14", convert(`🚀🚀a`), { hd: 128640, tl: { hd: 128640, @@ -128,21 +128,21 @@ Mocha.describe("Chn_test", () => { } } })); - Mocha.test("Convert rocket emoji surrogate with a", () => Test_utils.eq("File \"chn_test.res\", line 65, characters 7-14", convert(`\uD83D\uDE80a`), { + Mocha.test("Convert rocket emoji surrogate with a", () => Test_utils.eq("File \"chn_test.res\", line 67, characters 7-14", convert(`\uD83D\uDE80a`), { hd: 128640, tl: { hd: 97, tl: /* [] */0 } })); - Mocha.test("Convert rocket emoji surrogate with question", () => Test_utils.eq("File \"chn_test.res\", line 68, characters 7-14", convert(`\uD83D\uDE80\x3f`), { + Mocha.test("Convert rocket emoji surrogate with question", () => Test_utils.eq("File \"chn_test.res\", line 70, characters 7-14", convert(`\uD83D\uDE80\x3f`), { hd: 128640, tl: { hd: 63, tl: /* [] */0 } })); - Mocha.test("Convert double rocket emoji with a", () => Test_utils.eq("File \"chn_test.res\", line 72, characters 7-14", convert(`\uD83D\uDE80\uD83D\uDE80a`), { + Mocha.test("Convert double rocket emoji with a", () => Test_utils.eq("File \"chn_test.res\", line 74, characters 7-14", convert(`\uD83D\uDE80\uD83D\uDE80a`), { hd: 128640, tl: { hd: 128640, @@ -152,21 +152,21 @@ Mocha.describe("Chn_test", () => { } } })); - Mocha.test("String length with emoji", () => Test_utils.eq("File \"chn_test.res\", line 75, characters 44-51", `\uD83D\uDE80\0`.length, 3)); - Mocha.test("String get emoji with null", () => Test_utils.eq("File \"chn_test.res\", line 78, characters 7-14", `\uD83D\uDE80\0`.codePointAt(0), 128640)); - Mocha.test("String get rocket emoji", () => Test_utils.eq("File \"chn_test.res\", line 80, characters 43-50", `🚀`.codePointAt(0), 128640)); - Mocha.test("Convert rocket emoji", () => Test_utils.eq("File \"chn_test.res\", line 82, characters 40-47", convert(`\uD83D\uDE80`), { + Mocha.test("String length with emoji", () => Test_utils.eq("File \"chn_test.res\", line 77, characters 44-51", `\uD83D\uDE80\0`.length, 3)); + Mocha.test("String get emoji with null", () => Test_utils.eq("File \"chn_test.res\", line 80, characters 7-14", `\uD83D\uDE80\0`.codePointAt(0), 128640)); + Mocha.test("String get rocket emoji", () => Test_utils.eq("File \"chn_test.res\", line 82, characters 43-50", `🚀`.codePointAt(0), 128640)); + Mocha.test("Convert rocket emoji", () => Test_utils.eq("File \"chn_test.res\", line 84, characters 40-47", convert(`\uD83D\uDE80`), { hd: 128640, tl: /* [] */0 })); - Mocha.test("Convert double rocket emoji", () => Test_utils.eq("File \"chn_test.res\", line 84, characters 7-14", convert(`\uD83D\uDE80\uD83D\uDE80`), { + Mocha.test("Convert double rocket emoji", () => Test_utils.eq("File \"chn_test.res\", line 86, characters 7-14", convert(`\uD83D\uDE80\uD83D\uDE80`), { hd: 128640, tl: { hd: 128640, tl: /* [] */0 } })); - Mocha.test("Convert whitespace chars", () => Test_utils.eq("File \"chn_test.res\", line 87, characters 7-14", convert(` \b\t\n\v\f\ra`), { + Mocha.test("Convert whitespace chars", () => Test_utils.eq("File \"chn_test.res\", line 89, characters 7-14", convert(` \b\t\n\v\f\ra`), { hd: 32, tl: { hd: 8, @@ -191,7 +191,7 @@ Mocha.describe("Chn_test", () => { } } })); - Mocha.test("Convert escaped chars", () => Test_utils.eq("File \"chn_test.res\", line 90, characters 7-14", convert(` \b\t\n\v\f\r"'\\\0a`), { + Mocha.test("Convert escaped chars", () => Test_utils.eq("File \"chn_test.res\", line 92, characters 7-14", convert(` \b\t\n\v\f\r"'\\\0a`), { hd: 32, tl: { hd: 8, diff --git a/tests/tests/src/chn_test.res b/tests/tests/src/chn_test.res index 3f5cf0dcd1c..2198c15da05 100644 --- a/tests/tests/src/chn_test.res +++ b/tests/tests/src/chn_test.res @@ -1,6 +1,5 @@ open Mocha open Test_utils -open Belt Console.log(`你好, 世界`) @@ -9,8 +8,11 @@ Console.log(`\x3f\u003f\b\t\n\v\f\r\0"'`) let convert = (s: string): list => List.fromArray( - Js_array2.fromMap(Js_string.castToArrayLike(s), x => - switch Js_string2.codePointAt(x, 0) { + s + ->String.asIterable + ->Array.fromIterable + ->Array.map(x => + switch String.codePointAt(x, 0) { | None => assert(false) | Some(x) => x } diff --git a/tests/tests/src/class_type_ffi_test.res b/tests/tests/src/class_type_ffi_test.res index de7546c0c69..95bcbf4dba4 100644 --- a/tests/tests/src/class_type_ffi_test.res +++ b/tests/tests/src/class_type_ffi_test.res @@ -1,5 +1,5 @@ -/* TODO: create a special type - ['a Js.prop_set] for better error message +/* TODO: create a special property-setter type + for a better error message */ let test_set = x => x["length__aux"] = 3 diff --git a/tests/tests/src/complex_while_loop.res b/tests/tests/src/complex_while_loop.res index ac58e1830a5..d5906ab4a24 100644 --- a/tests/tests/src/complex_while_loop.res +++ b/tests/tests/src/complex_while_loop.res @@ -8,7 +8,7 @@ let f = () => { } fib(n.contents) > 10 } { - n.contents->Js.Int.toString->Console.log + n.contents->Int.toString->Console.log incr(n) } } diff --git a/tests/tests/src/custom_error_test.mjs b/tests/tests/src/custom_error_test.mjs index 07215d1f601..4d8a2ac21cc 100644 --- a/tests/tests/src/custom_error_test.mjs +++ b/tests/tests/src/custom_error_test.mjs @@ -1,6 +1,6 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Stdlib_Exn from "@rescript/runtime/lib/es6/Stdlib_Exn.mjs"; +import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.mjs"; import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.mjs"; function test_js_error() { @@ -9,8 +9,8 @@ function test_js_error() { e = JSON.parse(` {"x" : }`); } catch (raw_err) { let err = Primitive_exceptions.internalToException(raw_err); - if (err.RE_EXN_ID === Stdlib_Exn.$$Error) { - console.log(err._1.stack); + if (err.RE_EXN_ID === "JsExn") { + console.log(Stdlib_JsExn.stack(err._1)); return; } throw err; @@ -23,8 +23,8 @@ function test_js_error2() { return JSON.parse(` {"x" : }`); } catch (raw_e) { let e = Primitive_exceptions.internalToException(raw_e); - if (e.RE_EXN_ID === Stdlib_Exn.$$Error) { - console.log(e._1.stack); + if (e.RE_EXN_ID === "JsExn") { + console.log(Stdlib_JsExn.stack(e._1)); throw e; } throw e; @@ -37,8 +37,8 @@ function example1() { v = JSON.parse(` {"x" }`); } catch (raw_err) { let err = Primitive_exceptions.internalToException(raw_err); - if (err.RE_EXN_ID === Stdlib_Exn.$$Error) { - console.log(err._1.stack); + if (err.RE_EXN_ID === "JsExn") { + console.log(Stdlib_JsExn.stack(err._1)); return; } throw err; @@ -51,7 +51,7 @@ function example2() { return JSON.parse(` {"x"}`); } catch (raw_exn) { let exn = Primitive_exceptions.internalToException(raw_exn); - if (exn.RE_EXN_ID === Stdlib_Exn.$$Error) { + if (exn.RE_EXN_ID === "JsExn") { return; } throw exn; @@ -64,4 +64,4 @@ export { example1, example2, } -/* No side effect */ +/* Stdlib_JsExn Not a pure module */ diff --git a/tests/tests/src/custom_error_test.res b/tests/tests/src/custom_error_test.res index 9dc697f29f7..86473d01006 100644 --- a/tests/tests/src/custom_error_test.res +++ b/tests/tests/src/custom_error_test.res @@ -1,29 +1,29 @@ let test_js_error = () => - switch Js.Json.parseExn(` {"x" : }`) { - | exception Js.Exn.Error(err) => - Console.log(Js.Exn.stack(err)) + switch JSON.parseOrThrow(` {"x" : }`) { + | exception JsExn(err) => + Console.log(JsExn.stack(err)) None | e => Some(e) } let test_js_error2 = () => - try Js.Json.parseExn(` {"x" : }`) catch { - | Js.Exn.Error(err) as e => - Console.log(Js.Exn.stack(err)) + try JSON.parseOrThrow(` {"x" : }`) catch { + | JsExn(err) as e => + Console.log(JsExn.stack(err)) throw(e) } let example1 = () => - switch Js.Json.parseExn(` {"x" }`) { - | exception Js.Exn.Error(err) => - Console.log(Js.Exn.stack(err)) + switch JSON.parseOrThrow(` {"x" }`) { + | exception JsExn(err) => + Console.log(JsExn.stack(err)) None | v => Some(v) } let example2 = () => - try Some(Js.Json.parseExn(` {"x"}`)) catch { - | Js.Exn.Error(_) => None + try Some(JSON.parseOrThrow(` {"x"}`)) catch { + | JsExn(_) => None } /* let () = diff --git a/tests/tests/src/earger_curry_test.mjs b/tests/tests/src/earger_curry_test.mjs index 362d3062821..0ec6b670641 100644 --- a/tests/tests/src/earger_curry_test.mjs +++ b/tests/tests/src/earger_curry_test.mjs @@ -46,7 +46,7 @@ function f2() { let arr = Belt_Array.init(30000000, i => i); let b = Belt_Array.map(arr, i => i + i - 1); let v = Belt_Array.reduceReverse(b, 0, (prim0, prim1) => prim0 + prim1); - console.log(v.toString()); + console.log(String(v)); } f2(); diff --git a/tests/tests/src/earger_curry_test.res b/tests/tests/src/earger_curry_test.res index 72fc6eb0183..310d08464fd 100644 --- a/tests/tests/src/earger_curry_test.res +++ b/tests/tests/src/earger_curry_test.res @@ -55,7 +55,7 @@ let f = { let arr = init(10000000, i => float_of_int(i)) let b = arr->map(i => i +. i -. 1.) let v = b->reduceReverse(0., \"+.") - v->Js.Float.toString->Console.log + v->Float.toString->Console.log } } @@ -64,7 +64,7 @@ let f2 = () => { let arr = init(30_000_000, i => float_of_int(i)) let b = arr->map(i => i +. i -. 1.) let v = b->reduceReverse(0., \"+.") - v->Js.Float.toString->Console.log + v->Float.toString->Console.log } /* let time label f = */ diff --git a/tests/tests/src/equal_box_test.mjs b/tests/tests/src/equal_box_test.mjs index b645e33983e..d26a9ac7046 100644 --- a/tests/tests/src/equal_box_test.mjs +++ b/tests/tests/src/equal_box_test.mjs @@ -2,60 +2,35 @@ import * as Mocha from "mocha"; import * as Test_utils from "./test_utils.mjs"; -import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.mjs"; - -let aa = Primitive_object.equal; - -let bb = Primitive_object.equal; - -let cc = Primitive_object.equal; Mocha.describe("Equal_box_test", () => { Mocha.test("eqNull_tests", () => { - Test_utils.ok("File \"equal_box_test.res\", line 11, characters 7-14", 3 !== null); - Test_utils.ok("File \"equal_box_test.res\", line 12, characters 7-14", true); - Test_utils.ok("File \"equal_box_test.res\", line 13, characters 7-14", "3" !== null); - Test_utils.ok("File \"equal_box_test.res\", line 14, characters 7-14", /* '3' */51 !== null); - Test_utils.ok("File \"equal_box_test.res\", line 15, characters 7-14", 0 !== null); + Test_utils.ok("File \"equal_box_test.res\", line 12, characters 7-14", 3 !== null); + Test_utils.ok("File \"equal_box_test.res\", line 13, characters 7-14", true); + Test_utils.ok("File \"equal_box_test.res\", line 14, characters 7-14", "3" !== null); + Test_utils.ok("File \"equal_box_test.res\", line 15, characters 7-14", /* '3' */51 !== null); Test_utils.ok("File \"equal_box_test.res\", line 16, characters 7-14", 0 !== null); - Test_utils.ok("File \"equal_box_test.res\", line 17, characters 7-14", true); + Test_utils.ok("File \"equal_box_test.res\", line 17, characters 7-14", 0 !== null); Test_utils.ok("File \"equal_box_test.res\", line 18, characters 7-14", true); Test_utils.ok("File \"equal_box_test.res\", line 19, characters 7-14", true); Test_utils.ok("File \"equal_box_test.res\", line 20, characters 7-14", true); - Test_utils.ok("File \"equal_box_test.res\", line 21, characters 7-14", 3 !== undefined); + Test_utils.ok("File \"equal_box_test.res\", line 21, characters 7-14", true); + Test_utils.ok("File \"equal_box_test.res\", line 22, characters 7-14", 3 !== undefined); }); Mocha.test("eqNullable_tests", () => { let v = null; - Test_utils.ok("File \"equal_box_test.res\", line 29, characters 7-14", 3 !== v); - Test_utils.ok("File \"equal_box_test.res\", line 30, characters 7-14", undefined !== v); - Test_utils.ok("File \"equal_box_test.res\", line 31, characters 7-14", "3" !== v); - Test_utils.ok("File \"equal_box_test.res\", line 32, characters 7-14", /* '3' */51 !== v); - Test_utils.ok("File \"equal_box_test.res\", line 33, characters 7-14", 0 !== v); + Test_utils.ok("File \"equal_box_test.res\", line 30, characters 7-14", 3 !== v); + Test_utils.ok("File \"equal_box_test.res\", line 31, characters 7-14", undefined !== v); + Test_utils.ok("File \"equal_box_test.res\", line 32, characters 7-14", "3" !== v); + Test_utils.ok("File \"equal_box_test.res\", line 33, characters 7-14", /* '3' */51 !== v); Test_utils.ok("File \"equal_box_test.res\", line 34, characters 7-14", 0 !== v); - Test_utils.ok("File \"equal_box_test.res\", line 35, characters 7-14", undefined !== v); - Test_utils.ok("File \"equal_box_test.res\", line 36, characters 7-14", null === v); - Test_utils.ok("File \"equal_box_test.res\", line 37, characters 7-14", true); + Test_utils.ok("File \"equal_box_test.res\", line 35, characters 7-14", 0 !== v); + Test_utils.ok("File \"equal_box_test.res\", line 36, characters 7-14", undefined !== v); + Test_utils.ok("File \"equal_box_test.res\", line 37, characters 7-14", null === v); Test_utils.ok("File \"equal_box_test.res\", line 38, characters 7-14", true); - Test_utils.ok("File \"equal_box_test.res\", line 39, characters 7-14", 3 !== undefined); - }); - Mocha.test("eqUndefined_tests", () => { - Test_utils.ok("File \"equal_box_test.res\", line 47, characters 7-14", 3 !== undefined); - Test_utils.ok("File \"equal_box_test.res\", line 48, characters 7-14", true); - Test_utils.ok("File \"equal_box_test.res\", line 49, characters 7-14", "3" !== undefined); - Test_utils.ok("File \"equal_box_test.res\", line 50, characters 7-14", /* '3' */51 !== undefined); - Test_utils.ok("File \"equal_box_test.res\", line 51, characters 7-14", 0 !== undefined); - Test_utils.ok("File \"equal_box_test.res\", line 52, characters 7-14", 0 !== undefined); - Test_utils.ok("File \"equal_box_test.res\", line 53, characters 7-14", true); - Test_utils.ok("File \"equal_box_test.res\", line 54, characters 7-14", true); - Test_utils.ok("File \"equal_box_test.res\", line 55, characters 7-14", true); - Test_utils.ok("File \"equal_box_test.res\", line 56, characters 7-14", true); - Test_utils.ok("File \"equal_box_test.res\", line 57, characters 7-14", 3 !== undefined); + Test_utils.ok("File \"equal_box_test.res\", line 39, characters 7-14", true); + Test_utils.ok("File \"equal_box_test.res\", line 40, characters 7-14", 3 !== undefined); }); }); -export { - aa, - bb, - cc, -} /* Not a pure module */ diff --git a/tests/tests/src/equal_box_test.res b/tests/tests/src/equal_box_test.res index 5fe90d4956c..78146d193d0 100644 --- a/tests/tests/src/equal_box_test.res +++ b/tests/tests/src/equal_box_test.res @@ -1,29 +1,30 @@ open Mocha open Test_utils -open Js -let (aa, bb, cc) = (eqNull, eqUndefined, eqNullable) + +external eqNull: ('a, null<'a>) => bool = "%equal_null" +external eqNullable: ('a, nullable<'a>) => bool = "%equal_nullable" describe(__MODULE__, () => { test("eqNull_tests", () => { let f = () => None - let shouldBeNull = () => Js.null + let shouldBeNull = () => Null.null - ok(__LOC__, !eqNull(3, Js.null)) - ok(__LOC__, !eqNull(None, Js.null)) - ok(__LOC__, !eqNull("3", Js.null)) - ok(__LOC__, !eqNull('3', Js.null)) - ok(__LOC__, !eqNull(0, Js.null)) - ok(__LOC__, !eqNull(0., Js.null)) - ok(__LOC__, !eqNull(f(), Js.null)) - ok(__LOC__, eqNull(shouldBeNull(), Js.null)) - ok(__LOC__, !eqNull(1, Js.Null.return(3))) - ok(__LOC__, eqNull(None, Js.Null.return(None))) - ok(__LOC__, !eqNull(Some(3), Js.Null.return(None))) + ok(__LOC__, !eqNull(3, Null.null)) + ok(__LOC__, !eqNull(None, Null.null)) + ok(__LOC__, !eqNull("3", Null.null)) + ok(__LOC__, !eqNull('3', Null.null)) + ok(__LOC__, !eqNull(0, Null.null)) + ok(__LOC__, !eqNull(0., Null.null)) + ok(__LOC__, !eqNull(f(), Null.null)) + ok(__LOC__, eqNull(shouldBeNull(), Null.null)) + ok(__LOC__, !eqNull(1, Null.make(3))) + ok(__LOC__, eqNull(None, Null.make(None))) + ok(__LOC__, !eqNull(Some(3), Null.make(None))) }) test("eqNullable_tests", () => { let f = () => None - let shouldBeNull = () => Js.null + let shouldBeNull = () => Null.null let v = Nullable.null ok(__LOC__, !eqNullable(3, v)) @@ -34,26 +35,8 @@ describe(__MODULE__, () => { ok(__LOC__, !eqNullable(0., v)) ok(__LOC__, !eqNullable(f(), v)) ok(__LOC__, eqNullable(shouldBeNull(), v)) - ok(__LOC__, !eqNullable(1, Nullable.return(3))) - ok(__LOC__, eqNullable(None, Nullable.return(None))) - ok(__LOC__, !eqNullable(Some(3), Nullable.return(None))) - }) - - test("eqUndefined_tests", () => { - let f = () => None - let shouldBeNull = () => Js.null - let v = Undefined.empty - - ok(__LOC__, !eqUndefined(3, v)) - ok(__LOC__, eqUndefined(None, v)) - ok(__LOC__, !eqUndefined("3", v)) - ok(__LOC__, !eqUndefined('3', v)) - ok(__LOC__, !eqUndefined(0, v)) - ok(__LOC__, !eqUndefined(0., v)) - ok(__LOC__, eqUndefined(f(), v)) - ok(__LOC__, !eqUndefined(shouldBeNull(), v)) - ok(__LOC__, !eqUndefined(1, Undefined.return(3))) - ok(__LOC__, eqUndefined(None, Undefined.return(None))) - ok(__LOC__, !eqUndefined(Some(3), Undefined.return(None))) + ok(__LOC__, !eqNullable(1, Nullable.make(3))) + ok(__LOC__, eqNullable(None, Nullable.make(None))) + ok(__LOC__, !eqNullable(Some(3), Nullable.make(None))) }) }) diff --git a/tests/tests/src/event_ffi.res b/tests/tests/src/event_ffi.res index 601457e434e..83c0a4b33c0 100644 --- a/tests/tests/src/event_ffi.res +++ b/tests/tests/src/event_ffi.res @@ -1,35 +1,3 @@ -/* -type process - -external on : process -> - [ - `beforeExit - | `exit - ] -> unit Js.fn -> unit = "on" [@@send] - - -external p : process = "process" [@@val] - - -external on_hi : process -> - [ - `hello - | `xx - ] -> (unit*unit) Js.fn -> unit = "on" [@@send] - -type 'a t - -external (!) : 'a t -> 'a = "identity" - -let f x = - !x # hey 3 + !x # v - -let () = - on p `exit (Js.Internal.fn_mk0 (fun _ -> prerr_endline "hello world")); - on_hi p `xx (Js.Internal.fn_mk1 (fun _ -> prerr_endline "hello world")) - -*/ - let h0 = x => x() /* {[ function h0 (x){ @@ -52,11 +20,6 @@ let a0 = () => Console.log("hi") let a1 = () => x => x let a2 = (x, y) => x + y let a3 = (x, y, z) => x + y + z -/* let a4 = Js.Internal.fn_mk4 (fun x y z -> let u = x * x + y * y + z * z in fun d -> u + d) */ - -/* let a44 = Js.Internal.fn_mk4 (fun x y z d -> let u = x * x + y * y + z * z in u + d) */ - -/* let b44 () = Js.Internal.fn_mk4 (fun x y z d -> (x,y,z,d)) */ /* polymoprhic restriction */ let test_as: (_ as 'b, 'a => 'a) => 'b = Belt.List.map diff --git a/tests/tests/src/exception_raise_test.mjs b/tests/tests/src/exception_raise_test.mjs index 795ebc0d1ff..c26ef72c659 100644 --- a/tests/tests/src/exception_raise_test.mjs +++ b/tests/tests/src/exception_raise_test.mjs @@ -90,7 +90,7 @@ try { a0 = (function (){throw 2} ()); } catch (raw_x$3) { let x$3 = Primitive_exceptions.internalToException(raw_x$3); - if (x$3.RE_EXN_ID === A || x$3.RE_EXN_ID === Stdlib_Exn.$$Error) { + if (x$3.RE_EXN_ID === A || x$3.RE_EXN_ID === "JsExn") { a0 = x$3._1; } else { throw { @@ -160,9 +160,9 @@ Mocha.describe("Exception_raise_test", () => { 2, 2 ])); - Mocha.test("Js.Exn.Error conversion", () => { - if (a1.RE_EXN_ID === Stdlib_Exn.$$Error) { - return Test_utils.eq("File \"exception_raise_test.res\", line 77, characters 28-35", a1._1, 2); + Mocha.test("Exn.Error conversion", () => { + if (a1.RE_EXN_ID === "JsExn") { + return Test_utils.eq("File \"exception_raise_test.res\", line 77, characters 21-28", a1._1, 2); } throw { RE_EXN_ID: "Assert_failure", @@ -174,7 +174,7 @@ Mocha.describe("Exception_raise_test", () => { Error: new Error() }; }); - Mocha.test("Js.Exn.asJsExn with raw throw", () => { + Mocha.test("Exn.asJsExn with raw throw", () => { let testValue; try { testValue = (()=>{throw 2})(); diff --git a/tests/tests/src/exception_raise_test.res b/tests/tests/src/exception_raise_test.res index f3c7ffde477..5d44a46936e 100644 --- a/tests/tests/src/exception_raise_test.res +++ b/tests/tests/src/exception_raise_test.res @@ -42,7 +42,7 @@ let fff = try %raw(` function () {throw 2} ()`) catch { let a0 = try %raw(` function (){throw 2} () `) catch { | A(x) => x -| Js.Exn.Error(v) => Obj.magic(v) +| JsExn(v) => Obj.magic(v) | _ => assert(false) } @@ -72,16 +72,16 @@ describe(__MODULE__, () => { eq(__LOC__, (f, ff, fff, a0), (2, 2, 2, 2)) }) - test("Js.Exn.Error conversion", () => { + test("Exn.Error conversion", () => { switch a1 { - | Js.Exn.Error(v) => eq(__LOC__, Obj.magic(v), 2) + | JsExn(v) => eq(__LOC__, Obj.magic(v), 2) | _ => assert(false) } }) - test("Js.Exn.asJsExn with raw throw", () => { + test("Exn.asJsExn with raw throw", () => { let testValue = try %raw(`()=>{throw 2}`)() catch { - | e => Js.Exn.asJsExn(e) != None + | e => Exn.asJsExn(e) != None } eq(__LOC__, testValue, true) }) diff --git a/tests/tests/src/exception_rebound_err_test.mjs b/tests/tests/src/exception_rebound_err_test.mjs index 35e1f22a11f..df0a434707b 100644 --- a/tests/tests/src/exception_rebound_err_test.mjs +++ b/tests/tests/src/exception_rebound_err_test.mjs @@ -51,7 +51,7 @@ function f(g) { } Mocha.describe("Exception_rebound_err_test", () => { - Mocha.test("exception rebound error test", () => Test_utils.eq("File \"exception_rebound_err_test.res\", line 29, characters 7-14", test_js_error4(), 7)); + Mocha.test("exception rebound error test", () => Test_utils.eq("File \"exception_rebound_err_test.res\", line 28, characters 7-14", test_js_error4(), 7)); }); export { diff --git a/tests/tests/src/exception_rebound_err_test.res b/tests/tests/src/exception_rebound_err_test.res index b159aff7ab9..701aeaf725a 100644 --- a/tests/tests/src/exception_rebound_err_test.res +++ b/tests/tests/src/exception_rebound_err_test.res @@ -1,6 +1,5 @@ open Mocha open Test_utils -open Js exception A(int) exception B @@ -8,7 +7,7 @@ exception C(int, int) let test_js_error4 = () => try { - ignore(Js.Json.parseExn(` {"x"}`)) + ignore(JSON.parseOrThrow(` {"x"}`)) 1 } catch { | Not_found => 2 diff --git a/tests/tests/src/exception_value_test.mjs b/tests/tests/src/exception_value_test.mjs index 110393b249b..fffc5d4c3dd 100644 --- a/tests/tests/src/exception_value_test.mjs +++ b/tests/tests/src/exception_value_test.mjs @@ -1,6 +1,6 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Stdlib_Exn from "@rescript/runtime/lib/es6/Stdlib_Exn.mjs"; +import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.mjs"; import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.mjs"; function f() { @@ -60,8 +60,8 @@ function test_js_error2() { return JSON.parse(` {"x" : }`); } catch (raw_e) { let e = Primitive_exceptions.internalToException(raw_e); - if (e.RE_EXN_ID === Stdlib_Exn.$$Error) { - console.log(e._1.stack); + if (e.RE_EXN_ID === "JsExn") { + console.log(Stdlib_JsExn.stack(e._1)); throw e; } throw e; @@ -89,4 +89,4 @@ export { test_js_error2, test_js_error3, } -/* No side effect */ +/* Stdlib_JsExn Not a pure module */ diff --git a/tests/tests/src/exception_value_test.res b/tests/tests/src/exception_value_test.res index 42fd866a906..4ee358dc406 100644 --- a/tests/tests/src/exception_value_test.res +++ b/tests/tests/src/exception_value_test.res @@ -23,15 +23,15 @@ let test_not_found = (f, ()) => } let test_js_error2 = () => - try Js.Json.parseExn(` {"x" : }`) catch { - | Js.Exn.Error(err) as e => - Console.log(Js.Exn.stack(err)) + try JSON.parseOrThrow(` {"x" : }`) catch { + | JsExn(err) as e => + Console.log(JsExn.stack(err)) throw(e) } let test_js_error3 = () => try { - ignore(Js.Json.parseExn(` {"x"}`)) + ignore(JSON.parseOrThrow(` {"x"}`)) 1 } catch { | e => 0 diff --git a/tests/tests/src/ffi_array_test.res b/tests/tests/src/ffi_array_test.res index 35e4b341572..5bc2d81345e 100644 --- a/tests/tests/src/ffi_array_test.res +++ b/tests/tests/src/ffi_array_test.res @@ -1,7 +1,7 @@ open Mocha open Test_utils -@send external map: (Js_array2.t<'a>, 'a => 'b) => Js_array2.t<'b> = "map" +@send external map: (array<'a>, 'a => 'b) => array<'b> = "map" describe(__MODULE__, () => { test("ffi array test", () => { diff --git a/tests/tests/src/ffi_js_test.res b/tests/tests/src/ffi_js_test.res index 08eb56b0847..ab33d0f1901 100644 --- a/tests/tests/src/ffi_js_test.res +++ b/tests/tests/src/ffi_js_test.res @@ -62,8 +62,8 @@ describe(__MODULE__, () => { list{int_config, {"hi": 3, "low": 32}}, list{string_config, {"hi": 3, "low": "32"}}, ) - eq(__LOC__, Belt.Array.length(Js_obj.keys(int_config)), 2) - eq(__LOC__, Belt.Array.length(Js_obj.keys(string_config)), 2) + eq(__LOC__, int_config->Object.keysToArray->Array.length, 2) + eq(__LOC__, string_config->Object.keysToArray->Array.length, 2) }) test("side effect config", () => { diff --git a/tests/tests/src/ffi_test.res b/tests/tests/src/ffi_test.res index fc3ef608d01..77762f755b9 100644 --- a/tests/tests/src/ffi_test.res +++ b/tests/tests/src/ffi_test.res @@ -1,9 +1,9 @@ @val external f: int => int = "xx" let u = () => f(3) -let v = Js.Null.empty +let v = Nullable.null -let (a, b, c, d) = (true, false, Js.Null.empty, Js.Undefined.empty) +let (a, b, c, d) = (true, false, Nullable.null, Nullable.undefined) module Textarea = { type t diff --git a/tests/tests/src/float_test.mjs b/tests/tests/src/float_test.mjs index 6032efe6ade..1d3507e2bea 100644 --- a/tests/tests/src/float_test.mjs +++ b/tests/tests/src/float_test.mjs @@ -3,6 +3,7 @@ import * as Mocha from "mocha"; import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; import * as Test_utils from "./test_utils.mjs"; +import * as Stdlib_Float from "@rescript/runtime/lib/es6/Stdlib_Float.mjs"; import * as Primitive_float from "@rescript/runtime/lib/es6/Primitive_float.mjs"; import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.mjs"; @@ -46,10 +47,12 @@ function float_greaterequal(x, y) { let generic_greaterequal = Primitive_object.greaterequal; +let nan = NaN; + Mocha.describe("Float_test", () => { Mocha.test("float_test_1", () => { - Test_utils.eq("File \"float_test.res\", line 21, characters 7-14", Pervasives.classify_float(3), "FP_normal"); - Test_utils.eq("File \"float_test.res\", line 23, characters 6-13", [ + Test_utils.eq("File \"float_test.res\", line 22, characters 7-14", Pervasives.classify_float(3), "FP_normal"); + Test_utils.eq("File \"float_test.res\", line 24, characters 6-13", [ -1, 1, 1 @@ -75,50 +78,50 @@ Mocha.describe("Float_test", () => { return 0; } })); - Test_utils.eq("File \"float_test.res\", line 38, characters 7-14", Math.log10(10), 1); - Test_utils.eq("File \"float_test.res\", line 39, characters 7-14", Number("3.0"), 3.0); - Test_utils.eq("File \"float_test.res\", line 40, characters 7-14", Primitive_float.compare(NaN, NaN), 0); - Test_utils.eq("File \"float_test.res\", line 41, characters 7-14", Primitive_object.compare(NaN, NaN), 0); - Test_utils.eq("File \"float_test.res\", line 42, characters 7-14", Primitive_float.compare(NaN, Pervasives.neg_infinity), -1); - Test_utils.eq("File \"float_test.res\", line 43, characters 7-14", Primitive_object.compare(NaN, Pervasives.neg_infinity), -1); - Test_utils.eq("File \"float_test.res\", line 44, characters 7-14", Primitive_float.compare(Pervasives.neg_infinity, NaN), 1); - Test_utils.eq("File \"float_test.res\", line 45, characters 7-14", Primitive_object.compare(Pervasives.neg_infinity, NaN), 1); - Test_utils.eq("File \"float_test.res\", line 46, characters 7-14", NaN === NaN, false); - Test_utils.eq("File \"float_test.res\", line 47, characters 7-14", Primitive_object.equal(NaN, NaN), false); - Test_utils.eq("File \"float_test.res\", line 48, characters 7-14", 4.2 === NaN, false); - Test_utils.eq("File \"float_test.res\", line 49, characters 7-14", Primitive_object.equal(4.2, NaN), false); - Test_utils.eq("File \"float_test.res\", line 50, characters 7-14", NaN === 4.2, false); - Test_utils.eq("File \"float_test.res\", line 51, characters 7-14", Primitive_object.equal(NaN, 4.2), false); - Test_utils.eq("File \"float_test.res\", line 52, characters 7-14", NaN !== NaN, true); - Test_utils.eq("File \"float_test.res\", line 53, characters 7-14", Primitive_object.notequal(NaN, NaN), true); - Test_utils.eq("File \"float_test.res\", line 54, characters 7-14", 4.2 !== NaN, true); - Test_utils.eq("File \"float_test.res\", line 55, characters 7-14", Primitive_object.notequal(4.2, NaN), true); - Test_utils.eq("File \"float_test.res\", line 56, characters 7-14", NaN !== 4.2, true); - Test_utils.eq("File \"float_test.res\", line 57, characters 7-14", Primitive_object.notequal(NaN, 4.2), true); - Test_utils.eq("File \"float_test.res\", line 58, characters 7-14", NaN < NaN, false); - Test_utils.eq("File \"float_test.res\", line 59, characters 7-14", Primitive_object.lessthan(NaN, NaN), false); - Test_utils.eq("File \"float_test.res\", line 60, characters 7-14", 4.2 < NaN, false); - Test_utils.eq("File \"float_test.res\", line 61, characters 7-14", Primitive_object.lessthan(4.2, NaN), false); - Test_utils.eq("File \"float_test.res\", line 62, characters 7-14", NaN < 4.2, false); - Test_utils.eq("File \"float_test.res\", line 63, characters 7-14", Primitive_object.lessthan(NaN, 4.2), false); - Test_utils.eq("File \"float_test.res\", line 64, characters 7-14", NaN > NaN, false); - Test_utils.eq("File \"float_test.res\", line 65, characters 7-14", Primitive_object.greaterthan(NaN, NaN), false); - Test_utils.eq("File \"float_test.res\", line 66, characters 7-14", 4.2 > NaN, false); - Test_utils.eq("File \"float_test.res\", line 67, characters 7-14", Primitive_object.greaterthan(4.2, NaN), false); - Test_utils.eq("File \"float_test.res\", line 68, characters 7-14", NaN > 4.2, false); - Test_utils.eq("File \"float_test.res\", line 69, characters 7-14", Primitive_object.greaterthan(NaN, 4.2), false); - Test_utils.eq("File \"float_test.res\", line 70, characters 7-14", NaN <= NaN, false); - Test_utils.eq("File \"float_test.res\", line 71, characters 7-14", Primitive_object.lessequal(NaN, NaN), false); - Test_utils.eq("File \"float_test.res\", line 72, characters 7-14", Primitive_object.lessequal(4.2, NaN), false); - Test_utils.eq("File \"float_test.res\", line 73, characters 7-14", Primitive_object.lessequal(4.2, NaN), false); - Test_utils.eq("File \"float_test.res\", line 74, characters 7-14", Primitive_object.lessequal(NaN, 4.2), false); - Test_utils.eq("File \"float_test.res\", line 75, characters 7-14", Primitive_object.lessequal(NaN, 4.2), false); - Test_utils.eq("File \"float_test.res\", line 76, characters 7-14", NaN >= NaN, false); - Test_utils.eq("File \"float_test.res\", line 77, characters 7-14", Primitive_object.greaterequal(NaN, NaN), false); - Test_utils.eq("File \"float_test.res\", line 78, characters 7-14", 4.2 >= NaN, false); - Test_utils.eq("File \"float_test.res\", line 79, characters 7-14", Primitive_object.greaterequal(4.2, NaN), false); - Test_utils.eq("File \"float_test.res\", line 80, characters 7-14", NaN >= 4.2, false); - Test_utils.eq("File \"float_test.res\", line 81, characters 7-14", Primitive_object.greaterequal(NaN, 4.2), false); + Test_utils.eq("File \"float_test.res\", line 39, characters 7-14", Math.log10(10), 1); + Test_utils.eq("File \"float_test.res\", line 40, characters 7-14", Stdlib_Float.fromString("3.0"), 3.0); + Test_utils.eq("File \"float_test.res\", line 41, characters 7-14", Primitive_float.compare(nan, nan), 0); + Test_utils.eq("File \"float_test.res\", line 42, characters 7-14", Primitive_object.compare(nan, nan), 0); + Test_utils.eq("File \"float_test.res\", line 43, characters 7-14", Primitive_float.compare(nan, Pervasives.neg_infinity), -1); + Test_utils.eq("File \"float_test.res\", line 44, characters 7-14", Primitive_object.compare(nan, Pervasives.neg_infinity), -1); + Test_utils.eq("File \"float_test.res\", line 45, characters 7-14", Primitive_float.compare(Pervasives.neg_infinity, nan), 1); + Test_utils.eq("File \"float_test.res\", line 46, characters 7-14", Primitive_object.compare(Pervasives.neg_infinity, nan), 1); + Test_utils.eq("File \"float_test.res\", line 47, characters 7-14", nan === nan, false); + Test_utils.eq("File \"float_test.res\", line 48, characters 7-14", Primitive_object.equal(nan, nan), false); + Test_utils.eq("File \"float_test.res\", line 49, characters 7-14", 4.2 === nan, false); + Test_utils.eq("File \"float_test.res\", line 50, characters 7-14", Primitive_object.equal(4.2, nan), false); + Test_utils.eq("File \"float_test.res\", line 51, characters 7-14", nan === 4.2, false); + Test_utils.eq("File \"float_test.res\", line 52, characters 7-14", Primitive_object.equal(nan, 4.2), false); + Test_utils.eq("File \"float_test.res\", line 53, characters 7-14", nan !== nan, true); + Test_utils.eq("File \"float_test.res\", line 54, characters 7-14", Primitive_object.notequal(nan, nan), true); + Test_utils.eq("File \"float_test.res\", line 55, characters 7-14", 4.2 !== nan, true); + Test_utils.eq("File \"float_test.res\", line 56, characters 7-14", Primitive_object.notequal(4.2, nan), true); + Test_utils.eq("File \"float_test.res\", line 57, characters 7-14", nan !== 4.2, true); + Test_utils.eq("File \"float_test.res\", line 58, characters 7-14", Primitive_object.notequal(nan, 4.2), true); + Test_utils.eq("File \"float_test.res\", line 59, characters 7-14", nan < nan, false); + Test_utils.eq("File \"float_test.res\", line 60, characters 7-14", Primitive_object.lessthan(nan, nan), false); + Test_utils.eq("File \"float_test.res\", line 61, characters 7-14", 4.2 < nan, false); + Test_utils.eq("File \"float_test.res\", line 62, characters 7-14", Primitive_object.lessthan(4.2, nan), false); + Test_utils.eq("File \"float_test.res\", line 63, characters 7-14", nan < 4.2, false); + Test_utils.eq("File \"float_test.res\", line 64, characters 7-14", Primitive_object.lessthan(nan, 4.2), false); + Test_utils.eq("File \"float_test.res\", line 65, characters 7-14", nan > nan, false); + Test_utils.eq("File \"float_test.res\", line 66, characters 7-14", Primitive_object.greaterthan(nan, nan), false); + Test_utils.eq("File \"float_test.res\", line 67, characters 7-14", 4.2 > nan, false); + Test_utils.eq("File \"float_test.res\", line 68, characters 7-14", Primitive_object.greaterthan(4.2, nan), false); + Test_utils.eq("File \"float_test.res\", line 69, characters 7-14", nan > 4.2, false); + Test_utils.eq("File \"float_test.res\", line 70, characters 7-14", Primitive_object.greaterthan(nan, 4.2), false); + Test_utils.eq("File \"float_test.res\", line 71, characters 7-14", nan <= nan, false); + Test_utils.eq("File \"float_test.res\", line 72, characters 7-14", Primitive_object.lessequal(nan, nan), false); + Test_utils.eq("File \"float_test.res\", line 73, characters 7-14", Primitive_object.lessequal(4.2, nan), false); + Test_utils.eq("File \"float_test.res\", line 74, characters 7-14", Primitive_object.lessequal(4.2, nan), false); + Test_utils.eq("File \"float_test.res\", line 75, characters 7-14", Primitive_object.lessequal(nan, 4.2), false); + Test_utils.eq("File \"float_test.res\", line 76, characters 7-14", Primitive_object.lessequal(nan, 4.2), false); + Test_utils.eq("File \"float_test.res\", line 77, characters 7-14", nan >= nan, false); + Test_utils.eq("File \"float_test.res\", line 78, characters 7-14", Primitive_object.greaterequal(nan, nan), false); + Test_utils.eq("File \"float_test.res\", line 79, characters 7-14", 4.2 >= nan, false); + Test_utils.eq("File \"float_test.res\", line 80, characters 7-14", Primitive_object.greaterequal(4.2, nan), false); + Test_utils.eq("File \"float_test.res\", line 81, characters 7-14", nan >= 4.2, false); + Test_utils.eq("File \"float_test.res\", line 82, characters 7-14", Primitive_object.greaterequal(nan, 4.2), false); }); }); @@ -137,5 +140,6 @@ export { generic_lessequal, float_greaterequal, generic_greaterequal, + nan, } -/* Not a pure module */ +/* nan Not a pure module */ diff --git a/tests/tests/src/float_test.res b/tests/tests/src/float_test.res index 6d7b60afbf4..3f1ce3118a1 100644 --- a/tests/tests/src/float_test.res +++ b/tests/tests/src/float_test.res @@ -15,6 +15,7 @@ let float_lessequal = (x: float, y) => x <= y let generic_lessequal = (a, b) => a <= b let float_greaterequal = (x: float, y) => x >= y let generic_greaterequal = (a, b) => a >= b +let nan = Float.Constants.nan describe(__MODULE__, () => { test("float_test_1", () => { @@ -36,48 +37,48 @@ describe(__MODULE__, () => { ), ) eq(__LOC__, log10(10.), 1.) - eq(__LOC__, Js.Float.fromString("3.0"), 3.0) - eq(__LOC__, float_compare(Js.Float._NaN, Js.Float._NaN), 0) - eq(__LOC__, generic_compare(Js.Float._NaN, Js.Float._NaN), 0) - eq(__LOC__, float_compare(Js.Float._NaN, neg_infinity), -1) - eq(__LOC__, generic_compare(Js.Float._NaN, neg_infinity), -1) - eq(__LOC__, float_compare(neg_infinity, Js.Float._NaN), 1) - eq(__LOC__, generic_compare(neg_infinity, Js.Float._NaN), 1) - eq(__LOC__, float_equal(Js.Float._NaN, Js.Float._NaN), false) - eq(__LOC__, generic_equal(Js.Float._NaN, Js.Float._NaN), false) - eq(__LOC__, float_equal(4.2, Js.Float._NaN), false) - eq(__LOC__, generic_equal(4.2, Js.Float._NaN), false) - eq(__LOC__, float_equal(Js.Float._NaN, 4.2), false) - eq(__LOC__, generic_equal(Js.Float._NaN, 4.2), false) - eq(__LOC__, float_notequal(Js.Float._NaN, Js.Float._NaN), true) - eq(__LOC__, generic_notequal(Js.Float._NaN, Js.Float._NaN), true) - eq(__LOC__, float_notequal(4.2, Js.Float._NaN), true) - eq(__LOC__, generic_notequal(4.2, Js.Float._NaN), true) - eq(__LOC__, float_notequal(Js.Float._NaN, 4.2), true) - eq(__LOC__, generic_notequal(Js.Float._NaN, 4.2), true) - eq(__LOC__, float_lessthan(Js.Float._NaN, Js.Float._NaN), false) - eq(__LOC__, generic_lessthan(Js.Float._NaN, Js.Float._NaN), false) - eq(__LOC__, float_lessthan(4.2, Js.Float._NaN), false) - eq(__LOC__, generic_lessthan(4.2, Js.Float._NaN), false) - eq(__LOC__, float_lessthan(Js.Float._NaN, 4.2), false) - eq(__LOC__, generic_lessthan(Js.Float._NaN, 4.2), false) - eq(__LOC__, float_greaterthan(Js.Float._NaN, Js.Float._NaN), false) - eq(__LOC__, generic_greaterthan(Js.Float._NaN, Js.Float._NaN), false) - eq(__LOC__, float_greaterthan(4.2, Js.Float._NaN), false) - eq(__LOC__, generic_greaterthan(4.2, Js.Float._NaN), false) - eq(__LOC__, float_greaterthan(Js.Float._NaN, 4.2), false) - eq(__LOC__, generic_greaterthan(Js.Float._NaN, 4.2), false) - eq(__LOC__, float_lessequal(Js.Float._NaN, Js.Float._NaN), false) - eq(__LOC__, generic_lessequal(Js.Float._NaN, Js.Float._NaN), false) - eq(__LOC__, generic_lessequal(4.2, Js.Float._NaN), false) - eq(__LOC__, generic_lessequal(4.2, Js.Float._NaN), false) - eq(__LOC__, generic_lessequal(Js.Float._NaN, 4.2), false) - eq(__LOC__, generic_lessequal(Js.Float._NaN, 4.2), false) - eq(__LOC__, float_greaterequal(Js.Float._NaN, Js.Float._NaN), false) - eq(__LOC__, generic_greaterequal(Js.Float._NaN, Js.Float._NaN), false) - eq(__LOC__, float_greaterequal(4.2, Js.Float._NaN), false) - eq(__LOC__, generic_greaterequal(4.2, Js.Float._NaN), false) - eq(__LOC__, float_greaterequal(Js.Float._NaN, 4.2), false) - eq(__LOC__, generic_greaterequal(Js.Float._NaN, 4.2), false) + eq(__LOC__, Float.fromString("3.0"), Some(3.0)) + eq(__LOC__, float_compare(nan, nan), 0) + eq(__LOC__, generic_compare(nan, nan), 0) + eq(__LOC__, float_compare(nan, neg_infinity), -1) + eq(__LOC__, generic_compare(nan, neg_infinity), -1) + eq(__LOC__, float_compare(neg_infinity, nan), 1) + eq(__LOC__, generic_compare(neg_infinity, nan), 1) + eq(__LOC__, float_equal(nan, nan), false) + eq(__LOC__, generic_equal(nan, nan), false) + eq(__LOC__, float_equal(4.2, nan), false) + eq(__LOC__, generic_equal(4.2, nan), false) + eq(__LOC__, float_equal(nan, 4.2), false) + eq(__LOC__, generic_equal(nan, 4.2), false) + eq(__LOC__, float_notequal(nan, nan), true) + eq(__LOC__, generic_notequal(nan, nan), true) + eq(__LOC__, float_notequal(4.2, nan), true) + eq(__LOC__, generic_notequal(4.2, nan), true) + eq(__LOC__, float_notequal(nan, 4.2), true) + eq(__LOC__, generic_notequal(nan, 4.2), true) + eq(__LOC__, float_lessthan(nan, nan), false) + eq(__LOC__, generic_lessthan(nan, nan), false) + eq(__LOC__, float_lessthan(4.2, nan), false) + eq(__LOC__, generic_lessthan(4.2, nan), false) + eq(__LOC__, float_lessthan(nan, 4.2), false) + eq(__LOC__, generic_lessthan(nan, 4.2), false) + eq(__LOC__, float_greaterthan(nan, nan), false) + eq(__LOC__, generic_greaterthan(nan, nan), false) + eq(__LOC__, float_greaterthan(4.2, nan), false) + eq(__LOC__, generic_greaterthan(4.2, nan), false) + eq(__LOC__, float_greaterthan(nan, 4.2), false) + eq(__LOC__, generic_greaterthan(nan, 4.2), false) + eq(__LOC__, float_lessequal(nan, nan), false) + eq(__LOC__, generic_lessequal(nan, nan), false) + eq(__LOC__, generic_lessequal(4.2, nan), false) + eq(__LOC__, generic_lessequal(4.2, nan), false) + eq(__LOC__, generic_lessequal(nan, 4.2), false) + eq(__LOC__, generic_lessequal(nan, 4.2), false) + eq(__LOC__, float_greaterequal(nan, nan), false) + eq(__LOC__, generic_greaterequal(nan, nan), false) + eq(__LOC__, float_greaterequal(4.2, nan), false) + eq(__LOC__, generic_greaterequal(4.2, nan), false) + eq(__LOC__, float_greaterequal(nan, 4.2), false) + eq(__LOC__, generic_greaterequal(nan, 4.2), false) }) }) diff --git a/tests/tests/src/functor_ffi.mjs b/tests/tests/src/functor_ffi.mjs index 927624ebff0..cfa058ebaa0 100644 --- a/tests/tests/src/functor_ffi.mjs +++ b/tests/tests/src/functor_ffi.mjs @@ -1,16 +1,15 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Js_undefined from "@rescript/runtime/lib/es6/Js_undefined.mjs"; function Make(S) { - let opt_get = (f, i) => Js_undefined.toOption(f[i]); + let opt_get = (prim0, prim1) => prim0[prim1]; return { opt_get: opt_get }; } -function opt_get(f, i) { - return Js_undefined.toOption(f[i]); +function opt_get(prim0, prim1) { + return prim0[prim1]; } let Int_arr = { @@ -20,7 +19,7 @@ let Int_arr = { function f(v) { return [ v[0], - Js_undefined.toOption(v[1]) + v[1] ]; } diff --git a/tests/tests/src/functor_ffi.res b/tests/tests/src/functor_ffi.res index 8dd7920ef34..f815b85d333 100644 --- a/tests/tests/src/functor_ffi.res +++ b/tests/tests/src/functor_ffi.res @@ -7,9 +7,9 @@ module Make = ( type t<'a> @get_index external unsafe_get: (t, int) => elt = "" - @get_index external get: (t, int) => Js.undefined = "" + @get_index external get: (t, int) => option = "" - let opt_get = (f, i) => Js.Undefined.toOption(get(f, i)) + let opt_get = get } module Int_arr = Make({ diff --git a/tests/tests/src/gpr_1072.mjs b/tests/tests/src/gpr_1072.mjs index eb649571723..53f2ade46fc 100644 --- a/tests/tests/src/gpr_1072.mjs +++ b/tests/tests/src/gpr_1072.mjs @@ -153,23 +153,23 @@ let side_effect = { contents: 0 }; -again4(undefined, undefined, 141); +again4(undefined, undefined, 149); -again4(undefined, undefined, 142); +again4(undefined, undefined, 150); -again4(undefined, undefined, 143); +again4(undefined, undefined, 151); -again4(undefined, undefined, 144); +again4(undefined, undefined, 152); -again4(undefined, undefined, 145); +again4(undefined, undefined, 153); -again4((side_effect.contents = side_effect.contents + 1 | 0, undefined), undefined, 152); +again4((side_effect.contents = side_effect.contents + 1 | 0, undefined), undefined, 160); -again4((side_effect.contents = side_effect.contents + 1 | 0, undefined), (side_effect.contents = side_effect.contents - 1 | 0, undefined), 164); +again4((side_effect.contents = side_effect.contents + 1 | 0, undefined), (side_effect.contents = side_effect.contents - 1 | 0, undefined), 172); -again4(undefined, (side_effect.contents = side_effect.contents - 1 | 0, undefined), 172); +again4(undefined, (side_effect.contents = side_effect.contents - 1 | 0, undefined), 180); -again4((side_effect.contents = side_effect.contents + 1 | 0, undefined), undefined, 175); +again4((side_effect.contents = side_effect.contents + 1 | 0, undefined), undefined, 183); export { u, diff --git a/tests/tests/src/gpr_1072.res b/tests/tests/src/gpr_1072.res index 43f67e00c61..e77023ee9ca 100644 --- a/tests/tests/src/gpr_1072.res +++ b/tests/tests/src/gpr_1072.res @@ -20,15 +20,19 @@ external ice_cream_2: let my_scoop2 = ice_cream_2 ~flavor:`vanilla ~num:3 () */ -type opt_test = {"x": Js.Undefined.t, "y": Js.Undefined.t} -@obj external opt_test: (~x: int=?, ~y: int=?, unit) => _ = "" +type opt_test = {"x": option, "y": option} +@obj external opt_test: (~x: int=?, ~y: int=?, unit) => opt_test = "" let u: opt_test = opt_test(~y=3, ()) +type ice_cream3_expect = {"flavor": option, "num": int} + @obj -external ice_cream3: (~flavor: @string [#vanilla | @as("x") #chocolate]=?, ~num: int, unit) => _ = - "" /* TODO: warn when [_] happens in any place except `obj` */ -type ice_cream3_expect = {"flavor": Js.undefined, "num": int} +external ice_cream3: ( + ~flavor: @string [#vanilla | @as("x") #chocolate]=?, + ~num: int, + unit, +) => ice_cream3_expect = "" /* TODO: warn when [_] happens in any place except `obj` */ let v_ice_cream3: list = list{ ice_cream3(~flavor=#vanilla, ~num=3, ()), @@ -60,13 +64,13 @@ type int_expect = {"x__ignore": int} let int_expect: int_expect = int_test(~x__ignore=#a, ()) -@obj external int_test2: (~x__ignore: @int [#a | #b]=?, unit) => _ = "" +type int_expect2 = {"x__ignore": option} -type int_expect2 = {"x__ignore": Js.Undefined.t} +@obj external int_test2: (~x__ignore: @int [#a | #b]=?, unit) => int_expect2 = "" let int_expect2: int_expect2 = int_test2(~x__ignore=#a, ()) -@obj external int_test3: (~x__ignore: @int [@as(2) #a | #b]=?, unit) => _ = "" +@obj external int_test3: (~x__ignore: @int [@as(2) #a | #b]=?, unit) => int_expect2 = "" let int_expects: list = list{ int_test3(), @@ -79,11 +83,13 @@ type flavor = [#vanilla | #chocolate] let mk_ice: {"flavour": flavor, "num": int} = ice(~flavour=#vanilla, ~num=3, ()) -@obj external ice2: (~flavour: flavor=?, ~num: int, unit) => _ = "" +type ice2_expect = {"flavour": option, "num": int} + +@obj external ice2: (~flavour: flavor=?, ~num: int, unit) => ice2_expect = "" -let my_ice2: {"flavour": Js.Undefined.t, "num": int} = ice2(~flavour=#vanilla, ~num=1, ()) +let my_ice2: ice2_expect = ice2(~flavour=#vanilla, ~num=1, ()) -let my_ice3: {"flavour": Js.Undefined.t, "num": int} = ice2(~num=2, ()) +let my_ice3: ice2_expect = ice2(~num=2, ()) @obj external mk4: (~x__ignore: @ignore [#a | #b], ~y: int, unit) => _ = "" @@ -93,16 +99,18 @@ let v_mk4: {"y": int} = mk4(~x__ignore=#a, ~y=3, ()) let v_mk5: {"x": unit, "y": int} = mk5(~x=(), ~y=3, ()) -@obj external mk6: (~x: unit=?, ~y: int, unit) => _ = "" +type mk6_expect = {"x": option, "y": int} + +@obj external mk6: (~x: unit=?, ~y: int, unit) => mk6_expect = "" -let v_mk6: {"x": Js.Undefined.t, "y": int} = mk6(~y=3, ()) +let v_mk6: mk6_expect = mk6(~y=3, ()) let v_mk6_1 = mk6(~x=(), ~y=3, ()) type mk -@obj external mk: (~x__ignore: @int [#a | #b]=?, unit) => _ = "" +@obj external mk: (~x__ignore: @int [#a | #b]=?, unit) => int_expect2 = "" /* TODO: fix me */ -let mk_u: {"x__ignore": Js.Undefined.t} = mk(~x__ignore=#a, ()) +let mk_u: int_expect2 = mk(~x__ignore=#a, ()) @obj external mk7: (~x: @ignore [#a | #b]=?, ~y: int, unit) => _ = "" diff --git a/tests/tests/src/gpr_1245_test.res b/tests/tests/src/gpr_1245_test.res index 1f34e383b76..54b6fb8128e 100644 --- a/tests/tests/src/gpr_1245_test.res +++ b/tests/tests/src/gpr_1245_test.res @@ -16,7 +16,7 @@ let f = ((c, d)) => { such block. It is more general than - [Js.Null.toOption] + [Null.toOption] since its box number is one and immutable, so we can give it a meaningful name for such slot @@ -32,7 +32,7 @@ let g = () => { } let a0 = f => { - let u = Js.Null.toOption(f()) + let u = Null.toOption(f()) switch u { | None => 0 | Some(x) => diff --git a/tests/tests/src/gpr_1409_test.mjs b/tests/tests/src/gpr_1409_test.mjs index 3815fca77a9..c91dfb9a4bd 100644 --- a/tests/tests/src/gpr_1409_test.mjs +++ b/tests/tests/src/gpr_1409_test.mjs @@ -20,7 +20,7 @@ function map(f, x) { function make(foo, param) { let tmp = {}; - let tmp$1 = map(prim => prim.toString(), foo); + let tmp$1 = map(prim => String(prim), foo); if (tmp$1 !== undefined) { tmp.foo = tmp$1; } @@ -31,13 +31,13 @@ let a_ = make(undefined, undefined); let b_ = make(42, undefined); -Test_utils.eq("File \"gpr_1409_test.res\", line 22, characters 3-10", b_.foo, "42"); +Test_utils.eq("File \"gpr_1409_test.res\", line 24, characters 3-10", b_.foo, "42"); console.log(Object.keys(a_)); console.log(a, b, a_, b_); -Test_utils.eq("File \"gpr_1409_test.res\", line 27, characters 3-10", Object.keys(a_).length, 0); +Test_utils.eq("File \"gpr_1409_test.res\", line 29, characters 3-10", Object.keys(a_).length, 0); let test2 = { hi: 2 @@ -107,12 +107,12 @@ function keys(xs, ys) { return String_set.equal(String_set.of_list(xs), String_set.of_list(Belt_List.fromArray(ys))); } -Test_utils.eq("File \"gpr_1409_test.res\", line 65, characters 3-10", keys({ +Test_utils.eq("File \"gpr_1409_test.res\", line 67, characters 3-10", keys({ hd: "hi", tl: /* [] */0 }, Object.keys(test3(undefined, undefined))), true); -Test_utils.eq("File \"gpr_1409_test.res\", line 67, characters 3-10", keys({ +Test_utils.eq("File \"gpr_1409_test.res\", line 69, characters 3-10", keys({ hd: "hi", tl: { hd: "_open", @@ -120,7 +120,7 @@ Test_utils.eq("File \"gpr_1409_test.res\", line 67, characters 3-10", keys({ } }, Object.keys(test3(2, undefined))), true); -Test_utils.eq("File \"gpr_1409_test.res\", line 69, characters 3-10", keys({ +Test_utils.eq("File \"gpr_1409_test.res\", line 71, characters 3-10", keys({ hd: "hi", tl: { hd: "_open", @@ -132,20 +132,20 @@ Test_utils.eq("File \"gpr_1409_test.res\", line 69, characters 3-10", keys({ }, Object.keys(test3(2, 2))), true); Mocha.describe("Gpr_1409_test", () => { - Mocha.test("test1", () => Test_utils.eq("File \"gpr_1409_test.res\", line 73, characters 7-14", b_.foo, "42")); - Mocha.test("test2", () => Test_utils.eq("File \"gpr_1409_test.res\", line 77, characters 7-14", Object.keys(a_).length, 0)); - Mocha.test("test3", () => Test_utils.eq("File \"gpr_1409_test.res\", line 81, characters 7-14", keys({ + Mocha.test("test1", () => Test_utils.eq("File \"gpr_1409_test.res\", line 75, characters 7-14", b_.foo, "42")); + Mocha.test("test2", () => Test_utils.eq("File \"gpr_1409_test.res\", line 79, characters 7-14", Object.keys(a_).length, 0)); + Mocha.test("test3", () => Test_utils.eq("File \"gpr_1409_test.res\", line 83, characters 7-14", keys({ hd: "hi", tl: /* [] */0 }, Object.keys(test3(undefined, undefined))), true)); - Mocha.test("test4", () => Test_utils.eq("File \"gpr_1409_test.res\", line 85, characters 7-14", keys({ + Mocha.test("test4", () => Test_utils.eq("File \"gpr_1409_test.res\", line 87, characters 7-14", keys({ hd: "hi", tl: { hd: "_open", tl: /* [] */0 } }, Object.keys(test3(2, undefined))), true)); - Mocha.test("test5", () => Test_utils.eq("File \"gpr_1409_test.res\", line 89, characters 7-14", keys({ + Mocha.test("test5", () => Test_utils.eq("File \"gpr_1409_test.res\", line 92, characters 6-13", keys({ hd: "hi", tl: { hd: "_open", diff --git a/tests/tests/src/gpr_1409_test.res b/tests/tests/src/gpr_1409_test.res index a21727b1a71..758ac8ad5ac 100644 --- a/tests/tests/src/gpr_1409_test.res +++ b/tests/tests/src/gpr_1409_test.res @@ -3,7 +3,9 @@ open Test_utils open Belt /* type t */ -@obj external make: (~foo: string=?, unit) => _ = "" +@get external foo: {..} => option = "foo" + +@obj external make: (~foo: string=?, unit) => {..} = "" let a = make() let b = make(~foo="42", ()) @@ -14,17 +16,17 @@ let map = (f, x) => | Some(x) => Some(f(x)) } -let make = (~foo: option=?, ()) => make(~foo=?map(Js.Int.toString, foo), ()) +let make = (~foo: option=?, ()) => make(~foo=?map(Int.toString, foo), ()) let a_ = make() let b_ = make(~foo=42, ()) -eq(__LOC__, b_["foo"], Js.Undefined.return("42")) +eq(__LOC__, b_->foo, Some("42")) -Console.log(Js.Obj.keys(a_)) +Console.log(Object.keysToArray(a_)) Console.log4(a, b, a_, b_) -eq(__LOC__, Array.length(Js.Obj.keys(a_)), 0) +eq(__LOC__, Array.length(Object.keysToArray(a_)), 0) @obj external mangle: (~_open: int=?, ~xx__hi: int=?, ~hi: int, unit) => _ = "" @@ -62,30 +64,34 @@ let test6 = (f, x) => { let keys = (xs, ys) => String_set.equal(String_set.of_list(xs), String_set.of_list(List.fromArray(ys))) -eq(__LOC__, keys(list{"hi"}, Js.Obj.keys(test3(None, None))), true) +eq(__LOC__, keys(list{"hi"}, Object.keysToArray(test3(None, None))), true) -eq(__LOC__, keys(list{"hi", "_open"}, Js.Obj.keys(test3(Some(2), None))), true) +eq(__LOC__, keys(list{"hi", "_open"}, Object.keysToArray(test3(Some(2), None))), true) -eq(__LOC__, keys(list{"hi", "_open", "xx__hi"}, Js.Obj.keys(test3(Some(2), Some(2)))), true) +eq(__LOC__, keys(list{"hi", "_open", "xx__hi"}, Object.keysToArray(test3(Some(2), Some(2)))), true) describe(__MODULE__, () => { test("test1", () => { - eq(__LOC__, b_["foo"], Js.Undefined.return("42")) + eq(__LOC__, b_->foo, Some("42")) }) test("test2", () => { - eq(__LOC__, Array.length(Js.Obj.keys(a_)), 0) + eq(__LOC__, Array.length(Object.keysToArray(a_)), 0) }) test("test3", () => { - eq(__LOC__, keys(list{"hi"}, Js.Obj.keys(test3(None, None))), true) + eq(__LOC__, keys(list{"hi"}, Object.keysToArray(test3(None, None))), true) }) test("test4", () => { - eq(__LOC__, keys(list{"hi", "_open"}, Js.Obj.keys(test3(Some(2), None))), true) + eq(__LOC__, keys(list{"hi", "_open"}, Object.keysToArray(test3(Some(2), None))), true) }) test("test5", () => { - eq(__LOC__, keys(list{"hi", "_open", "xx__hi"}, Js.Obj.keys(test3(Some(2), Some(2)))), true) + eq( + __LOC__, + keys(list{"hi", "_open", "xx__hi"}, Object.keysToArray(test3(Some(2), Some(2)))), + true, + ) }) }) diff --git a/tests/tests/src/gpr_1658_test.mjs b/tests/tests/src/gpr_1658_test.mjs index c5739c520b2..335b8045b2e 100644 --- a/tests/tests/src/gpr_1658_test.mjs +++ b/tests/tests/src/gpr_1658_test.mjs @@ -1,19 +1,22 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Mocha from "mocha"; -import * as Js_types from "@rescript/runtime/lib/es6/Js_types.mjs"; import * as Test_utils from "./test_utils.mjs"; +import * as Stdlib_Type from "@rescript/runtime/lib/es6/Stdlib_Type.mjs"; Mocha.describe("File \"gpr_1658_test.res\", line 4, characters 9-16", () => { Mocha.test("JS Null operations", () => { Test_utils.eq("File \"gpr_1658_test.res\", line 6, characters 7-14", null, null); - let match = Js_types.classify(null); - if (typeof match !== "object" && match === "JSNull") { - Test_utils.eq("File \"gpr_1658_test.res\", line 8, characters 19-26", true, true); + let match = Stdlib_Type.Classify.classify(null); + if (typeof match !== "object" && match === "Null") { + Test_utils.eq("File \"gpr_1658_test.res\", line 8, characters 17-24", true, true); } else { Test_utils.eq("File \"gpr_1658_test.res\", line 9, characters 14-21", true, false); } - Test_utils.eq("File \"gpr_1658_test.res\", line 11, characters 7-14", true, Js_types.test(null, "Null")); + let match$1 = Stdlib_Type.Classify.classify(null); + let tmp; + tmp = typeof match$1 !== "object" ? match$1 === "Null" : false; + Test_utils.eq("File \"gpr_1658_test.res\", line 12, characters 6-13", true, tmp); }); }); diff --git a/tests/tests/src/gpr_1658_test.res b/tests/tests/src/gpr_1658_test.res index 43d4651b07b..8b0b19cb37f 100644 --- a/tests/tests/src/gpr_1658_test.res +++ b/tests/tests/src/gpr_1658_test.res @@ -3,11 +3,18 @@ open Test_utils describe(__LOC__, () => { test("JS Null operations", () => { - eq(__LOC__, Js.Null.empty, Js.Null.empty) - switch Js.Types.classify(Js.Null.empty) { - | JSNull => eq(__LOC__, true, true) + eq(__LOC__, Null.null, Null.null) + switch Null.null->Type.Classify.classify { + | Null => eq(__LOC__, true, true) | _ => eq(__LOC__, true, false) } - eq(__LOC__, true, Js.Types.test(Js.Null.empty, Null)) + eq( + __LOC__, + true, + switch Null.null->Type.Classify.classify { + | Null => true + | _ => false + }, + ) }) }) diff --git a/tests/tests/src/gpr_2503_test.mjs b/tests/tests/src/gpr_2503_test.mjs index efbf5b9adff..1506bf3d130 100644 --- a/tests/tests/src/gpr_2503_test.mjs +++ b/tests/tests/src/gpr_2503_test.mjs @@ -2,6 +2,7 @@ import * as Mocha from "mocha"; import * as Test_utils from "./test_utils.mjs"; +import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.mjs"; import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.mjs"; function makeWrapper(foo, param) { @@ -43,11 +44,11 @@ function makeWrapper4(foo, param) { Mocha.describe("Gpr_2503_test", () => { Mocha.test("gpr_2503 polymorphic variant optional parameter test", () => { - Test_utils.ok("File \"gpr_2503_test.res\", line 39, characters 7-14", "a" === makeWrapper3("a", undefined).foo); - Test_utils.ok("File \"gpr_2503_test.res\", line 40, characters 7-14", undefined === makeWrapper3(undefined, undefined).foo); - Test_utils.ok("File \"gpr_2503_test.res\", line 41, characters 7-14", "a" === makeWrapper4(1, undefined).foo); - Test_utils.ok("File \"gpr_2503_test.res\", line 42, characters 7-14", "b" === makeWrapper4(11, undefined).foo); - Test_utils.ok("File \"gpr_2503_test.res\", line 43, characters 7-14", undefined === makeWrapper4(111, undefined).foo); + Test_utils.ok("File \"gpr_2503_test.res\", line 41, characters 7-14", Primitive_object.equal(makeWrapper3("a", undefined).foo, "a")); + Test_utils.ok("File \"gpr_2503_test.res\", line 42, characters 7-14", makeWrapper3(undefined, undefined).foo === undefined); + Test_utils.ok("File \"gpr_2503_test.res\", line 43, characters 7-14", Primitive_object.equal(makeWrapper4(1, undefined).foo, "a")); + Test_utils.ok("File \"gpr_2503_test.res\", line 44, characters 7-14", Primitive_object.equal(makeWrapper4(11, undefined).foo, "b")); + Test_utils.ok("File \"gpr_2503_test.res\", line 45, characters 7-14", makeWrapper4(111, undefined).foo === undefined); }); }); diff --git a/tests/tests/src/gpr_2503_test.res b/tests/tests/src/gpr_2503_test.res index e870fd01f3e..6e97ec02236 100644 --- a/tests/tests/src/gpr_2503_test.res +++ b/tests/tests/src/gpr_2503_test.res @@ -3,17 +3,19 @@ open Test_utils /* TODO: */ -@obj external make: (~foo: [#a | #b]=?, unit) => _ = "" +@get external foo: {..} => option<[#a | #b]> = "foo" + +@obj external make: (~foo: [#a | #b]=?, unit) => {..} = "" let makeWrapper = (~foo=?, ()) => Console.log(make(~foo?, ())) -@obj external make2: (~foo: [#a | #b], unit) => _ = "" +@obj external make2: (~foo: [#a | #b], unit) => {..} = "" let makeWrapper2 = (foo, ()) => Console.log(make2(~foo, ())) let _ = makeWrapper2(#a, ()) -@obj external make3: (~foo: [#a | #b]=?, unit) => _ = "" +@obj external make3: (~foo: [#a | #b]=?, unit) => {..} = "" let makeWrapper3 = (~foo=?, ()) => { Console.log(2) @@ -36,10 +38,10 @@ let makeWrapper4 = (foo, ()) => { describe(__MODULE__, () => { test("gpr_2503 polymorphic variant optional parameter test", () => { - ok(__LOC__, Js.eqUndefined(#a, makeWrapper3(~foo=#a, ())["foo"])) - ok(__LOC__, Js.undefined == makeWrapper3()["foo"]) - ok(__LOC__, Js.eqUndefined(#a, makeWrapper4(1, ())["foo"])) - ok(__LOC__, Js.eqUndefined(#b, makeWrapper4(11, ())["foo"])) - ok(__LOC__, Js.undefined == makeWrapper4(111, ())["foo"]) + ok(__LOC__, makeWrapper3(~foo=#a, ())->foo == Some(#a)) + ok(__LOC__, makeWrapper3()->foo == None) + ok(__LOC__, makeWrapper4(1, ())->foo == Some(#a)) + ok(__LOC__, makeWrapper4(11, ())->foo == Some(#b)) + ok(__LOC__, makeWrapper4(111, ())->foo == None) }) }) diff --git a/tests/tests/src/gpr_3154_test.mjs b/tests/tests/src/gpr_3154_test.mjs index 8c69415bc12..bc02327291b 100644 --- a/tests/tests/src/gpr_3154_test.mjs +++ b/tests/tests/src/gpr_3154_test.mjs @@ -1,31 +1,34 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Mocha from "mocha"; -import * as Js_dict from "@rescript/runtime/lib/es6/Js_dict.mjs"; import * as Test_utils from "./test_utils.mjs"; import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.mjs"; +function get(dict, key) { + if (key in dict) { + return Primitive_option.some(dict[key]); + } +} + Mocha.describe("Gpr_3154_test", () => { - Mocha.test("Js.Dict None value handling", () => { + Mocha.test("Dict None value handling", () => { let d = {}; d["foo"] = undefined; - let match = Js_dict.get(d, "foo"); + let match = get(d, "foo"); if (match !== undefined && Primitive_option.valFromOption(match) === undefined) { - return Test_utils.ok("File \"gpr_3154_test.res\", line 11, characters 23-30", true); + return Test_utils.ok("File \"gpr_3154_test.res\", line 16, characters 23-30", true); } else { - return Test_utils.ok("File \"gpr_3154_test.res\", line 12, characters 14-21", false); + return Test_utils.ok("File \"gpr_3154_test.res\", line 17, characters 14-21", false); } }); - Mocha.test("Js.Dict get with None", () => { + Mocha.test("Dict get with None", () => { let d0 = {}; d0["foo"] = undefined; - Test_utils.eq("File \"gpr_3154_test.res\", line 19, characters 7-14", Js_dict.get(d0, "foo"), Primitive_option.some(undefined)); + Test_utils.eq("File \"gpr_3154_test.res\", line 24, characters 7-14", get(d0, "foo"), Primitive_option.some(undefined)); }); }); -let J; - export { - J, + get, } /* Not a pure module */ diff --git a/tests/tests/src/gpr_3154_test.res b/tests/tests/src/gpr_3154_test.res index bd745d36497..d03324b956f 100644 --- a/tests/tests/src/gpr_3154_test.res +++ b/tests/tests/src/gpr_3154_test.res @@ -1,21 +1,26 @@ open Mocha open Test_utils -module J = Js.Dict +let get = (dict, key) => + if Dict.has(dict, key) { + Some(Dict.getUnsafe(dict, key)) + } else { + None + } describe(__MODULE__, () => { - test("Js.Dict None value handling", () => { - let d = Js.Dict.empty() - J.set(d, "foo", None) - switch J.get(d, "foo") { + test("Dict None value handling", () => { + let d = Dict.make() + Dict.set(d, "foo", None) + switch get(d, "foo") { | Some(None) => ok(__LOC__, true) | _ => ok(__LOC__, false) } }) - test("Js.Dict get with None", () => { - let d0 = Js.Dict.empty() - J.set(d0, "foo", None) - eq(__LOC__, J.get(d0, "foo"), Some(None)) + test("Dict get with None", () => { + let d0 = Dict.make() + Dict.set(d0, "foo", None) + eq(__LOC__, get(d0, "foo"), Some(None)) }) }) diff --git a/tests/tests/src/gpr_3770_test.res b/tests/tests/src/gpr_3770_test.res index ed085bc046e..74566b0bfa8 100644 --- a/tests/tests/src/gpr_3770_test.res +++ b/tests/tests/src/gpr_3770_test.res @@ -3,5 +3,5 @@ type t = Foo(int, int, int) let show = x => switch x { | Foo(0, 0, 0) => "zeroes" - | Foo(a, b, _) => Js.Int.toString(a) ++ Js.Int.toString(b) + | Foo(a, b, _) => Int.toString(a) ++ Int.toString(b) } diff --git a/tests/tests/src/gpr_3895_test.res b/tests/tests/src/gpr_3895_test.res index 7c6c7c3f364..1bd9f1a9a40 100644 --- a/tests/tests/src/gpr_3895_test.res +++ b/tests/tests/src/gpr_3895_test.res @@ -1,4 +1,4 @@ let f = re => { - let _ = re->Js.Re.exec_("banana") + let _ = re->RegExp.exec("banana") 3 } diff --git a/tests/tests/src/gpr_3980_test.mjs b/tests/tests/src/gpr_3980_test.mjs index c7652c2d87c..38c5b374828 100644 --- a/tests/tests/src/gpr_3980_test.mjs +++ b/tests/tests/src/gpr_3980_test.mjs @@ -1,6 +1,6 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Js_math from "@rescript/runtime/lib/es6/Js_math.mjs"; +import * as Stdlib_Math from "@rescript/runtime/lib/es6/Stdlib_Math.mjs"; if (1 !== 1) { throw { @@ -28,7 +28,7 @@ if (match !== 1) { Error: new Error() }; } - Js_math.floor(1); + Stdlib_Math.Int.floor(1); } /* Not a pure module */ diff --git a/tests/tests/src/gpr_3980_test.res b/tests/tests/src/gpr_3980_test.res index 0e2e4b7c903..973e5ad93c2 100644 --- a/tests/tests/src/gpr_3980_test.res +++ b/tests/tests/src/gpr_3980_test.res @@ -8,7 +8,7 @@ let _ = switch Some(1) { | 1 => {name: "hi", age: 1} | 2 => { name: "bye", - age: Js.Math.floor(1.), + age: Math.Int.floor(1.), } | _ => assert(false) } diff --git a/tests/tests/src/gpr_4025_test.res b/tests/tests/src/gpr_4025_test.res index a45bb902d4b..eb07d236e0e 100644 --- a/tests/tests/src/gpr_4025_test.res +++ b/tests/tests/src/gpr_4025_test.res @@ -1,4 +1,4 @@ -()->Js.Dict.empty->Js.Dict.set("hi", "hello") +()->Dict.make->Dict.set("hi", "hello") type u = {mutable x: int} diff --git a/tests/tests/src/gpr_4069_test.res b/tests/tests/src/gpr_4069_test.res index 305c35e96dd..4e4d2105981 100644 --- a/tests/tests/src/gpr_4069_test.res +++ b/tests/tests/src/gpr_4069_test.res @@ -1,5 +1,5 @@ let f = value => - switch Js.Nullable.isNullable(value) { + switch Nullable.isNullable(value) { | false => Some((Obj.magic(value): string)) | true => None } diff --git a/tests/tests/src/gpr_4280_test.res b/tests/tests/src/gpr_4280_test.res index b0a473d7b8d..e52766c6bb2 100644 --- a/tests/tests/src/gpr_4280_test.res +++ b/tests/tests/src/gpr_4280_test.res @@ -18,7 +18,7 @@ let fn = (authState, route) => switch (authState, route) { | (#Unauthenticated, #Onboarding(onboardingRoute)) | (#Unverified(_), #Onboarding(onboardingRoute)) => - Js.Console.log(onboardingRoute) + Console.log(onboardingRoute) div(~children=list{string("Onboarding")}, ()) 0 | (#Unauthenticated, #SignIn) @@ -29,7 +29,7 @@ let fn = (authState, route) => 1 | (#Unverified(user), _) => - Js.Console.log(user) + Console.log(user) div(~children=list{string("VerifyEmail")}, ()) 2 | (#Unauthenticated, _) => diff --git a/tests/tests/src/gpr_974_test.mjs b/tests/tests/src/gpr_974_test.mjs index 581cd8d19e4..b530847c7a6 100644 --- a/tests/tests/src/gpr_974_test.mjs +++ b/tests/tests/src/gpr_974_test.mjs @@ -1,6 +1,5 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Js_undefined from "@rescript/runtime/lib/es6/Js_undefined.mjs"; import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.mjs"; import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.mjs"; @@ -16,24 +15,12 @@ if (!Primitive_object.equal(Primitive_option.fromNullable(""), "")) { }; } -if (!Primitive_object.equal(Js_undefined.toOption(""), "")) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "gpr_974_test.res", - 3, - 2 - ], - Error: new Error() - }; -} - if (!Primitive_object.equal(Primitive_option.fromNull(""), "")) { throw { RE_EXN_ID: "Assert_failure", _1: [ "gpr_974_test.res", - 4, + 3, 2 ], Error: new Error() diff --git a/tests/tests/src/gpr_974_test.res b/tests/tests/src/gpr_974_test.res index 70599869cd6..519bb4e053b 100644 --- a/tests/tests/src/gpr_974_test.res +++ b/tests/tests/src/gpr_974_test.res @@ -1,5 +1,4 @@ let _ = { - assert(Js.Null_undefined.toOption(Js.Null_undefined.return("")) == Some("")) - assert(Js.Undefined.toOption(Js.Undefined.return("")) == Some("")) - assert(Js.Null.toOption(Js.Null.return("")) == Some("")) + assert(Nullable.toOption(Nullable.make("")) == Some("")) + assert(Null.toOption(Null.make("")) == Some("")) } diff --git a/tests/tests/src/hash_test.res b/tests/tests/src/hash_test.res index 4a8e2cae138..e43eb169d1d 100644 --- a/tests/tests/src/hash_test.res +++ b/tests/tests/src/hash_test.res @@ -2,7 +2,7 @@ open Belt open Mocha open Test_utils -let test_strings = Array.init(32, i => Js.String2.fromCodePoint(i)->Js.String2.repeat(i)) +let test_strings = Array.init(32, i => String.fromCodePoint(i)->String.repeat(i)) let test_strings_hash_results = [ 0, diff --git a/tests/tests/src/import2.res b/tests/tests/src/import2.res index 9130ed5f23a..d05390a6fda 100644 --- a/tests/tests/src/import2.res +++ b/tests/tests/src/import2.res @@ -1,2 +1,2 @@ -let a = Js.import(Import_external.makeA) +let a = import(Import_external.makeA) let b = Import_external.makeA diff --git a/tests/tests/src/import_external.res b/tests/tests/src/import_external.res index 6474f9a0c9c..40356ed67d6 100644 --- a/tests/tests/src/import_external.res +++ b/tests/tests/src/import_external.res @@ -1,9 +1,9 @@ @module("a") external makeA: string = "default" -let f8 = Js.import(makeA) +let f8 = import(makeA) @module("b") external makeB: string => unit = "default" -let f9 = Js.import(makeB) +let f9 = import(makeB) diff --git a/tests/tests/src/import_side_effect.res b/tests/tests/src/import_side_effect.res index 013d7cde540..45fb297addf 100644 --- a/tests/tests/src/import_side_effect.res +++ b/tests/tests/src/import_side_effect.res @@ -1,3 +1,3 @@ -let a = Js.import(Side_effect2.a) +let a = import(Side_effect2.a) module M = await Side_effect diff --git a/tests/tests/src/import_side_effect_free.res b/tests/tests/src/import_side_effect_free.res index 0f23a781f91..2fd362e6eee 100644 --- a/tests/tests/src/import_side_effect_free.res +++ b/tests/tests/src/import_side_effect_free.res @@ -1 +1 @@ -let a = await Js.import(Side_effect_free.a) +let a = await import(Side_effect_free.a) diff --git a/tests/tests/src/infer_type_test.res b/tests/tests/src/infer_type_test.res index 5f44f198d9b..2416f8ca038 100644 --- a/tests/tests/src/infer_type_test.res +++ b/tests/tests/src/infer_type_test.res @@ -1,12 +1,13 @@ -@obj external mk_config: (~hi: int, ~lo: int, ~width: int=?, unit) => _ = "" +type hh = {"hi": int, "lo": int, "width": option} + +@obj external mk_config: (~hi: int, ~lo: int, ~width: int=?, unit) => hh = "" -type hh = {"hi": int, "lo": int, "width": Js.undefined} let hh = mk_config(~hi=30, ~lo=20, ()) /* let v = hh##widt */ let v = hh["width"] -@obj external config: (~hi: int, ~lo: int, ~width: int=?, unit) => _ = "" +@obj external config: (~hi: int, ~lo: int, ~width: int=?, unit) => hh = "" let v = config(~hi=32, ~lo=3, ()) @@ -15,7 +16,7 @@ let vv = config(~lo=3, ~width=3, ~hi=3, ()) let u = v["hi"] /* val u: int type */ let uu = v["width"] -/* val uu : int Js.undefined */ +/* val uu : option */ /* compile error let uu = v##xx */ diff --git a/tests/tests/src/infer_type_test.resi b/tests/tests/src/infer_type_test.resi index 0c57fe71e22..48c354eb379 100644 --- a/tests/tests/src/infer_type_test.resi +++ b/tests/tests/src/infer_type_test.resi @@ -1,11 +1,12 @@ -@obj external mk_config: (~hi: int, ~lo: int, ~width: int=?, unit) => _ = "" +type hh = {"hi": int, "lo": int, "width": option} + +@obj external mk_config: (~hi: int, ~lo: int, ~width: int=?, unit) => hh = "" -type hh = {"hi": int, "lo": int, "width": Js.undefined} let hh: hh -let v: {"hi": int, "lo": int, "width": Js.undefined} +let v: {"hi": int, "lo": int, "width": option} -let vv: {"hi": int, "lo": int, "width": Js.undefined} +let vv: {"hi": int, "lo": int, "width": option} let u: int -let uu: Js.undefined +let uu: option diff --git a/tests/tests/src/inline_condition_with_pattern_matching.res b/tests/tests/src/inline_condition_with_pattern_matching.res index a3a61ff623b..215ea4f2960 100644 --- a/tests/tests/src/inline_condition_with_pattern_matching.res +++ b/tests/tests/src/inline_condition_with_pattern_matching.res @@ -27,9 +27,9 @@ module Test2 = { // this is matched only if `name` isn't "Mary" or "Joe" `Hello ${name}.` | Student({name, reportCard: {passing: true, gpa}}) => - `Congrats ${name}, nice GPA of ${Js.Float.toString(gpa)} you got there!` + `Congrats ${name}, nice GPA of ${Float.toString(gpa)} you got there!` | Student({reportCard: {gpa: 0.0}, status: Vacations(daysLeft) | Sabbatical(daysLeft)}) => - `Come back in ${Js.Int.toString(daysLeft)} days!` + `Come back in ${Int.toString(daysLeft)} days!` | Student({status: Sick}) => `How are you feeling?` | Student({name}) => `Good luck next semester ${name}!` } diff --git a/tests/tests/src/inline_regression_test.mjs b/tests/tests/src/inline_regression_test.mjs index ffad8dab581..4ba1a84c8bf 100644 --- a/tests/tests/src/inline_regression_test.mjs +++ b/tests/tests/src/inline_regression_test.mjs @@ -11,7 +11,7 @@ function generic_basename(is_dir_sep, current_dir_name, name) { while (true) { let n = _n; if (n < 0) { - return name.substr(0, 1); + return name.substring(0, 1); } if (!is_dir_sep(name, n)) { let _n$1 = n; @@ -19,10 +19,10 @@ function generic_basename(is_dir_sep, current_dir_name, name) { while (true) { let n$1 = _n$1; if (n$1 < 0) { - return name.substr(0, p); + return name.substring(0, p); } if (is_dir_sep(name, n$1)) { - return name.substr(n$1 + 1 | 0, (p - n$1 | 0) - 1 | 0); + return name.substring(n$1 + 1 | 0, p); } _n$1 = n$1 - 1 | 0; continue; diff --git a/tests/tests/src/inline_regression_test.res b/tests/tests/src/inline_regression_test.res index 3f07acd79d1..34878cc84a1 100644 --- a/tests/tests/src/inline_regression_test.res +++ b/tests/tests/src/inline_regression_test.res @@ -4,7 +4,7 @@ open Test_utils let generic_basename = (is_dir_sep, current_dir_name, name) => { let rec find_end = n => if n < 0 { - Js.String2.substrAtMost(name, ~from=0, ~length=1) + String.substring(name, ~start=0, ~end=1) } else if is_dir_sep(name, n) { find_end(n - 1) } else { @@ -12,9 +12,9 @@ let generic_basename = (is_dir_sep, current_dir_name, name) => { } and find_beg = (n, p) => if n < 0 { - Js.String2.substrAtMost(name, ~from=0, ~length=p) + String.substring(name, ~start=0, ~end=p) } else if is_dir_sep(name, n) { - Js.String2.substrAtMost(name, ~from=n + 1, ~length=p - n - 1) + String.substring(name, ~start=n + 1, ~end=p) } else { find_beg(n - 1, p) } @@ -22,7 +22,7 @@ let generic_basename = (is_dir_sep, current_dir_name, name) => { if name == "" { current_dir_name } else { - find_end(Js.String2.length(name) - 1) + find_end(String.length(name) - 1) } } diff --git a/tests/tests/src/int_overflow_test.mjs b/tests/tests/src/int_overflow_test.mjs index 7d95eb09322..c1dcee99f4a 100644 --- a/tests/tests/src/int_overflow_test.mjs +++ b/tests/tests/src/int_overflow_test.mjs @@ -2,6 +2,8 @@ import * as Mocha from "mocha"; import * as Test_utils from "./test_utils.mjs"; +import * as Stdlib_Float from "@rescript/runtime/lib/es6/Stdlib_Float.mjs"; +import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.mjs"; function hash_variant(s) { let accu = 0; @@ -47,8 +49,8 @@ Mocha.describe("Int_overflow_test", () => { Mocha.test("hash_variant_test2", () => Test_utils.eq("File \"int_overflow_test.res\", line 58, characters 38-45", hash_variant2("xxyyzxzzyy"), -449896130)); Mocha.test("int_literal_flow", () => Test_utils.eq("File \"int_overflow_test.res\", line 59, characters 36-43", -1, -1)); Mocha.test("int_literal_flow2", () => Test_utils.eq("File \"int_overflow_test.res\", line 60, characters 37-44", -1, -1)); - Mocha.test("float_conversion_test1", () => Test_utils.eq("File \"int_overflow_test.res\", line 61, characters 42-49", Number("3") | 0, 3)); - Mocha.test("float_conversion_test2", () => Test_utils.eq("File \"int_overflow_test.res\", line 62, characters 42-49", Number("3.2") | 0, 3)); + Mocha.test("float_conversion_test1", () => Test_utils.eq("File \"int_overflow_test.res\", line 62, characters 7-14", Stdlib_Option.map(Stdlib_Float.fromString("3"), prim => prim | 0), 3)); + Mocha.test("float_conversion_test2", () => Test_utils.eq("File \"int_overflow_test.res\", line 65, characters 7-14", Stdlib_Option.map(Stdlib_Float.fromString("3.2"), prim => prim | 0), 3)); }); let max_int = 2147483647; diff --git a/tests/tests/src/int_overflow_test.res b/tests/tests/src/int_overflow_test.res index 279c850e8c9..223cfd8abd2 100644 --- a/tests/tests/src/int_overflow_test.res +++ b/tests/tests/src/int_overflow_test.res @@ -58,6 +58,10 @@ describe(__MODULE__, () => { test("hash_variant_test2", () => eq(__LOC__, hash_variant2("xxyyzxzzyy"), -449896130)) test("int_literal_flow", () => eq(__LOC__, -1, 0xffffffff)) test("int_literal_flow2", () => eq(__LOC__, -1, -1)) - test("float_conversion_test1", () => eq(__LOC__, int_of_float(Js.Float.fromString("3")), 3)) - test("float_conversion_test2", () => eq(__LOC__, int_of_float(Js.Float.fromString("3.2")), 3)) + test("float_conversion_test1", () => + eq(__LOC__, Float.fromString("3")->Option.map(int_of_float), Some(3)) + ) + test("float_conversion_test2", () => + eq(__LOC__, Float.fromString("3.2")->Option.map(int_of_float), Some(3)) + ) }) diff --git a/tests/tests/src/int_poly_var.res b/tests/tests/src/int_poly_var.res index 31308c40f10..17e9ed890d8 100644 --- a/tests/tests/src/int_poly_var.res +++ b/tests/tests/src/int_poly_var.res @@ -92,7 +92,7 @@ type u = [#0(int) | #1(string)] let f = (x: u) => { switch x { - | #0(x) => Js.Int.toString(x) + | #0(x) => Int.toString(x) | #1(x) => x } } diff --git a/tests/tests/src/js_array_test.mjs b/tests/tests/src/js_array_test.mjs deleted file mode 100644 index 5e31136af28..00000000000 --- a/tests/tests/src/js_array_test.mjs +++ /dev/null @@ -1,473 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Mocha from "mocha"; -import * as Test_utils from "./test_utils.mjs"; - -Mocha.describe("Js_array_test", () => { - Mocha.test("isArray_array", () => Test_utils.eq("File \"js_array_test.res\", line 25, characters 7-14", true, Array.isArray([]))); - Mocha.test("isArray_int", () => Test_utils.eq("File \"js_array_test.res\", line 28, characters 7-14", false, Array.isArray(34))); - Mocha.test("length", () => Test_utils.eq("File \"js_array_test.res\", line 31, characters 7-14", 3, 3)); - Mocha.test("copyWithin", () => Test_utils.eq("File \"js_array_test.res\", line 35, characters 7-14", [ - 1, - 2, - 3, - 1, - 2 - ], [ - 1, - 2, - 3, - 4, - 5 - ].copyWithin(-2))); - Mocha.test("copyWithinFrom", () => Test_utils.eq("File \"js_array_test.res\", line 38, characters 7-14", [ - 4, - 5, - 3, - 4, - 5 - ], [ - 1, - 2, - 3, - 4, - 5 - ].copyWithin(0, 3))); - Mocha.test("copyWithinFromRange", () => Test_utils.eq("File \"js_array_test.res\", line 42, characters 6-13", [ - 4, - 2, - 3, - 4, - 5 - ], [ - 1, - 2, - 3, - 4, - 5 - ].copyWithin(0, 3, 4))); - Mocha.test("fillInPlace", () => Test_utils.eq("File \"js_array_test.res\", line 49, characters 7-14", [ - 4, - 4, - 4 - ], [ - 1, - 2, - 3 - ].fill(4))); - Mocha.test("fillFromInPlace", () => Test_utils.eq("File \"js_array_test.res\", line 52, characters 7-14", [ - 1, - 4, - 4 - ], [ - 1, - 2, - 3 - ].fill(4, 1))); - Mocha.test("fillRangeInPlace", () => Test_utils.eq("File \"js_array_test.res\", line 55, characters 7-14", [ - 1, - 4, - 3 - ], [ - 1, - 2, - 3 - ].fill(4, 1, 2))); - Mocha.test("pop", () => Test_utils.eq("File \"js_array_test.res\", line 58, characters 7-14", 3, [ - 1, - 2, - 3 - ].pop())); - Mocha.test("pop - empty array", () => Test_utils.eq("File \"js_array_test.res\", line 61, characters 7-14", undefined, [].pop())); - Mocha.test("push", () => Test_utils.eq("File \"js_array_test.res\", line 64, characters 7-14", 4, [ - 1, - 2, - 3 - ].push(4))); - Mocha.test("pushMany", () => Test_utils.eq("File \"js_array_test.res\", line 67, characters 7-14", 5, [ - 1, - 2, - 3 - ].push(4, 5))); - Mocha.test("reverseInPlace", () => Test_utils.eq("File \"js_array_test.res\", line 70, characters 7-14", [ - 3, - 2, - 1 - ], [ - 1, - 2, - 3 - ].reverse())); - Mocha.test("shift", () => Test_utils.eq("File \"js_array_test.res\", line 73, characters 7-14", 1, [ - 1, - 2, - 3 - ].shift())); - Mocha.test("shift - empty array", () => Test_utils.eq("File \"js_array_test.res\", line 76, characters 7-14", undefined, [].shift())); - Mocha.test("sortInPlace", () => Test_utils.eq("File \"js_array_test.res\", line 79, characters 7-14", [ - 1, - 2, - 3 - ], [ - 3, - 1, - 2 - ].sort())); - Mocha.test("sortInPlaceWith", () => Test_utils.eq("File \"js_array_test.res\", line 82, characters 7-14", [ - 3, - 2, - 1 - ], [ - 3, - 1, - 2 - ].sort((a, b) => b - a | 0))); - Mocha.test("spliceInPlace", () => { - let arr = [ - 1, - 2, - 3, - 4 - ]; - let removed = arr.splice(2, 0, 5); - Test_utils.eq("File \"js_array_test.res\", line 88, characters 7-14", [ - [ - 1, - 2, - 5, - 3, - 4 - ], - [] - ], [ - arr, - removed - ]); - }); - Mocha.test("removeFromInPlace", () => { - let arr = [ - 1, - 2, - 3, - 4 - ]; - let removed = arr.splice(2); - Test_utils.eq("File \"js_array_test.res\", line 94, characters 7-14", [ - [ - 1, - 2 - ], - [ - 3, - 4 - ] - ], [ - arr, - removed - ]); - }); - Mocha.test("removeCountInPlace", () => { - let arr = [ - 1, - 2, - 3, - 4 - ]; - let removed = arr.splice(2, 1); - Test_utils.eq("File \"js_array_test.res\", line 100, characters 7-14", [ - [ - 1, - 2, - 4 - ], - [3] - ], [ - arr, - removed - ]); - }); - Mocha.test("unshift", () => Test_utils.eq("File \"js_array_test.res\", line 103, characters 7-14", 4, [ - 1, - 2, - 3 - ].unshift(4))); - Mocha.test("unshiftMany", () => Test_utils.eq("File \"js_array_test.res\", line 106, characters 7-14", 5, [ - 1, - 2, - 3 - ].unshift(4, 5))); - Mocha.test("append", () => Test_utils.eq("File \"js_array_test.res\", line 109, characters 7-14", [ - 1, - 2, - 3, - 4 - ], [ - 1, - 2, - 3 - ].concat([4]))); - Mocha.test("concat", () => Test_utils.eq("File \"js_array_test.res\", line 112, characters 7-14", [ - 1, - 2, - 3, - 4, - 5 - ], [ - 1, - 2, - 3 - ].concat([ - 4, - 5 - ]))); - Mocha.test("concatMany", () => Test_utils.eq("File \"js_array_test.res\", line 115, characters 7-14", [ - 1, - 2, - 3, - 4, - 5, - 6, - 7 - ], [ - 1, - 2, - 3 - ].concat([ - 4, - 5 - ], [ - 6, - 7 - ]))); - Mocha.test("includes", () => Test_utils.eq("File \"js_array_test.res\", line 119, characters 7-14", true, [ - 1, - 2, - 3 - ].includes(3))); - Mocha.test("indexOf", () => Test_utils.eq("File \"js_array_test.res\", line 122, characters 7-14", 1, [ - 1, - 2, - 3 - ].indexOf(2))); - Mocha.test("indexOfFrom", () => Test_utils.eq("File \"js_array_test.res\", line 125, characters 7-14", 3, [ - 1, - 2, - 3, - 2 - ].indexOf(2, 2))); - Mocha.test("join", () => Test_utils.eq("File \"js_array_test.res\", line 128, characters 7-14", "1,2,3", [ - 1, - 2, - 3 - ].join())); - Mocha.test("joinWith", () => Test_utils.eq("File \"js_array_test.res\", line 131, characters 7-14", "1;2;3", [ - 1, - 2, - 3 - ].join(";"))); - Mocha.test("lastIndexOf", () => Test_utils.eq("File \"js_array_test.res\", line 134, characters 7-14", 1, [ - 1, - 2, - 3 - ].lastIndexOf(2))); - Mocha.test("lastIndexOfFrom", () => Test_utils.eq("File \"js_array_test.res\", line 137, characters 7-14", 1, [ - 1, - 2, - 3, - 2 - ].lastIndexOf(2, 2))); - Mocha.test("slice", () => Test_utils.eq("File \"js_array_test.res\", line 140, characters 7-14", [ - 2, - 3 - ], [ - 1, - 2, - 3, - 4, - 5 - ].slice(1, 3))); - Mocha.test("copy", () => Test_utils.eq("File \"js_array_test.res\", line 143, characters 7-14", [ - 1, - 2, - 3, - 4, - 5 - ], [ - 1, - 2, - 3, - 4, - 5 - ].slice())); - Mocha.test("sliceFrom", () => Test_utils.eq("File \"js_array_test.res\", line 146, characters 7-14", [ - 3, - 4, - 5 - ], [ - 1, - 2, - 3, - 4, - 5 - ].slice(2))); - Mocha.test("toString", () => Test_utils.eq("File \"js_array_test.res\", line 149, characters 7-14", "1,2,3", [ - 1, - 2, - 3 - ].toString())); - Mocha.test("toLocaleString", () => Test_utils.eq("File \"js_array_test.res\", line 152, characters 7-14", "1,2,3", [ - 1, - 2, - 3 - ].toLocaleString())); - Mocha.test("every", () => Test_utils.eq("File \"js_array_test.res\", line 163, characters 7-14", true, [ - 1, - 2, - 3 - ].every(n => n > 0))); - Mocha.test("everyi", () => Test_utils.eq("File \"js_array_test.res\", line 166, characters 7-14", false, [ - 1, - 2, - 3 - ].every((param, i) => i > 0))); - Mocha.test("filter", () => Test_utils.eq("File \"js_array_test.res\", line 169, characters 7-14", [ - 2, - 4 - ], [ - 1, - 2, - 3, - 4 - ].filter(n => n % 2 === 0))); - Mocha.test("filteri", () => Test_utils.eq("File \"js_array_test.res\", line 172, characters 7-14", [ - 1, - 3 - ], [ - 1, - 2, - 3, - 4 - ].filter((param, i) => i % 2 === 0))); - Mocha.test("find", () => Test_utils.eq("File \"js_array_test.res\", line 176, characters 7-14", 2, [ - 1, - 2, - 3, - 4 - ].find(n => n % 2 === 0))); - Mocha.test("find - no match", () => Test_utils.eq("File \"js_array_test.res\", line 179, characters 7-14", undefined, [ - 1, - 2, - 3, - 4 - ].find(n => n % 2 === 5))); - Mocha.test("findi", () => Test_utils.eq("File \"js_array_test.res\", line 182, characters 7-14", 1, [ - 1, - 2, - 3, - 4 - ].find((param, i) => i % 2 === 0))); - Mocha.test("findi - no match", () => Test_utils.eq("File \"js_array_test.res\", line 185, characters 7-14", undefined, [ - 1, - 2, - 3, - 4 - ].find((param, i) => i % 2 === 5))); - Mocha.test("findIndex", () => Test_utils.eq("File \"js_array_test.res\", line 189, characters 7-14", 1, [ - 1, - 2, - 3, - 4 - ].findIndex(n => n % 2 === 0))); - Mocha.test("findIndexi", () => Test_utils.eq("File \"js_array_test.res\", line 192, characters 7-14", 0, [ - 1, - 2, - 3, - 4 - ].findIndex((param, i) => i % 2 === 0))); - Mocha.test("forEach", () => { - let sum = { - contents: 0 - }; - [ - 1, - 2, - 3 - ].forEach(n => { - sum.contents = sum.contents + n | 0; - }); - Test_utils.eq("File \"js_array_test.res\", line 198, characters 7-14", 6, sum.contents); - }); - Mocha.test("forEachi", () => { - let sum = { - contents: 0 - }; - [ - 1, - 2, - 3 - ].forEach((param, i) => { - sum.contents = sum.contents + i | 0; - }); - Test_utils.eq("File \"js_array_test.res\", line 204, characters 7-14", 3, sum.contents); - }); - Mocha.test("map", () => Test_utils.eq("File \"js_array_test.res\", line 215, characters 7-14", [ - 2, - 4, - 6, - 8 - ], [ - 1, - 2, - 3, - 4 - ].map(n => (n << 1)))); - Mocha.test("mapi", () => Test_utils.eq("File \"js_array_test.res\", line 218, characters 7-14", [ - 0, - 2, - 4, - 6 - ], [ - 1, - 2, - 3, - 4 - ].map((param, i) => (i << 1)))); - Mocha.test("reduce", () => Test_utils.eq("File \"js_array_test.res\", line 221, characters 7-14", -10, [ - 1, - 2, - 3, - 4 - ].reduce((acc, n) => acc - n | 0, 0))); - Mocha.test("reducei", () => Test_utils.eq("File \"js_array_test.res\", line 224, characters 7-14", -6, [ - 1, - 2, - 3, - 4 - ].reduce((acc, param, i) => acc - i | 0, 0))); - Mocha.test("reduceRight", () => Test_utils.eq("File \"js_array_test.res\", line 227, characters 7-14", -10, [ - 1, - 2, - 3, - 4 - ].reduceRight((acc, n) => acc - n | 0, 0))); - Mocha.test("reduceRighti", () => Test_utils.eq("File \"js_array_test.res\", line 230, characters 7-14", -6, [ - 1, - 2, - 3, - 4 - ].reduceRight((acc, param, i) => acc - i | 0, 0))); - Mocha.test("some", () => Test_utils.eq("File \"js_array_test.res\", line 233, characters 7-14", false, [ - 1, - 2, - 3, - 4 - ].some(n => n <= 0))); - Mocha.test("somei", () => Test_utils.eq("File \"js_array_test.res\", line 236, characters 7-14", true, [ - 1, - 2, - 3, - 4 - ].some((param, i) => i <= 0))); -}); - -/* Not a pure module */ diff --git a/tests/tests/src/js_array_test.res b/tests/tests/src/js_array_test.res deleted file mode 100644 index c628680baf3..00000000000 --- a/tests/tests/src/js_array_test.res +++ /dev/null @@ -1,246 +0,0 @@ -open Mocha -open Test_utils - -describe(__MODULE__, () => { - /* es2015, unable to test because nothing currently implements array_like - test("from", () => { - eq(__LOC__, - [| 0; 1 |], - [| "a"; "b" |] |. Js.Array2.keys |. Js.Array2.from) - }) - */ - - /* es2015, unable to test because nothing currently implements array_like - test("fromMap", () => { - eq(__LOC__, - [| (-1); 0 |], - Js.Array2.fromMap - ([| "a"; "b" |] |. Js.Array2.keys) - ((fun x -> x - 1) [@bs])) - }) - */ - - /* es2015 */ - test("isArray_array", () => { - eq(__LOC__, true, []->Js.Array2.isArray) - }) - test("isArray_int", () => { - eq(__LOC__, false, 34->Js.Array2.isArray) - }) - test("length", () => { - eq(__LOC__, 3, [1, 2, 3]->Js.Array2.length) - }) - /* es2015 */ - test("copyWithin", () => { - eq(__LOC__, [1, 2, 3, 1, 2], [1, 2, 3, 4, 5]->Js.Array2.copyWithin(~to_=-2)) - }) - test("copyWithinFrom", () => { - eq(__LOC__, [4, 5, 3, 4, 5], [1, 2, 3, 4, 5]->Js.Array2.copyWithinFrom(~to_=0, ~from=3)) - }) - test("copyWithinFromRange", () => { - eq( - __LOC__, - [4, 2, 3, 4, 5], - [1, 2, 3, 4, 5]->Js.Array2.copyWithinFromRange(~to_=0, ~start=3, ~end_=4), - ) - }) - /* es2015 */ - test("fillInPlace", () => { - eq(__LOC__, [4, 4, 4], [1, 2, 3]->Js.Array2.fillInPlace(4)) - }) - test("fillFromInPlace", () => { - eq(__LOC__, [1, 4, 4], [1, 2, 3]->Js.Array2.fillFromInPlace(4, ~from=1)) - }) - test("fillRangeInPlace", () => { - eq(__LOC__, [1, 4, 3], [1, 2, 3]->Js.Array2.fillRangeInPlace(4, ~start=1, ~end_=2)) - }) - test("pop", () => { - eq(__LOC__, Some(3), [1, 2, 3]->Js.Array2.pop) - }) - test("pop - empty array", () => { - eq(__LOC__, None, []->Js.Array2.pop) - }) - test("push", () => { - eq(__LOC__, 4, [1, 2, 3]->Js.Array2.push(4)) - }) - test("pushMany", () => { - eq(__LOC__, 5, [1, 2, 3]->Js.Array2.pushMany([4, 5])) - }) - test("reverseInPlace", () => { - eq(__LOC__, [3, 2, 1], [1, 2, 3]->Js.Array2.reverseInPlace) - }) - test("shift", () => { - eq(__LOC__, Some(1), [1, 2, 3]->Js.Array2.shift) - }) - test("shift - empty array", () => { - eq(__LOC__, None, []->Js.Array2.shift) - }) - test("sortInPlace", () => { - eq(__LOC__, [1, 2, 3], [3, 1, 2]->Js.Array2.sortInPlace) - }) - test("sortInPlaceWith", () => { - eq(__LOC__, [3, 2, 1], [3, 1, 2]->Js.Array2.sortInPlaceWith((a, b) => b - a)) - }) - test("spliceInPlace", () => { - let arr = [1, 2, 3, 4] - let removed = arr->Js.Array2.spliceInPlace(~pos=2, ~remove=0, ~add=[5]) - - eq(__LOC__, ([1, 2, 5, 3, 4], []), (arr, removed)) - }) - test("removeFromInPlace", () => { - let arr = [1, 2, 3, 4] - let removed = arr->Js.Array2.removeFromInPlace(~pos=2) - - eq(__LOC__, ([1, 2], [3, 4]), (arr, removed)) - }) - test("removeCountInPlace", () => { - let arr = [1, 2, 3, 4] - let removed = arr->Js.Array2.removeCountInPlace(~pos=2, ~count=1) - - eq(__LOC__, ([1, 2, 4], [3]), (arr, removed)) - }) - test("unshift", () => { - eq(__LOC__, 4, [1, 2, 3]->Js.Array2.unshift(4)) - }) - test("unshiftMany", () => { - eq(__LOC__, 5, [1, 2, 3]->Js.Array2.unshiftMany([4, 5])) - }) - test("append", () => { - eq(__LOC__, [1, 2, 3, 4], [1, 2, 3]->Js.Array2.concat([4])) - }) - test("concat", () => { - eq(__LOC__, [1, 2, 3, 4, 5], [1, 2, 3]->Js.Array2.concat([4, 5])) - }) - test("concatMany", () => { - eq(__LOC__, [1, 2, 3, 4, 5, 6, 7], [1, 2, 3]->Js.Array2.concatMany([[4, 5], [6, 7]])) - }) - /* es2016 */ - test("includes", () => { - eq(__LOC__, true, [1, 2, 3]->Js.Array2.includes(3)) - }) - test("indexOf", () => { - eq(__LOC__, 1, [1, 2, 3]->Js.Array2.indexOf(2)) - }) - test("indexOfFrom", () => { - eq(__LOC__, 3, [1, 2, 3, 2]->Js.Array2.indexOfFrom(2, ~from=2)) - }) - test("join", () => { - eq(__LOC__, "1,2,3", [1, 2, 3]->Js.Array.join) - }) - test("joinWith", () => { - eq(__LOC__, "1;2;3", [1, 2, 3]->Js.Array2.joinWith(";")) - }) - test("lastIndexOf", () => { - eq(__LOC__, 1, [1, 2, 3]->Js.Array2.lastIndexOf(2)) - }) - test("lastIndexOfFrom", () => { - eq(__LOC__, 1, [1, 2, 3, 2]->Js.Array2.lastIndexOfFrom(2, ~from=2)) - }) - test("slice", () => { - eq(__LOC__, [2, 3], [1, 2, 3, 4, 5]->Js.Array2.slice(~start=1, ~end_=3)) - }) - test("copy", () => { - eq(__LOC__, [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]->Js.Array2.copy) - }) - test("sliceFrom", () => { - eq(__LOC__, [3, 4, 5], [1, 2, 3, 4, 5]->Js.Array2.sliceFrom(2)) - }) - test("toString", () => { - eq(__LOC__, "1,2,3", [1, 2, 3]->Js.Array2.toString) - }) - test("toLocaleString", () => { - eq(__LOC__, "1,2,3", [1, 2, 3]->Js.Array2.toLocaleString) - }) - /* es2015, iterator - test("entries", () => { - eq(__LOC__, - [| (0, "a"); (1, "b"); (2, "c") |], - [| "a"; "b"; "c" |] |. Js.Array2.entries |. Js.Array2.from) - }) - */ - - test("every", () => { - eq(__LOC__, true, [1, 2, 3]->Js.Array2.every(n => n > 0)) - }) - test("everyi", () => { - eq(__LOC__, false, [1, 2, 3]->Js.Array2.everyi((_, i) => i > 0)) - }) - test("filter", () => { - eq(__LOC__, [2, 4], [1, 2, 3, 4]->Js.Array2.filter(n => mod(n, 2) == 0)) - }) - test("filteri", () => { - eq(__LOC__, [1, 3], [1, 2, 3, 4]->Js.Array2.filteri((_, i) => mod(i, 2) == 0)) - }) - /* es2015 */ - test("find", () => { - eq(__LOC__, Some(2), [1, 2, 3, 4]->Js.Array2.find(n => mod(n, 2) == 0)) - }) - test("find - no match", () => { - eq(__LOC__, None, [1, 2, 3, 4]->Js.Array2.find(n => mod(n, 2) == 5)) - }) - test("findi", () => { - eq(__LOC__, Some(1), [1, 2, 3, 4]->Js.Array2.findi((_, i) => mod(i, 2) == 0)) - }) - test("findi - no match", () => { - eq(__LOC__, None, [1, 2, 3, 4]->Js.Array2.findi((_, i) => mod(i, 2) == 5)) - }) - /* es2015 */ - test("findIndex", () => { - eq(__LOC__, 1, [1, 2, 3, 4]->Js.Array2.findIndex(n => mod(n, 2) == 0)) - }) - test("findIndexi", () => { - eq(__LOC__, 0, [1, 2, 3, 4]->Js.Array2.findIndexi((_, i) => mod(i, 2) == 0)) - }) - test("forEach", () => { - let sum = ref(0) - let _ = [1, 2, 3]->Js.Array2.forEach(n => sum := sum.contents + n) - - eq(__LOC__, 6, sum.contents) - }) - test("forEachi", () => { - let sum = ref(0) - let _ = [1, 2, 3]->Js.Array2.forEachi((_, i) => sum := sum.contents + i) - - eq(__LOC__, 3, sum.contents) - }) - /* es2015, iterator - test("keys", () => { - eq(__LOC__, - [| 0; 1; 2 |], - [| "a"; "b"; "c" |] |. Js.Array2.keys |. Js.Array2.from) - }) - */ - - test("map", () => { - eq(__LOC__, [2, 4, 6, 8], [1, 2, 3, 4]->Js.Array2.map(n => n * 2)) - }) - test("mapi", () => { - eq(__LOC__, [0, 2, 4, 6], [1, 2, 3, 4]->Js.Array2.mapi((_, i) => i * 2)) - }) - test("reduce", () => { - eq(__LOC__, -10, [1, 2, 3, 4]->Js.Array2.reduce((acc, n) => acc - n, 0)) - }) - test("reducei", () => { - eq(__LOC__, -6, [1, 2, 3, 4]->Js.Array2.reducei((acc, _, i) => acc - i, 0)) - }) - test("reduceRight", () => { - eq(__LOC__, -10, [1, 2, 3, 4]->Js.Array2.reduceRight((acc, n) => acc - n, 0)) - }) - test("reduceRighti", () => { - eq(__LOC__, -6, [1, 2, 3, 4]->Js.Array2.reduceRighti((acc, _, i) => acc - i, 0)) - }) - test("some", () => { - eq(__LOC__, false, [1, 2, 3, 4]->Js.Array2.some(n => n <= 0)) - }) - test("somei", () => { - eq(__LOC__, true, [1, 2, 3, 4]->Js.Array2.somei((_, i) => i <= 0)) - }) - - /* es2015, iterator - test("values", () => { - eq(__LOC__, - [| "a"; "b"; "c" |], - [| "a"; "b"; "c" |] |. Js.Array2.values |. Js.Array2.from) - }) - */ -}) diff --git a/tests/tests/src/js_bool_test.mjs b/tests/tests/src/js_bool_test.mjs deleted file mode 100644 index 593e8aff969..00000000000 --- a/tests/tests/src/js_bool_test.mjs +++ /dev/null @@ -1,104 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Mocha from "mocha"; -import * as Test_utils from "./test_utils.mjs"; - -function f(x) { - return x; -} - -function f2(x) { - return x; -} - -function f4(x) { - return x; -} - -let u = (!!1); - -let v = true; - -function ff(u) { - if (u === true) { - return 1; - } else { - return 2; - } -} - -function fi(x, y) { - return x === y; -} - -function fb(x, y) { - return x === y; -} - -function fadd(x, y) { - return x + y | 0; -} - -function ffadd(x, y) { - return x + y; -} - -function ss(x) { - return "xx" > x; -} - -function bb(x) { - return [ - true > x, - false, - true, - true <= x, - false, - false < x, - false >= x, - true - ]; -} - -let consts = [ - false, - false, - true, - false, - true, - false, - true, - true -]; - -let bool_array = [ - true, - false -]; - -Mocha.describe("Js_bool_test", () => { - Mocha.test("?bool_eq_caml_bool", () => Test_utils.eq("File \"js_bool_test.res\", line 74, characters 38-45", u, true)); - Mocha.test("js_bool_eq_js_bool", () => Test_utils.eq("File \"js_bool_test.res\", line 75, characters 38-45", v, true)); - Mocha.test("js_bool_neq_acml_bool", () => Test_utils.ok("File \"js_bool_test.res\", line 76, characters 41-48", true === true)); -}); - -let f3 = true; - -export { - f, - f2, - f4, - f3, - u, - v, - ff, - fi, - fb, - fadd, - ffadd, - ss, - bb, - consts, - bool_array, -} -/* u Not a pure module */ diff --git a/tests/tests/src/js_bool_test.res b/tests/tests/src/js_bool_test.res deleted file mode 100644 index 3ef790fccbf..00000000000 --- a/tests/tests/src/js_bool_test.res +++ /dev/null @@ -1,77 +0,0 @@ -open Mocha -open Test_utils - -let f = x => - if x { - true - } else { - false - } - -let f2 = x => - if x { - true - } else { - false - } - -let f4 = x => - if x { - true - } else { - false - } - -let f3 = if true { - true -} else { - false -} - -let u: bool = %raw(` !!1`) - -let v: bool = %raw(` true`) - -let ff = u => - if u == true { - 1 - } else { - 2 - } - -let fi = (x: int, y) => x == y -let fb = (x: bool, y) => x == y -let fadd = (x: int, y) => x + y -let ffadd = (x: float, y) => x +. y - -let ss = x => "xx" > x - -let bb = x => ( - true > x, - true < x, - true >= x, - true <= x, - false > x, - false < x, - false >= x, - false <= x, -) - -let consts = ( - true && false, - false && false, - true && true, - false && true, - true || false, - false || false, - true || true, - false || true, -) - -let bool_array = [true, false] - -describe(__MODULE__, () => { - test("?bool_eq_caml_bool", () => eq(__LOC__, u, f(true))) - test("js_bool_eq_js_bool", () => eq(__LOC__, v, f4(true))) - test("js_bool_neq_acml_bool", () => ok(__LOC__, f(true) == %raw(`true`) /* not type check */)) -}) diff --git a/tests/tests/src/js_date_test.mjs b/tests/tests/src/js_date_test.mjs deleted file mode 100644 index cecf55572b3..00000000000 --- a/tests/tests/src/js_date_test.mjs +++ /dev/null @@ -1,455 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Mocha from "mocha"; -import * as Test_utils from "./test_utils.mjs"; -import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.mjs"; - -function date() { - return new Date("1976-03-08T12:34:56.789+01:23"); -} - -Mocha.describe("Js_date_test", () => { - Mocha.test("valueOf", () => Test_utils.eq("File \"js_date_test.res\", line 9, characters 27-34", 195131516789, new Date("1976-03-08T12:34:56.789+01:23").valueOf())); - Mocha.test("make", () => Test_utils.eq("File \"js_date_test.res\", line 10, characters 24-31", true, new Date().getTime() > 1487223505382)); - Mocha.test("parseAsFloat", () => Test_utils.eq("File \"js_date_test.res\", line 12, characters 7-14", Date.parse("1976-03-08T12:34:56.789+01:23"), 195131516789)); - Mocha.test("parseAsFloat_invalid", () => Test_utils.eq("File \"js_date_test.res\", line 14, characters 40-47", true, Number.isNaN(Date.parse("gibberish")))); - Mocha.test("fromFloat", () => Test_utils.eq("File \"js_date_test.res\", line 16, characters 7-14", "1976-03-08T11:11:56.789Z", new Date(195131516789).toISOString())); - Mocha.test("fromString_valid", () => Test_utils.eq("File \"js_date_test.res\", line 19, characters 7-14", 195131516789, new Date("1976-03-08T12:34:56.789+01:23").getTime())); - Mocha.test("fromString_invalid", () => Test_utils.eq("File \"js_date_test.res\", line 22, characters 7-14", true, Number.isNaN(new Date("gibberish").getTime()))); - Mocha.test("makeWithYM", () => { - let d = new Date(1984, 4); - Test_utils.eq("File \"js_date_test.res\", line 26, characters 7-14", [ - 1984, - 4 - ], [ - d.getFullYear(), - d.getMonth() - ]); - }); - Mocha.test("makeWithYMD", () => { - let d = new Date(1984, 4, 6); - Test_utils.eq("File \"js_date_test.res\", line 30, characters 7-14", [ - 1984, - 4, - 6 - ], [ - d.getFullYear(), - d.getMonth(), - d.getDate() - ]); - }); - Mocha.test("makeWithYMDH", () => { - let d = new Date(1984, 4, 6, 3); - Test_utils.eq("File \"js_date_test.res\", line 34, characters 7-14", [ - 1984, - 4, - 6, - 3 - ], [ - d.getFullYear(), - d.getMonth(), - d.getDate(), - d.getHours() - ]); - }); - Mocha.test("makeWithYMDHM", () => { - let d = new Date(1984, 4, 6, 3, 59); - Test_utils.eq("File \"js_date_test.res\", line 39, characters 6-13", [ - 1984, - 4, - 6, - 3, - 59 - ], [ - d.getFullYear(), - d.getMonth(), - d.getDate(), - d.getHours(), - d.getMinutes() - ]); - }); - Mocha.test("makeWithYMDHMS", () => { - let d = new Date(1984, 4, 6, 3, 59, 27); - Test_utils.eq("File \"js_date_test.res\", line 55, characters 6-13", [ - 1984, - 4, - 6, - 3, - 59, - 27 - ], [ - d.getFullYear(), - d.getMonth(), - d.getDate(), - d.getHours(), - d.getMinutes(), - d.getSeconds() - ]); - }); - Mocha.test("utcWithYM", () => { - let d = Date.UTC(1984, 4); - let d$1 = new Date(d); - Test_utils.eq("File \"js_date_test.res\", line 70, characters 7-14", [ - 1984, - 4 - ], [ - d$1.getUTCFullYear(), - d$1.getUTCMonth() - ]); - }); - Mocha.test("utcWithYMD", () => { - let d = Date.UTC(1984, 4, 6); - let d$1 = new Date(d); - Test_utils.eq("File \"js_date_test.res\", line 75, characters 7-14", [ - 1984, - 4, - 6 - ], [ - d$1.getUTCFullYear(), - d$1.getUTCMonth(), - d$1.getUTCDate() - ]); - }); - Mocha.test("utcWithYMDH", () => { - let d = Date.UTC(1984, 4, 6, 3); - let d$1 = new Date(d); - Test_utils.eq("File \"js_date_test.res\", line 81, characters 6-13", [ - 1984, - 4, - 6, - 3 - ], [ - d$1.getUTCFullYear(), - d$1.getUTCMonth(), - d$1.getUTCDate(), - d$1.getUTCHours() - ]); - }); - Mocha.test("utcWithYMDHM", () => { - let d = Date.UTC(1984, 4, 6, 3, 59); - let d$1 = new Date(d); - Test_utils.eq("File \"js_date_test.res\", line 90, characters 6-13", [ - 1984, - 4, - 6, - 3, - 59 - ], [ - d$1.getUTCFullYear(), - d$1.getUTCMonth(), - d$1.getUTCDate(), - d$1.getUTCHours(), - d$1.getUTCMinutes() - ]); - }); - Mocha.test("utcWithYMDHMS", () => { - let d = Date.UTC(1984, 4, 6, 3, 59, 27); - let d$1 = new Date(d); - Test_utils.eq("File \"js_date_test.res\", line 113, characters 6-13", [ - 1984, - 4, - 6, - 3, - 59, - 27 - ], [ - d$1.getUTCFullYear(), - d$1.getUTCMonth(), - d$1.getUTCDate(), - d$1.getUTCHours(), - d$1.getUTCMinutes(), - d$1.getUTCSeconds() - ]); - }); - Mocha.test("getFullYear", () => Test_utils.eq("File \"js_date_test.res\", line 125, characters 31-38", 1976, new Date("1976-03-08T12:34:56.789+01:23").getFullYear())); - Mocha.test("getMilliseconds", () => Test_utils.eq("File \"js_date_test.res\", line 126, characters 35-42", 789, new Date("1976-03-08T12:34:56.789+01:23").getMilliseconds())); - Mocha.test("getSeconds", () => Test_utils.eq("File \"js_date_test.res\", line 127, characters 30-37", 56, new Date("1976-03-08T12:34:56.789+01:23").getSeconds())); - Mocha.test("getTime", () => Test_utils.eq("File \"js_date_test.res\", line 128, characters 27-34", 195131516789, new Date("1976-03-08T12:34:56.789+01:23").getTime())); - Mocha.test("getUTCDate", () => Test_utils.eq("File \"js_date_test.res\", line 129, characters 30-37", 8, new Date("1976-03-08T12:34:56.789+01:23").getUTCDate())); - Mocha.test("getUTCDay", () => Test_utils.eq("File \"js_date_test.res\", line 130, characters 29-36", 1, new Date("1976-03-08T12:34:56.789+01:23").getUTCDay())); - Mocha.test("getUTCFUllYear", () => Test_utils.eq("File \"js_date_test.res\", line 131, characters 34-41", 1976, new Date("1976-03-08T12:34:56.789+01:23").getUTCFullYear())); - Mocha.test("getUTCHours", () => Test_utils.eq("File \"js_date_test.res\", line 132, characters 31-38", 11, new Date("1976-03-08T12:34:56.789+01:23").getUTCHours())); - Mocha.test("getUTCMilliseconds", () => Test_utils.eq("File \"js_date_test.res\", line 133, characters 38-45", 789, new Date("1976-03-08T12:34:56.789+01:23").getUTCMilliseconds())); - Mocha.test("getUTCMinutes", () => Test_utils.eq("File \"js_date_test.res\", line 134, characters 33-40", 11, new Date("1976-03-08T12:34:56.789+01:23").getUTCMinutes())); - Mocha.test("getUTCMonth", () => Test_utils.eq("File \"js_date_test.res\", line 135, characters 31-38", 2, new Date("1976-03-08T12:34:56.789+01:23").getUTCMonth())); - Mocha.test("getUTCSeconds", () => Test_utils.eq("File \"js_date_test.res\", line 136, characters 33-40", 56, new Date("1976-03-08T12:34:56.789+01:23").getUTCSeconds())); - Mocha.test("getYear", () => Test_utils.eq("File \"js_date_test.res\", line 137, characters 27-34", 1976, new Date("1976-03-08T12:34:56.789+01:23").getFullYear())); - Mocha.test("setDate", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setDate(12); - Test_utils.eq("File \"js_date_test.res\", line 141, characters 7-14", 12, d.getDate()); - }); - Mocha.test("setFullYear", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setFullYear(1986); - Test_utils.eq("File \"js_date_test.res\", line 146, characters 7-14", 1986, d.getFullYear()); - }); - Mocha.test("setFullYearM", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setFullYear(1986, 7); - Test_utils.eq("File \"js_date_test.res\", line 151, characters 7-14", [ - 1986, - 7 - ], [ - d.getFullYear(), - d.getMonth() - ]); - }); - Mocha.test("setFullYearMD", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setFullYear(1986, 7, 23); - Test_utils.eq("File \"js_date_test.res\", line 156, characters 7-14", [ - 1986, - 7, - 23 - ], [ - d.getFullYear(), - d.getMonth(), - d.getDate() - ]); - }); - Mocha.test("setHours", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setHours(22); - Test_utils.eq("File \"js_date_test.res\", line 161, characters 7-14", 22, d.getHours()); - }); - Mocha.test("setHoursM", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setHours(22, 48); - Test_utils.eq("File \"js_date_test.res\", line 166, characters 7-14", [ - 22, - 48 - ], [ - d.getHours(), - d.getMinutes() - ]); - }); - Mocha.test("setHoursMS", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setHours(22, 48, 54); - Test_utils.eq("File \"js_date_test.res\", line 171, characters 7-14", [ - 22, - 48, - 54 - ], [ - d.getHours(), - d.getMinutes(), - d.getSeconds() - ]); - }); - Mocha.test("setMilliseconds", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setMilliseconds(543); - Test_utils.eq("File \"js_date_test.res\", line 176, characters 7-14", 543, d.getMilliseconds()); - }); - Mocha.test("setMinutes", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setMinutes(18); - Test_utils.eq("File \"js_date_test.res\", line 181, characters 7-14", 18, d.getMinutes()); - }); - Mocha.test("setMinutesS", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setMinutes(18, 42); - Test_utils.eq("File \"js_date_test.res\", line 186, characters 7-14", [ - 18, - 42 - ], [ - d.getMinutes(), - d.getSeconds() - ]); - }); - Mocha.test("setMinutesSMs", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setMinutes(18, 42, 311); - Test_utils.eq("File \"js_date_test.res\", line 191, characters 7-14", [ - 18, - 42, - 311 - ], [ - d.getMinutes(), - d.getSeconds(), - d.getMilliseconds() - ]); - }); - Mocha.test("setMonth", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setMonth(10); - Test_utils.eq("File \"js_date_test.res\", line 196, characters 7-14", 10, d.getMonth()); - }); - Mocha.test("setMonthD", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setMonth(10, 14); - Test_utils.eq("File \"js_date_test.res\", line 201, characters 7-14", [ - 10, - 14 - ], [ - d.getMonth(), - d.getDate() - ]); - }); - Mocha.test("setSeconds", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setSeconds(36); - Test_utils.eq("File \"js_date_test.res\", line 206, characters 7-14", 36, d.getSeconds()); - }); - Mocha.test("setSecondsMs", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setSeconds(36, 420); - Test_utils.eq("File \"js_date_test.res\", line 211, characters 7-14", [ - 36, - 420 - ], [ - d.getSeconds(), - d.getMilliseconds() - ]); - }); - Mocha.test("setUTCDate", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCDate(12); - Test_utils.eq("File \"js_date_test.res\", line 216, characters 7-14", 12, d.getUTCDate()); - }); - Mocha.test("setUTCFullYear", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCFullYear(1986); - Test_utils.eq("File \"js_date_test.res\", line 221, characters 7-14", 1986, d.getUTCFullYear()); - }); - Mocha.test("setUTCFullYearM", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCFullYear(1986, 7); - Test_utils.eq("File \"js_date_test.res\", line 226, characters 7-14", [ - 1986, - 7 - ], [ - d.getUTCFullYear(), - d.getUTCMonth() - ]); - }); - Mocha.test("setUTCFullYearMD", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCFullYear(1986, 7, 23); - Test_utils.eq("File \"js_date_test.res\", line 231, characters 7-14", [ - 1986, - 7, - 23 - ], [ - d.getUTCFullYear(), - d.getUTCMonth(), - d.getUTCDate() - ]); - }); - Mocha.test("setUTCHours", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCHours(22); - Test_utils.eq("File \"js_date_test.res\", line 236, characters 7-14", 22, d.getUTCHours()); - }); - Mocha.test("setUTCHoursM", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCHours(22, 48); - Test_utils.eq("File \"js_date_test.res\", line 241, characters 7-14", [ - 22, - 48 - ], [ - d.getUTCHours(), - d.getUTCMinutes() - ]); - }); - Mocha.test("setUTCHoursMS", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCHours(22, 48, 54); - Test_utils.eq("File \"js_date_test.res\", line 246, characters 7-14", [ - 22, - 48, - 54 - ], [ - d.getUTCHours(), - d.getUTCMinutes(), - d.getUTCSeconds() - ]); - }); - Mocha.test("setUTCMilliseconds", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCMilliseconds(543); - Test_utils.eq("File \"js_date_test.res\", line 251, characters 7-14", 543, d.getUTCMilliseconds()); - }); - Mocha.test("setUTCMinutes", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCMinutes(18); - Test_utils.eq("File \"js_date_test.res\", line 256, characters 7-14", 18, d.getUTCMinutes()); - }); - Mocha.test("setUTCMinutesS", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCMinutes(18, 42); - Test_utils.eq("File \"js_date_test.res\", line 261, characters 7-14", [ - 18, - 42 - ], [ - d.getUTCMinutes(), - d.getUTCSeconds() - ]); - }); - Mocha.test("setUTCMinutesSMs", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCMinutes(18, 42, 311); - Test_utils.eq("File \"js_date_test.res\", line 266, characters 7-14", [ - 18, - 42, - 311 - ], [ - d.getUTCMinutes(), - d.getUTCSeconds(), - d.getUTCMilliseconds() - ]); - }); - Mocha.test("setUTCMonth", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCMonth(10); - Test_utils.eq("File \"js_date_test.res\", line 271, characters 7-14", 10, d.getUTCMonth()); - }); - Mocha.test("setUTCMonthD", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCMonth(10, 14); - Test_utils.eq("File \"js_date_test.res\", line 276, characters 7-14", [ - 10, - 14 - ], [ - d.getUTCMonth(), - d.getUTCDate() - ]); - }); - Mocha.test("setUTCSeconds", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCSeconds(36); - Test_utils.eq("File \"js_date_test.res\", line 281, characters 7-14", 36, d.getUTCSeconds()); - }); - Mocha.test("setUTCSecondsMs", () => { - let d = new Date("1976-03-08T12:34:56.789+01:23"); - d.setUTCSeconds(36, 420); - Test_utils.eq("File \"js_date_test.res\", line 286, characters 7-14", [ - 36, - 420 - ], [ - d.getUTCSeconds(), - d.getUTCMilliseconds() - ]); - }); - Mocha.test("toDateString", () => Test_utils.eq("File \"js_date_test.res\", line 288, characters 32-39", "Mon Mar 08 1976", new Date("1976-03-08T12:34:56.789+01:23").toDateString())); - Mocha.test("toGMTString", () => Test_utils.eq("File \"js_date_test.res\", line 289, characters 31-38", "Mon, 08 Mar 1976 11:11:56 GMT", new Date("1976-03-08T12:34:56.789+01:23").toUTCString())); - Mocha.test("toISOString", () => Test_utils.eq("File \"js_date_test.res\", line 290, characters 31-38", "1976-03-08T11:11:56.789Z", new Date("1976-03-08T12:34:56.789+01:23").toISOString())); - Mocha.test("toJSON", () => Test_utils.eq("File \"js_date_test.res\", line 291, characters 26-33", "1976-03-08T11:11:56.789Z", new Date("1976-03-08T12:34:56.789+01:23").toJSON())); - Mocha.test("toJSONUnsafe", () => Test_utils.eq("File \"js_date_test.res\", line 292, characters 32-39", "1976-03-08T11:11:56.789Z", new Date("1976-03-08T12:34:56.789+01:23").toJSON())); - Mocha.test("toUTCString", () => Test_utils.eq("File \"js_date_test.res\", line 293, characters 31-38", "Mon, 08 Mar 1976 11:11:56 GMT", new Date("1976-03-08T12:34:56.789+01:23").toUTCString())); - Mocha.test("eq", () => { - let a = new Date("2013-03-01T01:10:00"); - let b = new Date("2013-03-01T01:10:00"); - let c = new Date("2013-03-01T01:10:01"); - Test_utils.ok("File \"js_date_test.res\", line 298, characters 7-14", Primitive_object.equal(a, b) && Primitive_object.notequal(b, c) && Primitive_object.greaterthan(c, b)); - }); -}); - -let N; - -export { - N, - date, -} -/* Not a pure module */ diff --git a/tests/tests/src/js_date_test.res b/tests/tests/src/js_date_test.res deleted file mode 100644 index 7e9e5987a93..00000000000 --- a/tests/tests/src/js_date_test.res +++ /dev/null @@ -1,300 +0,0 @@ -open Mocha -open Test_utils - -module N = Js.Date - -let date = () => N.fromString("1976-03-08T12:34:56.789+01:23") - -describe(__MODULE__, () => { - test("valueOf", () => eq(__LOC__, 195131516789., N.valueOf(date()))) - test("make", () => eq(__LOC__, true, N.getTime(N.make()) > 1487223505382.)) - test("parseAsFloat", () => - eq(__LOC__, N.parseAsFloat("1976-03-08T12:34:56.789+01:23"), 195131516789.) - ) - test("parseAsFloat_invalid", () => eq(__LOC__, true, Js_float.isNaN(N.parseAsFloat("gibberish")))) - test("fromFloat", () => - eq(__LOC__, "1976-03-08T11:11:56.789Z", N.toISOString(N.fromFloat(195131516789.))) - ) - test("fromString_valid", () => - eq(__LOC__, 195131516789., N.getTime(N.fromString("1976-03-08T12:34:56.789+01:23"))) - ) - test("fromString_invalid", () => - eq(__LOC__, true, Js_float.isNaN(N.getTime(N.fromString("gibberish")))) - ) - test("makeWithYM", () => { - let d = N.makeWithYM(~year=1984., ~month=4., ()) - eq(__LOC__, (1984., 4.), (N.getFullYear(d), N.getMonth(d))) - }) - test("makeWithYMD", () => { - let d = N.makeWithYMD(~year=1984., ~month=4., ~date=6., ()) - eq(__LOC__, (1984., 4., 6.), (N.getFullYear(d), N.getMonth(d), N.getDate(d))) - }) - test("makeWithYMDH", () => { - let d = N.makeWithYMDH(~year=1984., ~month=4., ~date=6., ~hours=3., ()) - eq(__LOC__, (1984., 4., 6., 3.), (N.getFullYear(d), N.getMonth(d), N.getDate(d), N.getHours(d))) - }) - test("makeWithYMDHM", () => { - let d = N.makeWithYMDHM(~year=1984., ~month=4., ~date=6., ~hours=3., ~minutes=59., ()) - eq( - __LOC__, - (1984., 4., 6., 3., 59.), - (N.getFullYear(d), N.getMonth(d), N.getDate(d), N.getHours(d), N.getMinutes(d)), - ) - }) - test("makeWithYMDHMS", () => { - let d = N.makeWithYMDHMS( - ~year=1984., - ~month=4., - ~date=6., - ~hours=3., - ~minutes=59., - ~seconds=27., - (), - ) - eq( - __LOC__, - (1984., 4., 6., 3., 59., 27.), - ( - N.getFullYear(d), - N.getMonth(d), - N.getDate(d), - N.getHours(d), - N.getMinutes(d), - N.getSeconds(d), - ), - ) - }) - test("utcWithYM", () => { - let d = N.utcWithYM(~year=1984., ~month=4., ()) - let d = N.fromFloat(d) - eq(__LOC__, (1984., 4.), (N.getUTCFullYear(d), N.getUTCMonth(d))) - }) - test("utcWithYMD", () => { - let d = N.utcWithYMD(~year=1984., ~month=4., ~date=6., ()) - let d = N.fromFloat(d) - eq(__LOC__, (1984., 4., 6.), (N.getUTCFullYear(d), N.getUTCMonth(d), N.getUTCDate(d))) - }) - test("utcWithYMDH", () => { - let d = N.utcWithYMDH(~year=1984., ~month=4., ~date=6., ~hours=3., ()) - let d = N.fromFloat(d) - eq( - __LOC__, - (1984., 4., 6., 3.), - (N.getUTCFullYear(d), N.getUTCMonth(d), N.getUTCDate(d), N.getUTCHours(d)), - ) - }) - test("utcWithYMDHM", () => { - let d = N.utcWithYMDHM(~year=1984., ~month=4., ~date=6., ~hours=3., ~minutes=59., ()) - let d = N.fromFloat(d) - eq( - __LOC__, - (1984., 4., 6., 3., 59.), - ( - N.getUTCFullYear(d), - N.getUTCMonth(d), - N.getUTCDate(d), - N.getUTCHours(d), - N.getUTCMinutes(d), - ), - ) - }) - test("utcWithYMDHMS", () => { - let d = N.utcWithYMDHMS( - ~year=1984., - ~month=4., - ~date=6., - ~hours=3., - ~minutes=59., - ~seconds=27., - (), - ) - let d = N.fromFloat(d) - eq( - __LOC__, - (1984., 4., 6., 3., 59., 27.), - ( - N.getUTCFullYear(d), - N.getUTCMonth(d), - N.getUTCDate(d), - N.getUTCHours(d), - N.getUTCMinutes(d), - N.getUTCSeconds(d), - ), - ) - }) - test("getFullYear", () => eq(__LOC__, 1976., N.getFullYear(date()))) - test("getMilliseconds", () => eq(__LOC__, 789., N.getMilliseconds(date()))) - test("getSeconds", () => eq(__LOC__, 56., N.getSeconds(date()))) - test("getTime", () => eq(__LOC__, 195131516789., N.getTime(date()))) - test("getUTCDate", () => eq(__LOC__, 8., N.getUTCDate(date()))) - test("getUTCDay", () => eq(__LOC__, 1., N.getUTCDay(date()))) - test("getUTCFUllYear", () => eq(__LOC__, 1976., N.getUTCFullYear(date()))) - test("getUTCHours", () => eq(__LOC__, 11., N.getUTCHours(date()))) - test("getUTCMilliseconds", () => eq(__LOC__, 789., N.getUTCMilliseconds(date()))) - test("getUTCMinutes", () => eq(__LOC__, 11., N.getUTCMinutes(date()))) - test("getUTCMonth", () => eq(__LOC__, 2., N.getUTCMonth(date()))) - test("getUTCSeconds", () => eq(__LOC__, 56., N.getUTCSeconds(date()))) - test("getYear", () => eq(__LOC__, 1976., N.getFullYear(date()))) - test("setDate", () => { - let d = date() - let _ = N.setDate(d, 12.) - eq(__LOC__, 12., N.getDate(d)) - }) - test("setFullYear", () => { - let d = date() - let _ = N.setFullYear(d, 1986.) - eq(__LOC__, 1986., N.getFullYear(d)) - }) - test("setFullYearM", () => { - let d = date() - let _ = N.setFullYearM(d, ~year=1986., ~month=7., ()) - eq(__LOC__, (1986., 7.), (N.getFullYear(d), N.getMonth(d))) - }) - test("setFullYearMD", () => { - let d = date() - let _ = N.setFullYearMD(d, ~year=1986., ~month=7., ~date=23., ()) - eq(__LOC__, (1986., 7., 23.), (N.getFullYear(d), N.getMonth(d), N.getDate(d))) - }) - test("setHours", () => { - let d = date() - let _ = N.setHours(d, 22.) - eq(__LOC__, 22., N.getHours(d)) - }) - test("setHoursM", () => { - let d = date() - let _ = N.setHoursM(d, ~hours=22., ~minutes=48., ()) - eq(__LOC__, (22., 48.), (N.getHours(d), N.getMinutes(d))) - }) - test("setHoursMS", () => { - let d = date() - let _ = N.setHoursMS(d, ~hours=22., ~minutes=48., ~seconds=54., ()) - eq(__LOC__, (22., 48., 54.), (N.getHours(d), N.getMinutes(d), N.getSeconds(d))) - }) - test("setMilliseconds", () => { - let d = date() - let _ = N.setMilliseconds(d, 543.) - eq(__LOC__, 543., N.getMilliseconds(d)) - }) - test("setMinutes", () => { - let d = date() - let _ = N.setMinutes(d, 18.) - eq(__LOC__, 18., N.getMinutes(d)) - }) - test("setMinutesS", () => { - let d = date() - let _ = N.setMinutesS(d, ~minutes=18., ~seconds=42., ()) - eq(__LOC__, (18., 42.), (N.getMinutes(d), N.getSeconds(d))) - }) - test("setMinutesSMs", () => { - let d = date() - let _ = N.setMinutesSMs(d, ~minutes=18., ~seconds=42., ~milliseconds=311., ()) - eq(__LOC__, (18., 42., 311.), (N.getMinutes(d), N.getSeconds(d), N.getMilliseconds(d))) - }) - test("setMonth", () => { - let d = date() - let _ = N.setMonth(d, 10.) - eq(__LOC__, 10., N.getMonth(d)) - }) - test("setMonthD", () => { - let d = date() - let _ = N.setMonthD(d, ~month=10., ~date=14., ()) - eq(__LOC__, (10., 14.), (N.getMonth(d), N.getDate(d))) - }) - test("setSeconds", () => { - let d = date() - let _ = N.setSeconds(d, 36.) - eq(__LOC__, 36., N.getSeconds(d)) - }) - test("setSecondsMs", () => { - let d = date() - let _ = N.setSecondsMs(d, ~seconds=36., ~milliseconds=420., ()) - eq(__LOC__, (36., 420.), (N.getSeconds(d), N.getMilliseconds(d))) - }) - test("setUTCDate", () => { - let d = date() - let _ = N.setUTCDate(d, 12.) - eq(__LOC__, 12., N.getUTCDate(d)) - }) - test("setUTCFullYear", () => { - let d = date() - let _ = N.setUTCFullYear(d, 1986.) - eq(__LOC__, 1986., N.getUTCFullYear(d)) - }) - test("setUTCFullYearM", () => { - let d = date() - let _ = N.setUTCFullYearM(d, ~year=1986., ~month=7., ()) - eq(__LOC__, (1986., 7.), (N.getUTCFullYear(d), N.getUTCMonth(d))) - }) - test("setUTCFullYearMD", () => { - let d = date() - let _ = N.setUTCFullYearMD(d, ~year=1986., ~month=7., ~date=23., ()) - eq(__LOC__, (1986., 7., 23.), (N.getUTCFullYear(d), N.getUTCMonth(d), N.getUTCDate(d))) - }) - test("setUTCHours", () => { - let d = date() - let _ = N.setUTCHours(d, 22.) - eq(__LOC__, 22., N.getUTCHours(d)) - }) - test("setUTCHoursM", () => { - let d = date() - let _ = N.setUTCHoursM(d, ~hours=22., ~minutes=48., ()) - eq(__LOC__, (22., 48.), (N.getUTCHours(d), N.getUTCMinutes(d))) - }) - test("setUTCHoursMS", () => { - let d = date() - let _ = N.setUTCHoursMS(d, ~hours=22., ~minutes=48., ~seconds=54., ()) - eq(__LOC__, (22., 48., 54.), (N.getUTCHours(d), N.getUTCMinutes(d), N.getUTCSeconds(d))) - }) - test("setUTCMilliseconds", () => { - let d = date() - let _ = N.setUTCMilliseconds(d, 543.) - eq(__LOC__, 543., N.getUTCMilliseconds(d)) - }) - test("setUTCMinutes", () => { - let d = date() - let _ = N.setUTCMinutes(d, 18.) - eq(__LOC__, 18., N.getUTCMinutes(d)) - }) - test("setUTCMinutesS", () => { - let d = date() - let _ = N.setUTCMinutesS(d, ~minutes=18., ~seconds=42., ()) - eq(__LOC__, (18., 42.), (N.getUTCMinutes(d), N.getUTCSeconds(d))) - }) - test("setUTCMinutesSMs", () => { - let d = date() - let _ = N.setUTCMinutesSMs(d, ~minutes=18., ~seconds=42., ~milliseconds=311., ()) - eq(__LOC__, (18., 42., 311.), (N.getUTCMinutes(d), N.getUTCSeconds(d), N.getUTCMilliseconds(d))) - }) - test("setUTCMonth", () => { - let d = date() - let _ = N.setUTCMonth(d, 10.) - eq(__LOC__, 10., N.getUTCMonth(d)) - }) - test("setUTCMonthD", () => { - let d = date() - let _ = N.setUTCMonthD(d, ~month=10., ~date=14., ()) - eq(__LOC__, (10., 14.), (N.getUTCMonth(d), N.getUTCDate(d))) - }) - test("setUTCSeconds", () => { - let d = date() - let _ = N.setUTCSeconds(d, 36.) - eq(__LOC__, 36., N.getUTCSeconds(d)) - }) - test("setUTCSecondsMs", () => { - let d = date() - let _ = N.setUTCSecondsMs(d, ~seconds=36., ~milliseconds=420., ()) - eq(__LOC__, (36., 420.), (N.getUTCSeconds(d), N.getUTCMilliseconds(d))) - }) - test("toDateString", () => eq(__LOC__, "Mon Mar 08 1976", N.toDateString(date()))) - test("toGMTString", () => eq(__LOC__, "Mon, 08 Mar 1976 11:11:56 GMT", N.toUTCString(date()))) - test("toISOString", () => eq(__LOC__, "1976-03-08T11:11:56.789Z", N.toISOString(date()))) - test("toJSON", () => eq(__LOC__, "1976-03-08T11:11:56.789Z", N.toJSON(date()))) - test("toJSONUnsafe", () => eq(__LOC__, "1976-03-08T11:11:56.789Z", N.toJSONUnsafe(date()))) - test("toUTCString", () => eq(__LOC__, "Mon, 08 Mar 1976 11:11:56 GMT", N.toUTCString(date()))) - test("eq", () => { - let a = Js.Date.fromString("2013-03-01T01:10:00") - let b = Js.Date.fromString("2013-03-01T01:10:00") - let c = Js.Date.fromString("2013-03-01T01:10:01") - ok(__LOC__, a == b && (b != c && c > b)) - }) -}) diff --git a/tests/tests/src/js_dict_test.mjs b/tests/tests/src/js_dict_test.mjs deleted file mode 100644 index 21215eb3d6a..00000000000 --- a/tests/tests/src/js_dict_test.mjs +++ /dev/null @@ -1,118 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Mocha from "mocha"; -import * as Js_dict from "@rescript/runtime/lib/es6/Js_dict.mjs"; -import * as Test_utils from "./test_utils.mjs"; - -function obj() { - return { - foo: 43, - bar: 86 - }; -} - -Mocha.describe("Js_dict_test", () => { - Mocha.test("empty", () => Test_utils.eq("File \"js_dict_test.res\", line 9, characters 7-14", [], Object.keys({}))); - Mocha.test("get", () => Test_utils.eq("File \"js_dict_test.res\", line 12, characters 7-14", 43, Js_dict.get({ - foo: 43, - bar: 86 - }, "foo"))); - Mocha.test("get - property not in object", () => Test_utils.eq("File \"js_dict_test.res\", line 15, characters 7-14", undefined, Js_dict.get({ - foo: 43, - bar: 86 - }, "baz"))); - Mocha.test("unsafe_get", () => Test_utils.eq("File \"js_dict_test.res\", line 18, characters 7-14", 43, ({ - foo: 43, - bar: 86 - })["foo"])); - Mocha.test("set", () => { - let o = { - foo: 43, - bar: 86 - }; - o["foo"] = 36; - Test_utils.eq("File \"js_dict_test.res\", line 23, characters 7-14", 36, Js_dict.get(o, "foo")); - }); - Mocha.test("keys", () => Test_utils.eq("File \"js_dict_test.res\", line 26, characters 7-14", [ - "foo", - "bar" - ], Object.keys({ - foo: 43, - bar: 86 - }))); - Mocha.test("entries", () => Test_utils.eq("File \"js_dict_test.res\", line 29, characters 7-14", [ - [ - "foo", - 43 - ], - [ - "bar", - 86 - ] - ], Js_dict.entries({ - foo: 43, - bar: 86 - }))); - Mocha.test("values", () => Test_utils.eq("File \"js_dict_test.res\", line 32, characters 7-14", [ - 43, - 86 - ], Js_dict.values({ - foo: 43, - bar: 86 - }))); - Mocha.test("fromList - []", () => Test_utils.eq("File \"js_dict_test.res\", line 35, characters 7-14", {}, Js_dict.fromList(/* [] */0))); - Mocha.test("fromList", () => Test_utils.eq("File \"js_dict_test.res\", line 38, characters 7-14", [ - [ - "x", - 23 - ], - [ - "y", - 46 - ] - ], Js_dict.entries(Js_dict.fromList({ - hd: [ - "x", - 23 - ], - tl: { - hd: [ - "y", - 46 - ], - tl: /* [] */0 - } - })))); - Mocha.test("fromArray - []", () => Test_utils.eq("File \"js_dict_test.res\", line 41, characters 7-14", {}, Js_dict.fromArray([]))); - Mocha.test("fromArray", () => Test_utils.eq("File \"js_dict_test.res\", line 44, characters 7-14", [ - [ - "x", - 23 - ], - [ - "y", - 46 - ] - ], Js_dict.entries(Js_dict.fromArray([ - [ - "x", - 23 - ], - [ - "y", - 46 - ] - ])))); - Mocha.test("map", () => Test_utils.eq("File \"js_dict_test.res\", line 47, characters 7-14", { - foo: "43", - bar: "86" - }, Js_dict.map(i => i.toString(), { - foo: 43, - bar: 86 - }))); -}); - -export { - obj, -} -/* Not a pure module */ diff --git a/tests/tests/src/js_dict_test.res b/tests/tests/src/js_dict_test.res deleted file mode 100644 index e241274ad1c..00000000000 --- a/tests/tests/src/js_dict_test.res +++ /dev/null @@ -1,49 +0,0 @@ -open Js_dict -open Mocha -open Test_utils - -let obj = (): t<'a> => Obj.magic({"foo": 43, "bar": 86}) - -describe(__MODULE__, () => { - test("empty", () => { - eq(__LOC__, [], keys(empty())) - }) - test("get", () => { - eq(__LOC__, Some(43), get(obj(), "foo")) - }) - test("get - property not in object", () => { - eq(__LOC__, None, get(obj(), "baz")) - }) - test("unsafe_get", () => { - eq(__LOC__, 43, unsafeGet(obj(), "foo")) - }) - test("set", () => { - let o = obj() - set(o, "foo", 36) - eq(__LOC__, Some(36), get(o, "foo")) - }) - test("keys", () => { - eq(__LOC__, ["foo", "bar"], keys(obj())) - }) - test("entries", () => { - eq(__LOC__, [("foo", 43), ("bar", 86)], entries(obj())) - }) - test("values", () => { - eq(__LOC__, [43, 86], values(obj())) - }) - test("fromList - []", () => { - eq(__LOC__, empty(), fromList(list{})) - }) - test("fromList", () => { - eq(__LOC__, [("x", 23), ("y", 46)], entries(fromList(list{("x", 23), ("y", 46)}))) - }) - test("fromArray - []", () => { - eq(__LOC__, empty(), fromArray([])) - }) - test("fromArray", () => { - eq(__LOC__, [("x", 23), ("y", 46)], entries(fromArray([("x", 23), ("y", 46)]))) - }) - test("map", () => { - eq(__LOC__, Obj.magic({"foo": "43", "bar": "86"}), map(i => Js.Int.toString(i), obj())) - }) -}) diff --git a/tests/tests/src/js_exception_catch_test.mjs b/tests/tests/src/js_exception_catch_test.mjs deleted file mode 100644 index 1f7b814adfc..00000000000 --- a/tests/tests/src/js_exception_catch_test.mjs +++ /dev/null @@ -1,123 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Mocha from "mocha"; -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; -import * as Stdlib_Exn from "@rescript/runtime/lib/es6/Stdlib_Exn.mjs"; -import * as Test_utils from "./test_utils.mjs"; -import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.mjs"; - -Mocha.test("js_exception_catch_test_json_parse", () => { - let e; - try { - e = JSON.parse(` {"x"}`); - } catch (raw_x) { - let x = Primitive_exceptions.internalToException(raw_x); - if (x.RE_EXN_ID === Stdlib_Exn.$$Error) { - return Test_utils.ok("File \"js_exception_catch_test.res\", line 7, characters 36-43", true); - } - throw x; - } - Test_utils.ok("File \"js_exception_catch_test.res\", line 8, characters 12-19", false); -}); - -let A = /* @__PURE__ */Primitive_exceptions.create("Js_exception_catch_test.A"); - -let B = /* @__PURE__ */Primitive_exceptions.create("Js_exception_catch_test.B"); - -let C = /* @__PURE__ */Primitive_exceptions.create("Js_exception_catch_test.C"); - -function testException(f) { - try { - f(); - return "No_error"; - } catch (raw_e) { - let e = Primitive_exceptions.internalToException(raw_e); - if (e.RE_EXN_ID === "Not_found") { - return "Not_found"; - } else if (e.RE_EXN_ID === "Invalid_argument") { - if (e._1 === "x") { - return "Invalid_argument"; - } else { - return "Invalid_any"; - } - } else if (e.RE_EXN_ID === A) { - if (e._1 !== 2) { - return "A_any"; - } else { - return "A2"; - } - } else if (e.RE_EXN_ID === B) { - return "B"; - } else if (e.RE_EXN_ID === C) { - if (e._1 !== 1 || e._2 !== 2) { - return "C_any"; - } else { - return "C"; - } - } else if (e.RE_EXN_ID === Stdlib_Exn.$$Error) { - return "Js_error"; - } else { - return "Any"; - } - } -} - -Mocha.describe("Js_exception_catch_test", () => { - Mocha.test("js exception catch test", () => { - Test_utils.eq("File \"js_exception_catch_test.res\", line 35, characters 7-14", testException(() => {}), "No_error"); - Test_utils.eq("File \"js_exception_catch_test.res\", line 36, characters 7-14", testException(() => { - throw { - RE_EXN_ID: "Not_found", - Error: new Error() - }; - }), "Not_found"); - Test_utils.eq("File \"js_exception_catch_test.res\", line 37, characters 7-14", testException(() => Pervasives.invalid_arg("x")), "Invalid_argument"); - Test_utils.eq("File \"js_exception_catch_test.res\", line 38, characters 7-14", testException(() => Pervasives.invalid_arg("")), "Invalid_any"); - Test_utils.eq("File \"js_exception_catch_test.res\", line 39, characters 7-14", testException(() => { - throw { - RE_EXN_ID: A, - _1: 2, - Error: new Error() - }; - }), "A2"); - Test_utils.eq("File \"js_exception_catch_test.res\", line 40, characters 7-14", testException(() => { - throw { - RE_EXN_ID: A, - _1: 3, - Error: new Error() - }; - }), "A_any"); - Test_utils.eq("File \"js_exception_catch_test.res\", line 41, characters 7-14", testException(() => { - throw { - RE_EXN_ID: B, - Error: new Error() - }; - }), "B"); - Test_utils.eq("File \"js_exception_catch_test.res\", line 42, characters 7-14", testException(() => { - throw { - RE_EXN_ID: C, - _1: 1, - _2: 2, - Error: new Error() - }; - }), "C"); - Test_utils.eq("File \"js_exception_catch_test.res\", line 43, characters 7-14", testException(() => { - throw { - RE_EXN_ID: C, - _1: 0, - _2: 2, - Error: new Error() - }; - }), "C_any"); - Test_utils.eq("File \"js_exception_catch_test.res\", line 44, characters 7-14", testException(() => Stdlib_Exn.raiseError("x")), "Js_error"); - Test_utils.eq("File \"js_exception_catch_test.res\", line 45, characters 7-14", testException(() => Pervasives.failwith("x")), "Any"); - }); -}); - -export { - A, - B, - C, - testException, -} -/* Not a pure module */ diff --git a/tests/tests/src/js_exception_catch_test.res b/tests/tests/src/js_exception_catch_test.res deleted file mode 100644 index 770158422c8..00000000000 --- a/tests/tests/src/js_exception_catch_test.res +++ /dev/null @@ -1,47 +0,0 @@ -open Mocha -open Test_utils -open Js - -test("js_exception_catch_test_json_parse", () => { - switch Js.Json.parseExn(` {"x"}`) { - | exception Js.Exn.Error(x) => ok(__LOC__, true) - | e => ok(__LOC__, false) - } -}) - -exception A(int) -exception B -exception C(int, int) - -let testException = f => - try { - f() - #No_error - } catch { - | Not_found => #Not_found - | Invalid_argument("x") => #Invalid_argument - | Invalid_argument(_) => #Invalid_any - | A(2) => #A2 - | A(_) => #A_any - | B => #B - | C(1, 2) => #C - | C(_) => #C_any - | Js.Exn.Error(_) => #Js_error - | e => #Any - } - -describe(__MODULE__, () => { - test("js exception catch test", () => { - eq(__LOC__, testException(_ => ()), #No_error) - eq(__LOC__, testException(_ => throw(Not_found)), #Not_found) - eq(__LOC__, testException(_ => invalid_arg("x")), #Invalid_argument) - eq(__LOC__, testException(_ => invalid_arg("")), #Invalid_any) - eq(__LOC__, testException(_ => throw(A(2))), #A2) - eq(__LOC__, testException(_ => throw(A(3))), #A_any) - eq(__LOC__, testException(_ => throw(B)), #B) - eq(__LOC__, testException(_ => throw(C(1, 2))), #C) - eq(__LOC__, testException(_ => throw(C(0, 2))), #C_any) - eq(__LOC__, testException(_ => Js.Exn.raiseError("x")), #Js_error) - eq(__LOC__, testException(_ => failwith("x")), #Any) - }) -}) diff --git a/tests/tests/src/js_float_test.mjs b/tests/tests/src/js_float_test.mjs deleted file mode 100644 index ab7864b04bd..00000000000 --- a/tests/tests/src/js_float_test.mjs +++ /dev/null @@ -1,53 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Mocha from "mocha"; -import * as Pervasives from "@rescript/runtime/lib/es6/Pervasives.mjs"; -import * as Test_utils from "./test_utils.mjs"; - -Mocha.describe("Js_float_test", () => { - Mocha.test("_NaN <> _NaN", () => Test_utils.eq("File \"js_float_test.res\", line 6, characters 32-39", false, NaN === NaN)); - Mocha.test("isNaN - _NaN", () => Test_utils.eq("File \"js_float_test.res\", line 7, characters 32-39", true, Number.isNaN(NaN))); - Mocha.test("isNaN - 0.", () => Test_utils.eq("File \"js_float_test.res\", line 8, characters 30-37", false, Number.isNaN(0))); - Mocha.test("isFinite - infinity", () => Test_utils.eq("File \"js_float_test.res\", line 9, characters 39-46", false, Number.isFinite(Pervasives.infinity))); - Mocha.test("isFinite - neg_infinity", () => Test_utils.eq("File \"js_float_test.res\", line 10, characters 43-50", false, Number.isFinite(Pervasives.neg_infinity))); - Mocha.test("isFinite - _NaN", () => Test_utils.eq("File \"js_float_test.res\", line 11, characters 35-42", false, Number.isFinite(NaN))); - Mocha.test("isFinite - 0.", () => Test_utils.eq("File \"js_float_test.res\", line 12, characters 33-40", true, Number.isFinite(0))); - Mocha.test("toExponential", () => Test_utils.eq("File \"js_float_test.res\", line 13, characters 33-40", "1.23456e+2", (123.456).toExponential())); - Mocha.test("toExponential - large number", () => Test_utils.eq("File \"js_float_test.res\", line 14, characters 48-55", "1.2e+21", (1.2e21).toExponential())); - Mocha.test("toExponentialWithPrecision - digits:2", () => Test_utils.eq("File \"js_float_test.res\", line 16, characters 7-14", "1.23e+2", (123.456).toExponential(2))); - Mocha.test("toExponentialWithPrecision - digits:4", () => Test_utils.eq("File \"js_float_test.res\", line 19, characters 7-14", "1.2346e+2", (123.456).toExponential(4))); - Mocha.test("toExponentialWithPrecision - digits:20", () => Test_utils.eq("File \"js_float_test.res\", line 22, characters 7-14", "0.00000000000000000000e+0", (0).toExponential(20))); - Mocha.test("toExponentialWithPrecision - digits:101", () => Test_utils.throws("File \"js_float_test.res\", line 25, characters 11-18", () => (0).toExponential(101))); - Mocha.test("toExponentialWithPrecision - digits:-1", () => Test_utils.throws("File \"js_float_test.res\", line 28, characters 11-18", () => (0).toExponential(-1))); - Mocha.test("toFixed", () => Test_utils.eq("File \"js_float_test.res\", line 30, characters 27-34", "123", (123.456).toFixed())); - Mocha.test("toFixed - large number", () => Test_utils.eq("File \"js_float_test.res\", line 31, characters 42-49", "1.2e+21", (1.2e21).toFixed())); - Mocha.test("toFixedWithPrecision - digits:2", () => Test_utils.eq("File \"js_float_test.res\", line 33, characters 7-14", "123.46", (123.456).toFixed(2))); - Mocha.test("toFixedWithPrecision - digits:4", () => Test_utils.eq("File \"js_float_test.res\", line 36, characters 7-14", "123.4560", (123.456).toFixed(4))); - Mocha.test("toFixedWithPrecision - digits:20", () => Test_utils.eq("File \"js_float_test.res\", line 39, characters 7-14", "0.00000000000000000000", (0).toFixed(20))); - Mocha.test("toFixedWithPrecision - digits:101", () => Test_utils.throws("File \"js_float_test.res\", line 42, characters 11-18", () => (0).toFixed(101))); - Mocha.test("toFixedWithPrecision - digits:-1", () => Test_utils.throws("File \"js_float_test.res\", line 45, characters 11-18", () => (0).toFixed(-1))); - Mocha.test("toPrecision", () => Test_utils.eq("File \"js_float_test.res\", line 47, characters 31-38", "123.456", (123.456).toPrecision())); - Mocha.test("toPrecision - large number", () => Test_utils.eq("File \"js_float_test.res\", line 48, characters 46-53", "1.2e+21", (1.2e21).toPrecision())); - Mocha.test("toPrecisionWithPrecision - digits:2", () => Test_utils.eq("File \"js_float_test.res\", line 50, characters 7-14", "1.2e+2", (123.456).toPrecision(2))); - Mocha.test("toPrecisionWithPrecision - digits:4", () => Test_utils.eq("File \"js_float_test.res\", line 53, characters 7-14", "123.5", (123.456).toPrecision(4))); - Mocha.test("toPrecisionWithPrecision - digits:20", () => Test_utils.eq("File \"js_float_test.res\", line 56, characters 7-14", "0.0000000000000000000", (0).toPrecision(20))); - Mocha.test("toPrecisionWithPrecision - digits:101", () => Test_utils.throws("File \"js_float_test.res\", line 59, characters 11-18", () => (0).toPrecision(101))); - Mocha.test("toPrecisionWithPrecision - digits:-1", () => Test_utils.throws("File \"js_float_test.res\", line 62, characters 11-18", () => (0).toPrecision(-1))); - Mocha.test("toString", () => Test_utils.eq("File \"js_float_test.res\", line 64, characters 28-35", "1.23", (1.23).toString())); - Mocha.test("toString - large number", () => Test_utils.eq("File \"js_float_test.res\", line 65, characters 43-50", "1.2e+21", (1.2e21).toString())); - Mocha.test("toStringWithRadix - radix:2", () => Test_utils.eq("File \"js_float_test.res\", line 68, characters 6-13", "1111011.0111010010111100011010100111111011111001110111", (123.456).toString(2))); - Mocha.test("toStringWithRadix - radix:16", () => Test_utils.eq("File \"js_float_test.res\", line 74, characters 7-14", "7b.74bc6a7ef9dc", (123.456).toString(16))); - Mocha.test("toStringWithRadix - radix:36", () => Test_utils.eq("File \"js_float_test.res\", line 76, characters 48-55", "3f", (123).toString(36))); - Mocha.test("toStringWithRadix - radix:37", () => Test_utils.throws("File \"js_float_test.res\", line 78, characters 11-18", () => (0).toString(37))); - Mocha.test("toStringWithRadix - radix:1", () => Test_utils.throws("File \"js_float_test.res\", line 81, characters 11-18", () => (0).toString(1))); - Mocha.test("toStringWithRadix - radix:-1", () => Test_utils.throws("File \"js_float_test.res\", line 84, characters 11-18", () => (0).toString(-1))); - Mocha.test("fromString - 123", () => Test_utils.eq("File \"js_float_test.res\", line 86, characters 36-43", 123, Number("123"))); - Mocha.test("fromString - 12.3", () => Test_utils.eq("File \"js_float_test.res\", line 87, characters 37-44", 12.3, Number("12.3"))); - Mocha.test("fromString - empty string", () => Test_utils.eq("File \"js_float_test.res\", line 88, characters 45-52", 0, Number(""))); - Mocha.test("fromString - 0x11", () => Test_utils.eq("File \"js_float_test.res\", line 89, characters 37-44", 17, Number("0x11"))); - Mocha.test("fromString - 0b11", () => Test_utils.eq("File \"js_float_test.res\", line 90, characters 37-44", 3, Number("0b11"))); - Mocha.test("fromString - 0o11", () => Test_utils.eq("File \"js_float_test.res\", line 91, characters 37-44", 9, Number("0o11"))); - Mocha.test("fromString - invalid string", () => Test_utils.eq("File \"js_float_test.res\", line 92, characters 47-54", true, Number.isNaN(Number("foo")))); -}); - -/* Not a pure module */ diff --git a/tests/tests/src/js_float_test.res b/tests/tests/src/js_float_test.res deleted file mode 100644 index 91a11005ea8..00000000000 --- a/tests/tests/src/js_float_test.res +++ /dev/null @@ -1,93 +0,0 @@ -open Mocha -open Test_utils -open Js.Float - -describe(__MODULE__, () => { - test("_NaN <> _NaN", () => eq(__LOC__, false, _NaN == _NaN)) - test("isNaN - _NaN", () => eq(__LOC__, true, isNaN(_NaN))) - test("isNaN - 0.", () => eq(__LOC__, false, isNaN(0.))) - test("isFinite - infinity", () => eq(__LOC__, false, isFinite(infinity))) - test("isFinite - neg_infinity", () => eq(__LOC__, false, isFinite(neg_infinity))) - test("isFinite - _NaN", () => eq(__LOC__, false, isFinite(_NaN))) - test("isFinite - 0.", () => eq(__LOC__, true, isFinite(0.))) - test("toExponential", () => eq(__LOC__, "1.23456e+2", toExponential(123.456))) - test("toExponential - large number", () => eq(__LOC__, "1.2e+21", toExponential(1.2e21))) - test("toExponentialWithPrecision - digits:2", () => - eq(__LOC__, "1.23e+2", toExponentialWithPrecision(123.456, ~digits=2)) - ) - test("toExponentialWithPrecision - digits:4", () => - eq(__LOC__, "1.2346e+2", toExponentialWithPrecision(123.456, ~digits=4)) - ) - test("toExponentialWithPrecision - digits:20", () => - eq(__LOC__, "0.00000000000000000000e+0", toExponentialWithPrecision(0., ~digits=20)) - ) - test("toExponentialWithPrecision - digits:101", () => { - throws(__LOC__, () => toExponentialWithPrecision(0., ~digits=101)) - }) - test("toExponentialWithPrecision - digits:-1", () => { - throws(__LOC__, () => toExponentialWithPrecision(0., ~digits=-1)) - }) - test("toFixed", () => eq(__LOC__, "123", toFixed(123.456))) - test("toFixed - large number", () => eq(__LOC__, "1.2e+21", toFixed(1.2e21))) - test("toFixedWithPrecision - digits:2", () => - eq(__LOC__, "123.46", toFixedWithPrecision(123.456, ~digits=2)) - ) - test("toFixedWithPrecision - digits:4", () => - eq(__LOC__, "123.4560", toFixedWithPrecision(123.456, ~digits=4)) - ) - test("toFixedWithPrecision - digits:20", () => - eq(__LOC__, "0.00000000000000000000", toFixedWithPrecision(0., ~digits=20)) - ) - test("toFixedWithPrecision - digits:101", () => { - throws(__LOC__, () => toFixedWithPrecision(0., ~digits=101)) - }) - test("toFixedWithPrecision - digits:-1", () => { - throws(__LOC__, () => toFixedWithPrecision(0., ~digits=-1)) - }) - test("toPrecision", () => eq(__LOC__, "123.456", toPrecision(123.456))) - test("toPrecision - large number", () => eq(__LOC__, "1.2e+21", toPrecision(1.2e21))) - test("toPrecisionWithPrecision - digits:2", () => - eq(__LOC__, "1.2e+2", toPrecisionWithPrecision(123.456, ~digits=2)) - ) - test("toPrecisionWithPrecision - digits:4", () => - eq(__LOC__, "123.5", toPrecisionWithPrecision(123.456, ~digits=4)) - ) - test("toPrecisionWithPrecision - digits:20", () => - eq(__LOC__, "0.0000000000000000000", toPrecisionWithPrecision(0., ~digits=20)) - ) - test("toPrecisionWithPrecision - digits:101", () => { - throws(__LOC__, () => toPrecisionWithPrecision(0., ~digits=101)) - }) - test("toPrecisionWithPrecision - digits:-1", () => { - throws(__LOC__, () => toPrecisionWithPrecision(0., ~digits=-1)) - }) - test("toString", () => eq(__LOC__, "1.23", toString(1.23))) - test("toString - large number", () => eq(__LOC__, "1.2e+21", toString(1.2e21))) - test("toStringWithRadix - radix:2", () => - eq( - __LOC__, - "1111011.0111010010111100011010100111111011111001110111", - toStringWithRadix(123.456, ~radix=2), - ) - ) - test("toStringWithRadix - radix:16", () => - eq(__LOC__, "7b.74bc6a7ef9dc", toStringWithRadix(123.456, ~radix=16)) - ) - test("toStringWithRadix - radix:36", () => eq(__LOC__, "3f", toStringWithRadix(123., ~radix=36))) - test("toStringWithRadix - radix:37", () => { - throws(__LOC__, () => toStringWithRadix(0., ~radix=37)) - }) - test("toStringWithRadix - radix:1", () => { - throws(__LOC__, () => toStringWithRadix(0., ~radix=1)) - }) - test("toStringWithRadix - radix:-1", () => { - throws(__LOC__, () => toStringWithRadix(0., ~radix=-1)) - }) - test("fromString - 123", () => eq(__LOC__, 123., fromString("123"))) - test("fromString - 12.3", () => eq(__LOC__, 12.3, fromString("12.3"))) - test("fromString - empty string", () => eq(__LOC__, 0., fromString(""))) - test("fromString - 0x11", () => eq(__LOC__, 17., fromString("0x11"))) - test("fromString - 0b11", () => eq(__LOC__, 3., fromString("0b11"))) - test("fromString - 0o11", () => eq(__LOC__, 9., fromString("0o11"))) - test("fromString - invalid string", () => eq(__LOC__, true, isNaN(fromString("foo")))) -}) diff --git a/tests/tests/src/js_global_test.mjs b/tests/tests/src/js_global_test.mjs deleted file mode 100644 index 66d1790e5b8..00000000000 --- a/tests/tests/src/js_global_test.mjs +++ /dev/null @@ -1,23 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Mocha from "mocha"; -import * as Test_utils from "./test_utils.mjs"; - -Mocha.describe("Js_global_test", () => { - Mocha.test("setTimeout/clearTimeout sanity check", () => { - let handle = setTimeout(() => {}, 0); - clearTimeout(handle); - Test_utils.eq("File \"js_global_test.res\", line 9, characters 7-14", true, true); - }); - Mocha.test("setInterval/clearInterval sanity check", () => { - let handle = setInterval(() => {}, 0); - clearInterval(handle); - Test_utils.eq("File \"js_global_test.res\", line 14, characters 7-14", true, true); - }); - Mocha.test("encodeURI", () => Test_utils.eq("File \"js_global_test.res\", line 17, characters 7-14", "%5B-=-%5D", encodeURI("[-=-]"))); - Mocha.test("decodeURI", () => Test_utils.eq("File \"js_global_test.res\", line 20, characters 7-14", "[-=-]", decodeURI("%5B-=-%5D"))); - Mocha.test("encodeURIComponent", () => Test_utils.eq("File \"js_global_test.res\", line 23, characters 7-14", "%5B-%3D-%5D", encodeURIComponent("[-=-]"))); - Mocha.test("decodeURIComponent", () => Test_utils.eq("File \"js_global_test.res\", line 26, characters 7-14", "[-=-]", decodeURIComponent("%5B-%3D-%5D"))); -}); - -/* Not a pure module */ diff --git a/tests/tests/src/js_global_test.res b/tests/tests/src/js_global_test.res deleted file mode 100644 index fb0fdbe758d..00000000000 --- a/tests/tests/src/js_global_test.res +++ /dev/null @@ -1,28 +0,0 @@ -open Js_global -open Mocha -open Test_utils - -describe(__MODULE__, () => { - test("setTimeout/clearTimeout sanity check", () => { - let handle = setTimeout(() => (), 0) - clearTimeout(handle) - eq(__LOC__, true, true) - }) - test("setInterval/clearInterval sanity check", () => { - let handle = setInterval(() => (), 0) - clearInterval(handle) - eq(__LOC__, true, true) - }) - test("encodeURI", () => { - eq(__LOC__, "%5B-=-%5D", encodeURI("[-=-]")) - }) - test("decodeURI", () => { - eq(__LOC__, "[-=-]", decodeURI("%5B-=-%5D")) - }) - test("encodeURIComponent", () => { - eq(__LOC__, "%5B-%3D-%5D", encodeURIComponent("[-=-]")) - }) - test("decodeURIComponent", () => { - eq(__LOC__, "[-=-]", decodeURIComponent("%5B-%3D-%5D")) - }) -}) diff --git a/tests/tests/src/js_int_test.mjs b/tests/tests/src/js_int_test.mjs deleted file mode 100644 index 2e067a8de45..00000000000 --- a/tests/tests/src/js_int_test.mjs +++ /dev/null @@ -1,42 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Mocha from "mocha"; -import * as Test_utils from "./test_utils.mjs"; - -Mocha.describe("Js_int_test", () => { - Mocha.test("toExponential", () => Test_utils.eq("File \"js_int_test.res\", line 7, characters 7-14", "1.23456e+5", (123456).toExponential())); - Mocha.test("toExponentialWithPrecision - digits:2", () => Test_utils.eq("File \"js_int_test.res\", line 11, characters 7-14", "1.23e+5", (123456).toExponential(2))); - Mocha.test("toExponentialWithPrecision - digits:4", () => Test_utils.eq("File \"js_int_test.res\", line 15, characters 7-14", "1.2346e+5", (123456).toExponential(4))); - Mocha.test("toExponentialWithPrecision - digits:20", () => Test_utils.eq("File \"js_int_test.res\", line 19, characters 7-14", "0.00000000000000000000e+0", (0).toExponential(20))); - Mocha.test("toExponentialWithPrecision - digits:101 throws", () => Test_utils.throws("File \"js_int_test.res\", line 23, characters 11-18", () => { - (0).toExponential(101); - })); - Mocha.test("toExponentialWithPrecision - digits:-1 throws", () => Test_utils.throws("File \"js_int_test.res\", line 27, characters 11-18", () => { - (0).toExponential(-1); - })); - Mocha.test("toPrecision", () => Test_utils.eq("File \"js_int_test.res\", line 31, characters 7-14", "123456", (123456).toPrecision())); - Mocha.test("toPrecisionWithPrecision - digits:2", () => Test_utils.eq("File \"js_int_test.res\", line 35, characters 7-14", "1.2e+5", (123456).toPrecision(2))); - Mocha.test("toPrecisionWithPrecision - digits:4", () => Test_utils.eq("File \"js_int_test.res\", line 39, characters 7-14", "1.235e+5", (123456).toPrecision(4))); - Mocha.test("toPrecisionWithPrecision - digits:20", () => Test_utils.eq("File \"js_int_test.res\", line 43, characters 7-14", "0.0000000000000000000", (0).toPrecision(20))); - Mocha.test("toPrecisionWithPrecision - digits:101 throws", () => Test_utils.throws("File \"js_int_test.res\", line 47, characters 11-18", () => { - (0).toPrecision(101); - })); - Mocha.test("toPrecisionWithPrecision - digits:-1 throws", () => Test_utils.throws("File \"js_int_test.res\", line 51, characters 11-18", () => { - (0).toPrecision(-1); - })); - Mocha.test("toString", () => Test_utils.eq("File \"js_int_test.res\", line 55, characters 7-14", "123", (123).toString())); - Mocha.test("toStringWithRadix - radix:2", () => Test_utils.eq("File \"js_int_test.res\", line 59, characters 7-14", "11110001001000000", (123456).toString(2))); - Mocha.test("toStringWithRadix - radix:16", () => Test_utils.eq("File \"js_int_test.res\", line 63, characters 7-14", "1e240", (123456).toString(16))); - Mocha.test("toStringWithRadix - radix:36", () => Test_utils.eq("File \"js_int_test.res\", line 67, characters 7-14", "2n9c", (123456).toString(36))); - Mocha.test("toStringWithRadix - radix:37 throws", () => Test_utils.throws("File \"js_int_test.res\", line 71, characters 11-18", () => { - (0).toString(37); - })); - Mocha.test("toStringWithRadix - radix:1 throws", () => Test_utils.throws("File \"js_int_test.res\", line 75, characters 11-18", () => { - (0).toString(1); - })); - Mocha.test("toStringWithRadix - radix:-1 throws", () => Test_utils.throws("File \"js_int_test.res\", line 79, characters 11-18", () => { - (0).toString(-1); - })); -}); - -/* Not a pure module */ diff --git a/tests/tests/src/js_int_test.res b/tests/tests/src/js_int_test.res deleted file mode 100644 index e083a7d403d..00000000000 --- a/tests/tests/src/js_int_test.res +++ /dev/null @@ -1,81 +0,0 @@ -open Js_int -open Mocha -open Test_utils - -describe(__MODULE__, () => { - test("toExponential", () => { - eq(__LOC__, "1.23456e+5", toExponential(123456)) - }) - - test("toExponentialWithPrecision - digits:2", () => { - eq(__LOC__, "1.23e+5", toExponentialWithPrecision(123456, ~digits=2)) - }) - - test("toExponentialWithPrecision - digits:4", () => { - eq(__LOC__, "1.2346e+5", toExponentialWithPrecision(123456, ~digits=4)) - }) - - test("toExponentialWithPrecision - digits:20", () => { - eq(__LOC__, "0.00000000000000000000e+0", toExponentialWithPrecision(0, ~digits=20)) - }) - - test("toExponentialWithPrecision - digits:101 throws", () => { - throws(__LOC__, () => ignore(toExponentialWithPrecision(0, ~digits=101))) - }) - - test("toExponentialWithPrecision - digits:-1 throws", () => { - throws(__LOC__, () => ignore(toExponentialWithPrecision(0, ~digits=-1))) - }) - - test("toPrecision", () => { - eq(__LOC__, "123456", toPrecision(123456)) - }) - - test("toPrecisionWithPrecision - digits:2", () => { - eq(__LOC__, "1.2e+5", toPrecisionWithPrecision(123456, ~digits=2)) - }) - - test("toPrecisionWithPrecision - digits:4", () => { - eq(__LOC__, "1.235e+5", toPrecisionWithPrecision(123456, ~digits=4)) - }) - - test("toPrecisionWithPrecision - digits:20", () => { - eq(__LOC__, "0.0000000000000000000", toPrecisionWithPrecision(0, ~digits=20)) - }) - - test("toPrecisionWithPrecision - digits:101 throws", () => { - throws(__LOC__, () => ignore(toPrecisionWithPrecision(0, ~digits=101))) - }) - - test("toPrecisionWithPrecision - digits:-1 throws", () => { - throws(__LOC__, () => ignore(toPrecisionWithPrecision(0, ~digits=-1))) - }) - - test("toString", () => { - eq(__LOC__, "123", toString(123)) - }) - - test("toStringWithRadix - radix:2", () => { - eq(__LOC__, "11110001001000000", toStringWithRadix(123456, ~radix=2)) - }) - - test("toStringWithRadix - radix:16", () => { - eq(__LOC__, "1e240", toStringWithRadix(123456, ~radix=16)) - }) - - test("toStringWithRadix - radix:36", () => { - eq(__LOC__, "2n9c", toStringWithRadix(123456, ~radix=36)) - }) - - test("toStringWithRadix - radix:37 throws", () => { - throws(__LOC__, () => ignore(toStringWithRadix(0, ~radix=37))) - }) - - test("toStringWithRadix - radix:1 throws", () => { - throws(__LOC__, () => ignore(toStringWithRadix(0, ~radix=1))) - }) - - test("toStringWithRadix - radix:-1 throws", () => { - throws(__LOC__, () => ignore(toStringWithRadix(0, ~radix=-1))) - }) -}) diff --git a/tests/tests/src/js_json_test.mjs b/tests/tests/src/js_json_test.mjs deleted file mode 100644 index abdae939649..00000000000 --- a/tests/tests/src/js_json_test.mjs +++ /dev/null @@ -1,482 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Mocha from "mocha"; -import * as Js_dict from "@rescript/runtime/lib/es6/Js_dict.mjs"; -import * as Js_json from "@rescript/runtime/lib/es6/Js_json.mjs"; -import * as Belt_List from "@rescript/runtime/lib/es6/Belt_List.mjs"; -import * as Belt_Array from "@rescript/runtime/lib/es6/Belt_Array.mjs"; -import * as Test_utils from "./test_utils.mjs"; -import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.mjs"; - -Mocha.describe("Js_json_test", () => { - Mocha.test("JSON object parsing and validation", () => { - let v = JSON.parse(` { "x" : [1, 2, 3 ] } `); - let ty = Js_json.classify(v); - if (typeof ty !== "object" || ty.TAG !== "JSONObject") { - Test_utils.ok("File \"js_json_test.res\", line 35, characters 14-21", false); - } else { - let v$1 = Js_dict.get(ty._0, "x"); - if (v$1 !== undefined) { - let ty2 = Js_json.classify(v$1); - if (typeof ty2 !== "object" || ty2.TAG !== "JSONArray") { - Test_utils.ok("File \"js_json_test.res\", line 31, characters 18-25", false); - } else { - ty2._0.forEach(x => { - let ty3 = Js_json.classify(x); - if (typeof ty3 !== "object") { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "js_json_test.res", - 26, - 21 - ], - Error: new Error() - }; - } - if (ty3.TAG === "JSONNumber") { - return; - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "js_json_test.res", - 26, - 21 - ], - Error: new Error() - }; - }); - Test_utils.ok("File \"js_json_test.res\", line 30, characters 13-20", true); - } - } else { - Test_utils.ok("File \"js_json_test.res\", line 33, characters 19-26", false); - } - } - Test_utils.eq("File \"js_json_test.res\", line 38, characters 7-14", Js_json.test(v, "Object"), true); - }); - Mocha.test("JSON null parsing", () => { - let json = JSON.parse(JSON.stringify(null)); - let ty = Js_json.classify(json); - if (typeof ty !== "object") { - if (ty === "JSONNull") { - return Test_utils.ok("File \"js_json_test.res\", line 45, characters 23-30", true); - } - console.log(ty); - return Test_utils.ok("File \"js_json_test.res\", line 48, characters 9-16", false); - } else { - console.log(ty); - return Test_utils.ok("File \"js_json_test.res\", line 48, characters 9-16", false); - } - }); - Mocha.test("JSON string parsing", () => { - let json = JSON.parse(JSON.stringify("test string")); - let ty = Js_json.classify(json); - if (typeof ty !== "object" || ty.TAG !== "JSONString") { - return Test_utils.ok("File \"js_json_test.res\", line 57, characters 14-21", false); - } else { - return Test_utils.eq("File \"js_json_test.res\", line 56, characters 28-35", ty._0, "test string"); - } - }); - Mocha.test("JSON number parsing", () => { - let json = JSON.parse(JSON.stringify(1.23456789)); - let ty = Js_json.classify(json); - if (typeof ty !== "object" || ty.TAG !== "JSONNumber") { - return Test_utils.ok("File \"js_json_test.res\", line 66, characters 14-21", false); - } else { - return Test_utils.eq("File \"js_json_test.res\", line 65, characters 28-35", ty._0, 1.23456789); - } - }); - Mocha.test("JSON large integer parsing", () => { - let json = JSON.parse(JSON.stringify(-1347440721)); - let ty = Js_json.classify(json); - if (typeof ty !== "object" || ty.TAG !== "JSONNumber") { - return Test_utils.ok("File \"js_json_test.res\", line 75, characters 14-21", false); - } else { - return Test_utils.eq("File \"js_json_test.res\", line 74, characters 28-35", ty._0 | 0, -1347440721); - } - }); - Mocha.test("JSON boolean parsing", () => { - let test = v => { - let json = JSON.parse(JSON.stringify(v)); - let ty = Js_json.classify(json); - if (typeof ty === "object") { - return Test_utils.ok("File \"js_json_test.res\", line 86, characters 16-23", false); - } - switch (ty) { - case "JSONFalse" : - return Test_utils.eq("File \"js_json_test.res\", line 85, characters 26-33", false, v); - case "JSONTrue" : - return Test_utils.eq("File \"js_json_test.res\", line 84, characters 25-32", true, v); - default: - return Test_utils.ok("File \"js_json_test.res\", line 86, characters 16-23", false); - } - }; - test(true); - test(false); - }); - Mocha.test("JSON object with string and number fields", () => { - let option_get = x => { - if (x !== undefined) { - return Primitive_option.valFromOption(x); - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "js_json_test.res", - 97, - 16 - ], - Error: new Error() - }; - }; - let dict = {}; - dict["a"] = "test string"; - dict["b"] = 123.0; - let json = JSON.parse(JSON.stringify(dict)); - let ty = Js_json.classify(json); - if (typeof ty !== "object") { - return Test_utils.ok("File \"js_json_test.res\", line 127, characters 14-21", false); - } - if (ty.TAG !== "JSONObject") { - return Test_utils.ok("File \"js_json_test.res\", line 127, characters 14-21", false); - } - let x = ty._0; - let ta = Js_json.classify(option_get(Js_dict.get(x, "a"))); - if (typeof ta !== "object") { - return Test_utils.ok("File \"js_json_test.res\", line 125, characters 16-23", false); - } - if (ta.TAG !== "JSONString") { - return Test_utils.ok("File \"js_json_test.res\", line 125, characters 16-23", false); - } - if (ta._0 !== "test string") { - return Test_utils.ok("File \"js_json_test.res\", line 116, characters 13-20", false); - } - let ty$1 = Js_json.classify(option_get(Js_dict.get(x, "b"))); - if (typeof ty$1 !== "object" || ty$1.TAG !== "JSONNumber") { - return Test_utils.ok("File \"js_json_test.res\", line 122, characters 20-27", false); - } else { - return Test_utils.approxEq("File \"js_json_test.res\", line 121, characters 40-47", 0.001, 123.0, ty$1._0); - } - }); - let eq_at_i = (loc, json, i, kind, expected) => { - let ty = Js_json.classify(json); - if (typeof ty !== "object") { - return Test_utils.ok(loc, false); - } - if (ty.TAG !== "JSONArray") { - return Test_utils.ok(loc, false); - } - let ty$1 = Js_json.classify(ty._0[i]); - switch (kind) { - case "String" : - if (typeof ty$1 !== "object" || ty$1.TAG !== "JSONString") { - return Test_utils.ok(loc, false); - } else { - return Test_utils.eq(loc, ty$1._0, expected); - } - case "Number" : - if (typeof ty$1 !== "object" || ty$1.TAG !== "JSONNumber") { - return Test_utils.ok(loc, false); - } else { - return Test_utils.eq(loc, ty$1._0, expected); - } - case "Object" : - if (typeof ty$1 !== "object" || ty$1.TAG !== "JSONObject") { - return Test_utils.ok(loc, false); - } else { - return Test_utils.eq(loc, ty$1._0, expected); - } - case "Array" : - if (typeof ty$1 !== "object" || ty$1.TAG !== "JSONArray") { - return Test_utils.ok(loc, false); - } else { - return Test_utils.eq(loc, ty$1._0, expected); - } - case "Boolean" : - if (typeof ty$1 === "object") { - return Test_utils.ok(loc, false); - } - switch (ty$1) { - case "JSONFalse" : - return Test_utils.eq(loc, false, expected); - case "JSONTrue" : - return Test_utils.eq(loc, true, expected); - default: - return Test_utils.ok(loc, false); - } - case "Null" : - if (typeof ty$1 !== "object" && ty$1 === "JSONNull") { - return Test_utils.ok(loc, true); - } else { - return Test_utils.ok(loc, false); - } - } - }; - Mocha.test("JSON string array parsing", () => { - let json = JSON.parse(JSON.stringify(Belt_Array.map([ - "string 0", - "string 1", - "string 2" - ], prim => prim))); - eq_at_i("File \"js_json_test.res\", line 180, characters 12-19", json, 0, "String", "string 0"); - eq_at_i("File \"js_json_test.res\", line 181, characters 12-19", json, 1, "String", "string 1"); - eq_at_i("File \"js_json_test.res\", line 182, characters 12-19", json, 2, "String", "string 2"); - }); - Mocha.test("JSON stringArray parsing", () => { - let json = JSON.parse(JSON.stringify([ - "string 0", - "string 1", - "string 2" - ])); - eq_at_i("File \"js_json_test.res\", line 188, characters 12-19", json, 0, "String", "string 0"); - eq_at_i("File \"js_json_test.res\", line 189, characters 12-19", json, 1, "String", "string 1"); - eq_at_i("File \"js_json_test.res\", line 190, characters 12-19", json, 2, "String", "string 2"); - }); - Mocha.test("JSON number array parsing", () => { - let a = [ - 1.0000001, - 10000000000.1, - 123.0 - ]; - let json = JSON.parse(JSON.stringify(a)); - eq_at_i("File \"js_json_test.res\", line 198, characters 12-19", json, 0, "Number", a[0]); - eq_at_i("File \"js_json_test.res\", line 199, characters 12-19", json, 1, "Number", a[1]); - eq_at_i("File \"js_json_test.res\", line 200, characters 12-19", json, 2, "Number", a[2]); - }); - Mocha.test("JSON integer array parsing", () => { - let a = [ - 0, - -1347440721, - -268391749 - ]; - let json = JSON.parse(JSON.stringify(Belt_Array.map(a, prim => prim))); - eq_at_i("File \"js_json_test.res\", line 208, characters 12-19", json, 0, "Number", a[0]); - eq_at_i("File \"js_json_test.res\", line 209, characters 12-19", json, 1, "Number", a[1]); - eq_at_i("File \"js_json_test.res\", line 210, characters 12-19", json, 2, "Number", a[2]); - }); - Mocha.test("JSON boolean array parsing", () => { - let a = [ - true, - false, - true - ]; - let json = JSON.parse(JSON.stringify(a)); - eq_at_i("File \"js_json_test.res\", line 218, characters 12-19", json, 0, "Boolean", a[0]); - eq_at_i("File \"js_json_test.res\", line 219, characters 12-19", json, 1, "Boolean", a[1]); - eq_at_i("File \"js_json_test.res\", line 220, characters 12-19", json, 2, "Boolean", a[2]); - }); - Mocha.test("JSON object array parsing", () => { - let option_get = x => { - if (x !== undefined) { - return Primitive_option.valFromOption(x); - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "js_json_test.res", - 226, - 16 - ], - Error: new Error() - }; - }; - let make_d = (s, i) => { - let d = {}; - d["a"] = s; - d["b"] = i; - return d; - }; - let a = [ - make_d("aaa", 123), - make_d("bbb", 456) - ]; - let json = JSON.parse(JSON.stringify(a)); - let ty = Js_json.classify(json); - if (typeof ty !== "object") { - return Test_utils.ok("File \"js_json_test.res\", line 253, characters 14-21", false); - } - if (ty.TAG !== "JSONArray") { - return Test_utils.ok("File \"js_json_test.res\", line 253, characters 14-21", false); - } - let ty$1 = Js_json.classify(ty._0[1]); - if (typeof ty$1 !== "object") { - return Test_utils.ok("File \"js_json_test.res\", line 251, characters 16-23", false); - } - if (ty$1.TAG !== "JSONObject") { - return Test_utils.ok("File \"js_json_test.res\", line 251, characters 16-23", false); - } - let ty$2 = Js_json.classify(option_get(Js_dict.get(ty$1._0, "a"))); - if (typeof ty$2 !== "object" || ty$2.TAG !== "JSONString") { - return Test_utils.ok("File \"js_json_test.res\", line 249, characters 18-25", false); - } else { - return Test_utils.eq("File \"js_json_test.res\", line 248, characters 37-44", ty$2._0, "bbb"); - } - }); - Mocha.test("JSON invalid parsing", () => { - try { - JSON.parse("{{ A}"); - return Test_utils.ok("File \"js_json_test.res\", line 261, characters 9-16", false); - } catch (exn) { - return Test_utils.ok("File \"js_json_test.res\", line 263, characters 16-23", true); - } - }); - Mocha.test("JSON stringifyAny array", () => Test_utils.eq("File \"js_json_test.res\", line 268, characters 43-50", JSON.stringify([ - 1, - 2, - 3 - ]), "[1,2,3]")); - Mocha.test("JSON stringifyAny object", () => Test_utils.eq("File \"js_json_test.res\", line 272, characters 6-13", JSON.stringify({ - foo: 1, - bar: "hello", - baz: { - baaz: 10 - } - }), `{"foo":1,"bar":"hello","baz":{"baaz":10}}`)); - Mocha.test("JSON stringifyAny null", () => Test_utils.eq("File \"js_json_test.res\", line 278, characters 42-49", JSON.stringify(null), "null")); - Mocha.test("JSON stringifyAny undefined", () => Test_utils.eq("File \"js_json_test.res\", line 280, characters 47-54", JSON.stringify(undefined), undefined)); - Mocha.test("JSON decodeString", () => { - Test_utils.eq("File \"js_json_test.res\", line 283, characters 7-14", Js_json.decodeString("test"), "test"); - Test_utils.eq("File \"js_json_test.res\", line 284, characters 7-14", Js_json.decodeString(true), undefined); - Test_utils.eq("File \"js_json_test.res\", line 285, characters 7-14", Js_json.decodeString([]), undefined); - Test_utils.eq("File \"js_json_test.res\", line 286, characters 7-14", Js_json.decodeString(null), undefined); - Test_utils.eq("File \"js_json_test.res\", line 287, characters 7-14", Js_json.decodeString({}), undefined); - Test_utils.eq("File \"js_json_test.res\", line 288, characters 7-14", Js_json.decodeString(1.23), undefined); - }); - Mocha.test("JSON decodeNumber", () => { - Test_utils.eq("File \"js_json_test.res\", line 292, characters 7-14", Js_json.decodeNumber("test"), undefined); - Test_utils.eq("File \"js_json_test.res\", line 293, characters 7-14", Js_json.decodeNumber(true), undefined); - Test_utils.eq("File \"js_json_test.res\", line 294, characters 7-14", Js_json.decodeNumber([]), undefined); - Test_utils.eq("File \"js_json_test.res\", line 295, characters 7-14", Js_json.decodeNumber(null), undefined); - Test_utils.eq("File \"js_json_test.res\", line 296, characters 7-14", Js_json.decodeNumber({}), undefined); - Test_utils.eq("File \"js_json_test.res\", line 297, characters 7-14", Js_json.decodeNumber(1.23), 1.23); - }); - Mocha.test("JSON decodeObject", () => { - Test_utils.eq("File \"js_json_test.res\", line 301, characters 7-14", Js_json.decodeObject("test"), undefined); - Test_utils.eq("File \"js_json_test.res\", line 302, characters 7-14", Js_json.decodeObject(true), undefined); - Test_utils.eq("File \"js_json_test.res\", line 303, characters 7-14", Js_json.decodeObject([]), undefined); - Test_utils.eq("File \"js_json_test.res\", line 304, characters 7-14", Js_json.decodeObject(null), undefined); - Test_utils.eq("File \"js_json_test.res\", line 305, characters 7-14", Js_json.decodeObject({}), {}); - Test_utils.eq("File \"js_json_test.res\", line 306, characters 7-14", Js_json.decodeObject(1.23), undefined); - }); - Mocha.test("JSON decodeArray", () => { - Test_utils.eq("File \"js_json_test.res\", line 310, characters 7-14", Js_json.decodeArray("test"), undefined); - Test_utils.eq("File \"js_json_test.res\", line 311, characters 7-14", Js_json.decodeArray(true), undefined); - Test_utils.eq("File \"js_json_test.res\", line 312, characters 7-14", Js_json.decodeArray([]), []); - Test_utils.eq("File \"js_json_test.res\", line 313, characters 7-14", Js_json.decodeArray(null), undefined); - Test_utils.eq("File \"js_json_test.res\", line 314, characters 7-14", Js_json.decodeArray({}), undefined); - Test_utils.eq("File \"js_json_test.res\", line 315, characters 7-14", Js_json.decodeArray(1.23), undefined); - }); - Mocha.test("JSON Array/Object switch falls through to wildcard on null and array", () => { - let classifyArrayOrObject = json => { - if (Array.isArray(json)) { - return json.length; - } - if (json === null) { - return; - } - switch (typeof json) { - case "object" : - Js_dict.get(json, "x"); - return 0; - default: - return; - } - }; - Test_utils.eq("File \"js_json_test.res\", line 328, characters 7-14", classifyArrayOrObject(null), undefined); - Test_utils.eq("File \"js_json_test.res\", line 329, characters 7-14", classifyArrayOrObject([1]), 1); - Test_utils.eq("File \"js_json_test.res\", line 330, characters 7-14", classifyArrayOrObject({}), 0); - let classifyObjectOnly = json => { - if (json === null || Array.isArray(json)) { - return "default"; - } - switch (typeof json) { - case "string" : - return "String"; - case "object" : - return "Object"; - default: - return "default"; - } - }; - Test_utils.eq("File \"js_json_test.res\", line 340, characters 7-14", classifyObjectOnly(null), "default"); - Test_utils.eq("File \"js_json_test.res\", line 341, characters 7-14", classifyObjectOnly([]), "default"); - Test_utils.eq("File \"js_json_test.res\", line 342, characters 7-14", classifyObjectOnly({}), "Object"); - Test_utils.eq("File \"js_json_test.res\", line 343, characters 7-14", classifyObjectOnly("hi"), "String"); - }); - Mocha.test("JSON Object switch as statement guards null and array", () => { - let result = { - contents: "none" - }; - let classifyStatement = json => { - if (json === null || Array.isArray(json)) { - return; - } - switch (typeof json) { - case "object" : - result.contents = "object"; - return; - default: - return; - } - }; - result.contents = "none"; - classifyStatement(null); - Test_utils.eq("File \"js_json_test.res\", line 359, characters 7-14", result.contents, "none"); - result.contents = "none"; - classifyStatement([]); - Test_utils.eq("File \"js_json_test.res\", line 363, characters 7-14", result.contents, "none"); - result.contents = "none"; - classifyStatement({}); - Test_utils.eq("File \"js_json_test.res\", line 367, characters 7-14", result.contents, "object"); - }); - Mocha.test("JSON decodeBoolean", () => { - Test_utils.eq("File \"js_json_test.res\", line 371, characters 7-14", Js_json.decodeBoolean("test"), undefined); - Test_utils.eq("File \"js_json_test.res\", line 372, characters 7-14", Js_json.decodeBoolean(true), true); - Test_utils.eq("File \"js_json_test.res\", line 373, characters 7-14", Js_json.decodeBoolean([]), undefined); - Test_utils.eq("File \"js_json_test.res\", line 374, characters 7-14", Js_json.decodeBoolean(null), undefined); - Test_utils.eq("File \"js_json_test.res\", line 375, characters 7-14", Js_json.decodeBoolean({}), undefined); - Test_utils.eq("File \"js_json_test.res\", line 376, characters 7-14", Js_json.decodeBoolean(1.23), undefined); - }); - Mocha.test("JSON decodeNull", () => { - Test_utils.eq("File \"js_json_test.res\", line 380, characters 7-14", Js_json.decodeNull("test"), undefined); - Test_utils.eq("File \"js_json_test.res\", line 381, characters 7-14", Js_json.decodeNull(true), undefined); - Test_utils.eq("File \"js_json_test.res\", line 382, characters 7-14", Js_json.decodeNull([]), undefined); - Test_utils.eq("File \"js_json_test.res\", line 383, characters 7-14", Js_json.decodeNull(null), null); - Test_utils.eq("File \"js_json_test.res\", line 384, characters 7-14", Js_json.decodeNull({}), undefined); - Test_utils.eq("File \"js_json_test.res\", line 385, characters 7-14", Js_json.decodeNull(1.23), undefined); - }); - Mocha.test("JSON serialize/deserialize identity", () => { - let idtest = obj => Test_utils.eq("File \"js_json_test.res\", line 391, characters 27-34", obj, Js_json.deserializeUnsafe(Js_json.serializeExn(obj))); - idtest(undefined); - idtest({ - hd: [ - undefined, - undefined, - undefined - ], - tl: /* [] */0 - }); - idtest(Belt_List.makeBy(500, i => { - if (i % 2 === 0) { - return; - } else { - return 1; - } - })); - idtest(Belt_Array.makeBy(500, i => { - if (i % 2 === 0) { - return; - } else { - return 1; - } - })); - }); -}); - -let J; - -export { - J, -} -/* Not a pure module */ diff --git a/tests/tests/src/js_json_test.res b/tests/tests/src/js_json_test.res deleted file mode 100644 index e56f669a22a..00000000000 --- a/tests/tests/src/js_json_test.res +++ /dev/null @@ -1,417 +0,0 @@ -open Mocha -open Test_utils - -module J = Js.Json - -describe(__MODULE__, () => { - test("JSON object parsing and validation", () => { - let v = J.parseExn(` { "x" : [1, 2, 3 ] } `) - - let ty = J.classify(v) - switch ty { - | J.JSONObject(x) => - /* compiler infer x : J.t dict */ - switch Js.Dict.get(x, "x") { - | Some(v) => - let ty2 = J.classify(v) - switch ty2 { - | J.JSONArray(x) => - /* compiler infer x : J.t array */ - Js.Array2.forEach( - x, - x => { - let ty3 = J.classify(x) - switch ty3 { - | J.JSONNumber(_) => () - | _ => assert(false) - } - }, - ) - ok(__LOC__, true) - | _ => ok(__LOC__, false) - } - | None => ok(__LOC__, false) - } - | _ => ok(__LOC__, false) - } - - eq(__LOC__, J.test(v, Object), true) - }) - - test("JSON null parsing", () => { - let json = J.parseExn(J.stringify(J.null)) - let ty = J.classify(json) - switch ty { - | J.JSONNull => ok(__LOC__, true) - | _ => - Console.log(ty) - ok(__LOC__, false) - } - }) - - test("JSON string parsing", () => { - let json = J.parseExn(J.stringify(J.string("test string"))) - let ty = J.classify(json) - switch ty { - | J.JSONString(x) => eq(__LOC__, x, "test string") - | _ => ok(__LOC__, false) - } - }) - - test("JSON number parsing", () => { - let json = J.parseExn(J.stringify(J.number(1.23456789))) - let ty = J.classify(json) - switch ty { - | J.JSONNumber(x) => eq(__LOC__, x, 1.23456789) - | _ => ok(__LOC__, false) - } - }) - - test("JSON large integer parsing", () => { - let json = J.parseExn(J.stringify(J.number(float_of_int(0xAFAFAFAF)))) - let ty = J.classify(json) - switch ty { - | J.JSONNumber(x) => eq(__LOC__, int_of_float(x), 0xAFAFAFAF) - | _ => ok(__LOC__, false) - } - }) - - test("JSON boolean parsing", () => { - let test = v => { - let json = J.parseExn(J.stringify(J.boolean(v))) - let ty = J.classify(json) - switch ty { - | J.JSONTrue => eq(__LOC__, true, v) - | J.JSONFalse => eq(__LOC__, false, v) - | _ => ok(__LOC__, false) - } - } - - test(true) - test(false) - }) - - test("JSON object with string and number fields", () => { - let option_get = x => - switch x { - | None => assert(false) - | Some(x) => x - } - - let dict = Js_dict.empty() - Js_dict.set(dict, "a", J.string("test string")) - Js_dict.set(dict, "b", J.number(123.0)) - - let json = J.parseExn(J.stringify(J.object_(dict))) - - /* Make sure parsed as Object */ - let ty = J.classify(json) - switch ty { - | J.JSONObject(x) => - /* Test field 'a' */ - let ta = J.classify(option_get(Js_dict.get(x, "a"))) - switch ta { - | J.JSONString(a) => - if a != "test string" { - ok(__LOC__, false) - } else { - /* Test field 'b' */ - let ty = J.classify(option_get(Js_dict.get(x, "b"))) - switch ty { - | J.JSONNumber(b) => approxEq(__LOC__, 0.001, 123.0, b) - | _ => ok(__LOC__, false) - } - } - | _ => ok(__LOC__, false) - } - | _ => ok(__LOC__, false) - } - }) - - /* Check that the given json value is an array and that its element - * a position [i] is equal to both the [kind] and [expected] value */ - let eq_at_i = (type a, loc: string, json: J.t, i: int, kind: J.Kind.t, expected: a): unit => { - let ty = J.classify(json) - switch ty { - | J.JSONArray(x) => - let ty = J.classify(x->Array.getUnsafe(i)) - switch kind { - | J.Kind.Boolean => - switch ty { - | JSONTrue => eq(loc, true, expected) - | JSONFalse => eq(loc, false, expected) - | _ => ok(loc, false) - } - | J.Kind.Number => - switch ty { - | JSONNumber(f) => eq(loc, f, expected) - | _ => ok(loc, false) - } - | J.Kind.Object => - switch ty { - | JSONObject(f) => eq(loc, f, expected) - | _ => ok(loc, false) - } - | J.Kind.Array => - switch ty { - | JSONArray(f) => eq(loc, f, expected) - | _ => ok(loc, false) - } - | J.Kind.Null => - switch ty { - | JSONNull => ok(loc, true) - | _ => ok(loc, false) - } - | J.Kind.String => - switch ty { - | JSONString(f) => eq(loc, f, expected) - | _ => ok(loc, false) - } - } - | _ => ok(loc, false) - } - } - - test("JSON string array parsing", () => { - let json = J.parseExn( - J.stringify(J.array(Belt.Array.map(["string 0", "string 1", "string 2"], J.string))), - ) - - eq_at_i(__LOC__, json, 0, J.Kind.String, "string 0") - eq_at_i(__LOC__, json, 1, J.Kind.String, "string 1") - eq_at_i(__LOC__, json, 2, J.Kind.String, "string 2") - }) - - test("JSON stringArray parsing", () => { - let json = J.parseExn(J.stringify(J.stringArray(["string 0", "string 1", "string 2"]))) - - eq_at_i(__LOC__, json, 0, J.Kind.String, "string 0") - eq_at_i(__LOC__, json, 1, J.Kind.String, "string 1") - eq_at_i(__LOC__, json, 2, J.Kind.String, "string 2") - }) - - test("JSON number array parsing", () => { - let a = [1.0000001, 10000000000.1, 123.0] - let json = J.parseExn(J.stringify(J.numberArray(a))) - - /* Loop is unrolled to keep relevant location information */ - eq_at_i(__LOC__, json, 0, J.Kind.Number, a->Array.getUnsafe(0)) - eq_at_i(__LOC__, json, 1, J.Kind.Number, a->Array.getUnsafe(1)) - eq_at_i(__LOC__, json, 2, J.Kind.Number, a->Array.getUnsafe(2)) - }) - - test("JSON integer array parsing", () => { - let a = [0, 0xAFAFAFAF, 0xF000AABB] - let json = J.parseExn(J.stringify(J.numberArray(a->Belt.Array.map(float_of_int)))) - - /* Loop is unrolled to keep relevant location information */ - eq_at_i(__LOC__, json, 0, J.Kind.Number, float_of_int(a->Array.getUnsafe(0))) - eq_at_i(__LOC__, json, 1, J.Kind.Number, float_of_int(a->Array.getUnsafe(1))) - eq_at_i(__LOC__, json, 2, J.Kind.Number, float_of_int(a->Array.getUnsafe(2))) - }) - - test("JSON boolean array parsing", () => { - let a = [true, false, true] - let json = J.parseExn(J.stringify(J.booleanArray(a))) - - /* Loop is unrolled to keep relevant location information */ - eq_at_i(__LOC__, json, 0, J.Kind.Boolean, a->Array.getUnsafe(0)) - eq_at_i(__LOC__, json, 1, J.Kind.Boolean, a->Array.getUnsafe(1)) - eq_at_i(__LOC__, json, 2, J.Kind.Boolean, a->Array.getUnsafe(2)) - }) - - test("JSON object array parsing", () => { - let option_get = x => - switch x { - | None => assert(false) - | Some(x) => x - } - - let make_d = (s, i) => { - let d = Js_dict.empty() - Js_dict.set(d, "a", J.string(s)) - Js_dict.set(d, "b", J.number(float_of_int(i))) - d - } - - let a = [make_d("aaa", 123), make_d("bbb", 456)] - let json = J.parseExn(J.stringify(J.objectArray(a))) - - let ty = J.classify(json) - switch ty { - | J.JSONArray(x) => - let ty = J.classify(x->Array.getUnsafe(1)) - switch ty { - | J.JSONObject(a1) => - let ty = J.classify(option_get(Js_dict.get(a1, "a"))) - switch ty { - | J.JSONString(aValue) => eq(__LOC__, aValue, "bbb") - | _ => ok(__LOC__, false) - } - | _ => ok(__LOC__, false) - } - | _ => ok(__LOC__, false) - } - }) - - test("JSON invalid parsing", () => { - let invalid_json_str = "{{ A}" - try { - let _ = J.parseExn(invalid_json_str) - ok(__LOC__, false) - } catch { - | exn => ok(__LOC__, true) - } - }) - - /* stringifyAny tests */ - test("JSON stringifyAny array", () => eq(__LOC__, J.stringifyAny([1, 2, 3]), Some("[1,2,3]"))) - - test("JSON stringifyAny object", () => - eq( - __LOC__, - J.stringifyAny({"foo": 1, "bar": "hello", "baz": {"baaz": 10}}), - Some(`{"foo":1,"bar":"hello","baz":{"baaz":10}}`), - ) - ) - - test("JSON stringifyAny null", () => eq(__LOC__, J.stringifyAny(Js.Null.empty), Some("null"))) - - test("JSON stringifyAny undefined", () => eq(__LOC__, J.stringifyAny(Js.Undefined.empty), None)) - - test("JSON decodeString", () => { - eq(__LOC__, J.decodeString(J.string("test")), Some("test")) - eq(__LOC__, J.decodeString(J.boolean(true)), None) - eq(__LOC__, J.decodeString(J.array([])), None) - eq(__LOC__, J.decodeString(J.null), None) - eq(__LOC__, J.decodeString(J.object_(Js.Dict.empty())), None) - eq(__LOC__, J.decodeString(J.number(1.23)), None) - }) - - test("JSON decodeNumber", () => { - eq(__LOC__, J.decodeNumber(J.string("test")), None) - eq(__LOC__, J.decodeNumber(J.boolean(true)), None) - eq(__LOC__, J.decodeNumber(J.array([])), None) - eq(__LOC__, J.decodeNumber(J.null), None) - eq(__LOC__, J.decodeNumber(J.object_(Js.Dict.empty())), None) - eq(__LOC__, J.decodeNumber(J.number(1.23)), Some(1.23)) - }) - - test("JSON decodeObject", () => { - eq(__LOC__, J.decodeObject(J.string("test")), None) - eq(__LOC__, J.decodeObject(J.boolean(true)), None) - eq(__LOC__, J.decodeObject(J.array([])), None) - eq(__LOC__, J.decodeObject(J.null), None) - eq(__LOC__, J.decodeObject(J.object_(Js.Dict.empty())), Some(Js.Dict.empty())) - eq(__LOC__, J.decodeObject(J.number(1.23)), None) - }) - - test("JSON decodeArray", () => { - eq(__LOC__, J.decodeArray(J.string("test")), None) - eq(__LOC__, J.decodeArray(J.boolean(true)), None) - eq(__LOC__, J.decodeArray(J.array([])), Some([])) - eq(__LOC__, J.decodeArray(J.null), None) - eq(__LOC__, J.decodeArray(J.object_(Js.Dict.empty())), None) - eq(__LOC__, J.decodeArray(J.number(1.23)), None) - }) - - test("JSON Array/Object switch falls through to wildcard on null and array", () => { - let classifyArrayOrObject = (json: J.t) => - switch json { - | J.Array(items) => Some(items->Js.Array2.length) - | J.Object(dict) => - ignore(Js.Dict.get(dict, "x")) - Some(0) - | _ => None - } - - eq(__LOC__, classifyArrayOrObject(J.null), None) - eq(__LOC__, classifyArrayOrObject(J.array([J.number(1.)])), Some(1)) - eq(__LOC__, classifyArrayOrObject(J.object_(Js.Dict.empty())), Some(0)) - - // When there's no Array case, arrays should fall to wildcard - let classifyObjectOnly = (json: J.t) => - switch json { - | J.Object(_) => "Object" - | J.String(_) => "String" - | _ => "default" - } - - eq(__LOC__, classifyObjectOnly(J.null), "default") - eq(__LOC__, classifyObjectOnly(J.array([])), "default") - eq(__LOC__, classifyObjectOnly(J.object_(Js.Dict.empty())), "Object") - eq(__LOC__, classifyObjectOnly(J.string("hi")), "String") - }) - - test("JSON Object switch as statement guards null and array", () => { - let result = ref("none") - let classifyStatement = (json: J.t) => { - switch json { - | J.Object(_) => result := "object" - | J.Array(_) => () - | J.String(_) => () - | _ => () - } - } - - result := "none" - classifyStatement(J.null) - eq(__LOC__, result.contents, "none") - - result := "none" - classifyStatement(J.array([])) - eq(__LOC__, result.contents, "none") - - result := "none" - classifyStatement(J.object_(Js.Dict.empty())) - eq(__LOC__, result.contents, "object") - }) - - test("JSON decodeBoolean", () => { - eq(__LOC__, J.decodeBoolean(J.string("test")), None) - eq(__LOC__, J.decodeBoolean(J.boolean(true)), Some(true)) - eq(__LOC__, J.decodeBoolean(J.array([])), None) - eq(__LOC__, J.decodeBoolean(J.null), None) - eq(__LOC__, J.decodeBoolean(J.object_(Js.Dict.empty())), None) - eq(__LOC__, J.decodeBoolean(J.number(1.23)), None) - }) - - test("JSON decodeNull", () => { - eq(__LOC__, J.decodeNull(J.string("test")), None) - eq(__LOC__, J.decodeNull(J.boolean(true)), None) - eq(__LOC__, J.decodeNull(J.array([])), None) - eq(__LOC__, J.decodeNull(J.null), Some(Js.null)) - eq(__LOC__, J.decodeNull(J.object_(Js.Dict.empty())), None) - eq(__LOC__, J.decodeNull(J.number(1.23)), None) - }) - - test("JSON serialize/deserialize identity", () => { - let id = (type t, obj: t): t => obj->J.serializeExn->J.deserializeUnsafe - - let idtest = obj => eq(__LOC__, obj, id(obj)) - idtest(None) - idtest(list{(None, None, None)}) - idtest( - Belt.List.makeBy( - 500, - i => - if mod(i, 2) == 0 { - None - } else { - Some(1) - }, - ), - ) - idtest( - Belt.Array.makeBy( - 500, - i => - if mod(i, 2) == 0 { - None - } else { - Some(1) - }, - ), - ) - }) -}) diff --git a/tests/tests/src/js_math_test.mjs b/tests/tests/src/js_math_test.mjs deleted file mode 100644 index c7e788a51de..00000000000 --- a/tests/tests/src/js_math_test.mjs +++ /dev/null @@ -1,74 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Mocha from "mocha"; -import * as Js_math from "@rescript/runtime/lib/es6/Js_math.mjs"; -import * as Test_utils from "./test_utils.mjs"; - -Mocha.describe("Js_math_test", () => { - Mocha.test("_E", () => Test_utils.approxEq("File \"js_math_test.res\", line 7, characters 13-20", 0.001, 2.718, Math.E)); - Mocha.test("_LN2", () => Test_utils.approxEq("File \"js_math_test.res\", line 10, characters 13-20", 0.001, 0.693, Math.LN2)); - Mocha.test("_LN10", () => Test_utils.approxEq("File \"js_math_test.res\", line 13, characters 13-20", 0.001, 2.303, Math.LN10)); - Mocha.test("_LOG2E", () => Test_utils.approxEq("File \"js_math_test.res\", line 16, characters 13-20", 0.001, 1.443, Math.LOG2E)); - Mocha.test("_LOG10E", () => Test_utils.approxEq("File \"js_math_test.res\", line 19, characters 13-20", 0.001, 0.434, Math.LOG10E)); - Mocha.test("_PI", () => Test_utils.approxEq("File \"js_math_test.res\", line 22, characters 13-20", 0.001, 3.14159, Math.PI)); - Mocha.test("_SQRT1_2", () => Test_utils.approxEq("File \"js_math_test.res\", line 25, characters 13-20", 0.001, 0.707, Math.SQRT1_2)); - Mocha.test("_SQRT2", () => Test_utils.approxEq("File \"js_math_test.res\", line 28, characters 13-20", 0.001, 1.414, Math.SQRT2)); - Mocha.test("abs_int", () => Test_utils.eq("File \"js_math_test.res\", line 31, characters 7-14", 4, Math.abs(-4))); - Mocha.test("abs_float", () => Test_utils.eq("File \"js_math_test.res\", line 34, characters 7-14", 1.2, Math.abs(-1.2))); - Mocha.test("acos", () => Test_utils.approxEq("File \"js_math_test.res\", line 37, characters 13-20", 0.001, 1.159, Math.acos(0.4))); - Mocha.test("acosh", () => Test_utils.approxEq("File \"js_math_test.res\", line 40, characters 13-20", 0.001, 0.622, Math.acosh(1.2))); - Mocha.test("asin", () => Test_utils.approxEq("File \"js_math_test.res\", line 43, characters 13-20", 0.001, 0.411, Math.asin(0.4))); - Mocha.test("asinh", () => Test_utils.approxEq("File \"js_math_test.res\", line 46, characters 13-20", 0.001, 0.390, Math.asinh(0.4))); - Mocha.test("atan", () => Test_utils.approxEq("File \"js_math_test.res\", line 49, characters 13-20", 0.001, 0.380, Math.atan(0.4))); - Mocha.test("atanh", () => Test_utils.approxEq("File \"js_math_test.res\", line 52, characters 13-20", 0.001, 0.423, Math.atanh(0.4))); - Mocha.test("atan2", () => Test_utils.approxEq("File \"js_math_test.res\", line 55, characters 13-20", 0.001, 0.588, Math.atan2(0.4, 0.6))); - Mocha.test("cbrt", () => Test_utils.eq("File \"js_math_test.res\", line 58, characters 7-14", 2, Math.cbrt(8))); - Mocha.test("unsafe_ceil_int", () => Test_utils.eq("File \"js_math_test.res\", line 61, characters 7-14", 4, Math.ceil(3.2))); - Mocha.test("ceil_int", () => Test_utils.eq("File \"js_math_test.res\", line 64, characters 7-14", 4, Js_math.ceil_int(3.2))); - Mocha.test("ceil_float", () => Test_utils.eq("File \"js_math_test.res\", line 67, characters 7-14", 4, Math.ceil(3.2))); - Mocha.test("cos", () => Test_utils.approxEq("File \"js_math_test.res\", line 70, characters 13-20", 0.001, 0.921, Math.cos(0.4))); - Mocha.test("cosh", () => Test_utils.approxEq("File \"js_math_test.res\", line 73, characters 13-20", 0.001, 1.081, Math.cosh(0.4))); - Mocha.test("exp", () => Test_utils.approxEq("File \"js_math_test.res\", line 76, characters 13-20", 0.001, 1.491, Math.exp(0.4))); - Mocha.test("expm1", () => Test_utils.approxEq("File \"js_math_test.res\", line 79, characters 13-20", 0.001, 0.491, Math.expm1(0.4))); - Mocha.test("unsafe_floor_int", () => Test_utils.eq("File \"js_math_test.res\", line 82, characters 7-14", 3, Math.floor(3.2))); - Mocha.test("floor_int", () => Test_utils.eq("File \"js_math_test.res\", line 85, characters 7-14", 3, Js_math.floor_int(3.2))); - Mocha.test("floor_float", () => Test_utils.eq("File \"js_math_test.res\", line 88, characters 7-14", 3, Math.floor(3.2))); - Mocha.test("fround", () => Test_utils.approxEq("File \"js_math_test.res\", line 91, characters 13-20", 0.001, 3.2, Math.fround(3.2))); - Mocha.test("hypot", () => Test_utils.approxEq("File \"js_math_test.res\", line 94, characters 13-20", 0.001, 0.721, Math.hypot(0.4, 0.6))); - Mocha.test("hypotMany", () => Test_utils.approxEq("File \"js_math_test.res\", line 97, characters 13-20", 0.001, 1.077, Math.hypot(0.4, 0.6, 0.8))); - Mocha.test("imul", () => Test_utils.eq("File \"js_math_test.res\", line 100, characters 7-14", 8, Math.imul(4, 2))); - Mocha.test("log", () => Test_utils.approxEq("File \"js_math_test.res\", line 103, characters 13-20", 0.001, -0.916, Math.log(0.4))); - Mocha.test("log1p", () => Test_utils.approxEq("File \"js_math_test.res\", line 106, characters 13-20", 0.001, 0.336, Math.log1p(0.4))); - Mocha.test("log10", () => Test_utils.approxEq("File \"js_math_test.res\", line 109, characters 13-20", 0.001, -0.397, Math.log10(0.4))); - Mocha.test("log2", () => Test_utils.approxEq("File \"js_math_test.res\", line 112, characters 13-20", 0.001, -1.321, Math.log2(0.4))); - Mocha.test("max_int", () => Test_utils.eq("File \"js_math_test.res\", line 115, characters 7-14", 4, Math.max(2, 4))); - Mocha.test("maxMany_int", () => Test_utils.eq("File \"js_math_test.res\", line 118, characters 7-14", 4, Math.max(2, 4, 3))); - Mocha.test("max_float", () => Test_utils.eq("File \"js_math_test.res\", line 121, characters 7-14", 4.2, Math.max(2.7, 4.2))); - Mocha.test("maxMany_float", () => Test_utils.eq("File \"js_math_test.res\", line 124, characters 7-14", 4.2, Math.max(2.7, 4.2, 3.9))); - Mocha.test("min_int", () => Test_utils.eq("File \"js_math_test.res\", line 127, characters 7-14", 2, Math.min(2, 4))); - Mocha.test("minMany_int", () => Test_utils.eq("File \"js_math_test.res\", line 130, characters 7-14", 2, Math.min(2, 4, 3))); - Mocha.test("min_float", () => Test_utils.eq("File \"js_math_test.res\", line 133, characters 7-14", 2.7, Math.min(2.7, 4.2))); - Mocha.test("minMany_float", () => Test_utils.eq("File \"js_math_test.res\", line 136, characters 7-14", 2.7, Math.min(2.7, 4.2, 3.9))); - Mocha.test("random", () => { - let a = Math.random(); - Test_utils.eq("File \"js_math_test.res\", line 140, characters 7-14", true, a >= 0 && a < 1); - }); - Mocha.test("random_int", () => { - let a = Js_math.random_int(1, 3); - Test_utils.eq("File \"js_math_test.res\", line 144, characters 7-14", true, a >= 1 && a < 3); - }); - Mocha.test("unsafe_round", () => Test_utils.eq("File \"js_math_test.res\", line 147, characters 7-14", 3, Math.round(3.2))); - Mocha.test("round", () => Test_utils.eq("File \"js_math_test.res\", line 150, characters 7-14", 3, Math.round(3.2))); - Mocha.test("sign_int", () => Test_utils.eq("File \"js_math_test.res\", line 153, characters 7-14", -1, Math.sign(-4))); - Mocha.test("sign_float", () => Test_utils.eq("File \"js_math_test.res\", line 156, characters 7-14", -1, Math.sign(-4.2))); - Mocha.test("sign_float -0", () => Test_utils.eq("File \"js_math_test.res\", line 159, characters 7-14", -0, Math.sign(-0))); - Mocha.test("sin", () => Test_utils.approxEq("File \"js_math_test.res\", line 162, characters 13-20", 0.001, 0.389, Math.sin(0.4))); - Mocha.test("sinh", () => Test_utils.approxEq("File \"js_math_test.res\", line 165, characters 13-20", 0.001, 0.410, Math.sinh(0.4))); - Mocha.test("sqrt", () => Test_utils.approxEq("File \"js_math_test.res\", line 168, characters 13-20", 0.001, 0.632, Math.sqrt(0.4))); - Mocha.test("tan", () => Test_utils.approxEq("File \"js_math_test.res\", line 171, characters 13-20", 0.001, 0.422, Math.tan(0.4))); - Mocha.test("tanh", () => Test_utils.approxEq("File \"js_math_test.res\", line 174, characters 13-20", 0.001, 0.379, Math.tanh(0.4))); - Mocha.test("unsafe_trunc", () => Test_utils.eq("File \"js_math_test.res\", line 177, characters 7-14", 4, Math.trunc(4.2156))); - Mocha.test("trunc", () => Test_utils.eq("File \"js_math_test.res\", line 180, characters 7-14", 4, Math.trunc(4.2156))); -}); - -/* Not a pure module */ diff --git a/tests/tests/src/js_math_test.res b/tests/tests/src/js_math_test.res deleted file mode 100644 index 3e3ec079d46..00000000000 --- a/tests/tests/src/js_math_test.res +++ /dev/null @@ -1,182 +0,0 @@ -open Js.Math -open Mocha -open Test_utils - -describe(__MODULE__, () => { - test("_E", () => { - approxEq(__LOC__, 0.001, 2.718, _E) - }) - test("_LN2", () => { - approxEq(__LOC__, 0.001, 0.693, _LN2) - }) - test("_LN10", () => { - approxEq(__LOC__, 0.001, 2.303, _LN10) - }) - test("_LOG2E", () => { - approxEq(__LOC__, 0.001, 1.443, _LOG2E) - }) - test("_LOG10E", () => { - approxEq(__LOC__, 0.001, 0.434, _LOG10E) - }) - test("_PI", () => { - approxEq(__LOC__, 0.001, 3.14159, _PI) - }) - test("_SQRT1_2", () => { - approxEq(__LOC__, 0.001, 0.707, _SQRT1_2) - }) - test("_SQRT2", () => { - approxEq(__LOC__, 0.001, 1.414, _SQRT2) - }) - test("abs_int", () => { - eq(__LOC__, 4, abs_int(-4)) - }) - test("abs_float", () => { - eq(__LOC__, 1.2, abs_float(-1.2)) - }) - test("acos", () => { - approxEq(__LOC__, 0.001, 1.159, acos(0.4)) - }) - test("acosh", () => { - approxEq(__LOC__, 0.001, 0.622, acosh(1.2)) - }) - test("asin", () => { - approxEq(__LOC__, 0.001, 0.411, asin(0.4)) - }) - test("asinh", () => { - approxEq(__LOC__, 0.001, 0.390, asinh(0.4)) - }) - test("atan", () => { - approxEq(__LOC__, 0.001, 0.380, atan(0.4)) - }) - test("atanh", () => { - approxEq(__LOC__, 0.001, 0.423, atanh(0.4)) - }) - test("atan2", () => { - approxEq(__LOC__, 0.001, 0.588, atan2(~x=0.6, ~y=0.4, ())) - }) - test("cbrt", () => { - eq(__LOC__, 2., cbrt(8.)) - }) - test("unsafe_ceil_int", () => { - eq(__LOC__, 4, unsafe_ceil_int(3.2)) - }) - test("ceil_int", () => { - eq(__LOC__, 4, ceil_int(3.2)) - }) - test("ceil_float", () => { - eq(__LOC__, 4., ceil_float(3.2)) - }) - test("cos", () => { - approxEq(__LOC__, 0.001, 0.921, cos(0.4)) - }) - test("cosh", () => { - approxEq(__LOC__, 0.001, 1.081, cosh(0.4)) - }) - test("exp", () => { - approxEq(__LOC__, 0.001, 1.491, exp(0.4)) - }) - test("expm1", () => { - approxEq(__LOC__, 0.001, 0.491, expm1(0.4)) - }) - test("unsafe_floor_int", () => { - eq(__LOC__, 3, unsafe_floor_int(3.2)) - }) - test("floor_int", () => { - eq(__LOC__, 3, floor_int(3.2)) - }) - test("floor_float", () => { - eq(__LOC__, 3., floor_float(3.2)) - }) - test("fround", () => { - approxEq(__LOC__, 0.001, 3.2, fround(3.2)) - }) - test("hypot", () => { - approxEq(__LOC__, 0.001, 0.721, hypot(0.4, 0.6)) - }) - test("hypotMany", () => { - approxEq(__LOC__, 0.001, 1.077, hypotMany([0.4, 0.6, 0.8])) - }) - test("imul", () => { - eq(__LOC__, 8, imul(4, 2)) - }) - test("log", () => { - approxEq(__LOC__, 0.001, -0.916, log(0.4)) - }) - test("log1p", () => { - approxEq(__LOC__, 0.001, 0.336, log1p(0.4)) - }) - test("log10", () => { - approxEq(__LOC__, 0.001, -0.397, log10(0.4)) - }) - test("log2", () => { - approxEq(__LOC__, 0.001, -1.321, log2(0.4)) - }) - test("max_int", () => { - eq(__LOC__, 4, max_int(2, 4)) - }) - test("maxMany_int", () => { - eq(__LOC__, 4, maxMany_int([2, 4, 3])) - }) - test("max_float", () => { - eq(__LOC__, 4.2, max_float(2.7, 4.2)) - }) - test("maxMany_float", () => { - eq(__LOC__, 4.2, maxMany_float([2.7, 4.2, 3.9])) - }) - test("min_int", () => { - eq(__LOC__, 2, min_int(2, 4)) - }) - test("minMany_int", () => { - eq(__LOC__, 2, minMany_int([2, 4, 3])) - }) - test("min_float", () => { - eq(__LOC__, 2.7, min_float(2.7, 4.2)) - }) - test("minMany_float", () => { - eq(__LOC__, 2.7, minMany_float([2.7, 4.2, 3.9])) - }) - test("random", () => { - let a = random() - eq(__LOC__, true, a >= 0. && a < 1.) - }) - test("random_int", () => { - let a = random_int(1, 3) - eq(__LOC__, true, a >= 1 && a < 3) - }) - test("unsafe_round", () => { - eq(__LOC__, 3, unsafe_round(3.2)) - }) - test("round", () => { - eq(__LOC__, 3., round(3.2)) - }) - test("sign_int", () => { - eq(__LOC__, -1, sign_int(-4)) - }) - test("sign_float", () => { - eq(__LOC__, -1., sign_float(-4.2)) - }) - test("sign_float -0", () => { - eq(__LOC__, -0., sign_float(-0.)) - }) - test("sin", () => { - approxEq(__LOC__, 0.001, 0.389, sin(0.4)) - }) - test("sinh", () => { - approxEq(__LOC__, 0.001, 0.410, sinh(0.4)) - }) - test("sqrt", () => { - approxEq(__LOC__, 0.001, 0.632, sqrt(0.4)) - }) - test("tan", () => { - approxEq(__LOC__, 0.001, 0.422, tan(0.4)) - }) - test("tanh", () => { - approxEq(__LOC__, 0.001, 0.379, tanh(0.4)) - }) - test("unsafe_trunc", () => { - eq(__LOC__, 4, unsafe_trunc(4.2156)) - }) - test("trunc", () => { - eq(__LOC__, 4., trunc(4.2156)) - }) -}) diff --git a/tests/tests/src/js_null_test.mjs b/tests/tests/src/js_null_test.mjs deleted file mode 100644 index 51b08db2006..00000000000 --- a/tests/tests/src/js_null_test.mjs +++ /dev/null @@ -1,38 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Mocha from "mocha"; -import * as Js_null from "@rescript/runtime/lib/es6/Js_null.mjs"; -import * as Test_utils from "./test_utils.mjs"; -import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.mjs"; - -Mocha.describe("Js_null_test", () => { - Mocha.test("toOption - empty", () => Test_utils.eq("File \"js_null_test.res\", line 7, characters 7-14", undefined, undefined)); - Mocha.test("toOption - 'a", () => Test_utils.eq("File \"js_null_test.res\", line 11, characters 7-14", Primitive_option.some(undefined), Primitive_option.some())); - Mocha.test("return", () => Test_utils.eq("File \"js_null_test.res\", line 15, characters 7-14", "something", Primitive_option.fromNull("something"))); - Mocha.test("test - empty", () => Test_utils.eq("File \"js_null_test.res\", line 19, characters 7-14", true, true)); - Mocha.test("test - 'a", () => Test_utils.eq("File \"js_null_test.res\", line 23, characters 7-14", false, false)); - Mocha.test("bind - empty", () => Test_utils.eq("File \"js_null_test.res\", line 27, characters 7-14", null, Js_null.bind(null, v => v))); - Mocha.test("bind - 'a", () => Test_utils.eq("File \"js_null_test.res\", line 31, characters 7-14", 4, Js_null.bind(2, n => (n << 1)))); - Mocha.test("iter - empty", () => { - let hit = { - contents: false - }; - Js_null.iter(null, param => { - hit.contents = true; - }); - Test_utils.eq("File \"js_null_test.res\", line 37, characters 7-14", false, hit.contents); - }); - Mocha.test("iter - 'a", () => { - let hit = { - contents: 0 - }; - Js_null.iter(2, v => { - hit.contents = v; - }); - Test_utils.eq("File \"js_null_test.res\", line 43, characters 7-14", 2, hit.contents); - }); - Mocha.test("fromOption - None", () => Test_utils.eq("File \"js_null_test.res\", line 47, characters 7-14", null, Js_null.fromOption(undefined))); - Mocha.test("fromOption - Some", () => Test_utils.eq("File \"js_null_test.res\", line 51, characters 7-14", 2, Js_null.fromOption(2))); -}); - -/* Not a pure module */ diff --git a/tests/tests/src/js_null_test.res b/tests/tests/src/js_null_test.res deleted file mode 100644 index f8044e770b8..00000000000 --- a/tests/tests/src/js_null_test.res +++ /dev/null @@ -1,53 +0,0 @@ -open Js_null -open Mocha -open Test_utils - -describe(__MODULE__, () => { - test("toOption - empty", () => { - eq(__LOC__, None, toOption(empty)) - }) - - test("toOption - 'a", () => { - eq(__LOC__, Some(), toOption(return())) - }) - - test("return", () => { - eq(__LOC__, Some("something"), toOption(return("something"))) - }) - - test("test - empty", () => { - eq(__LOC__, true, empty == Js.null) - }) - - test("test - 'a", () => { - eq(__LOC__, false, return() == empty) - }) - - test("bind - empty", () => { - eq(__LOC__, empty, bind(empty, v => v)) - }) - - test("bind - 'a", () => { - eq(__LOC__, return(4), bind(return(2), n => n * 2)) - }) - - test("iter - empty", () => { - let hit = ref(false) - let _ = iter(empty, _ => hit := true) - eq(__LOC__, false, hit.contents) - }) - - test("iter - 'a", () => { - let hit = ref(0) - let _ = iter(return(2), v => hit := v) - eq(__LOC__, 2, hit.contents) - }) - - test("fromOption - None", () => { - eq(__LOC__, empty, fromOption(None)) - }) - - test("fromOption - Some", () => { - eq(__LOC__, return(2), fromOption(Some(2))) - }) -}) diff --git a/tests/tests/src/js_null_undefined_test.mjs b/tests/tests/src/js_null_undefined_test.mjs deleted file mode 100644 index 233b98e186a..00000000000 --- a/tests/tests/src/js_null_undefined_test.mjs +++ /dev/null @@ -1,66 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Mocha from "mocha"; -import * as Test_utils from "./test_utils.mjs"; -import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.mjs"; -import * as Js_null_undefined from "@rescript/runtime/lib/es6/Js_null_undefined.mjs"; - -Mocha.describe("Js_null_undefined_test", () => { - Mocha.test("toOption - null", () => Test_utils.eq("File \"js_null_undefined_test.res\", line 7, characters 7-14", undefined, undefined)); - Mocha.test("toOption - undefined", () => Test_utils.eq("File \"js_null_undefined_test.res\", line 10, characters 7-14", undefined, undefined)); - Mocha.test("toOption - empty", () => Test_utils.eq("File \"js_null_undefined_test.res\", line 13, characters 7-14", undefined, undefined)); - Mocha.test("toOption - return", () => Test_utils.eq("File \"js_null_undefined_test.res\", line 16, characters 7-14", "foo", Primitive_option.fromNullable("foo"))); - Mocha.test("return", () => Test_utils.eq("File \"js_null_undefined_test.res\", line 19, characters 7-14", "something", Primitive_option.fromNullable("something"))); - Mocha.test("test - null", () => Test_utils.eq("File \"js_null_undefined_test.res\", line 22, characters 7-14", true, true)); - Mocha.test("test - undefined", () => Test_utils.eq("File \"js_null_undefined_test.res\", line 25, characters 7-14", true, true)); - Mocha.test("test - empty", () => Test_utils.eq("File \"js_null_undefined_test.res\", line 28, characters 7-14", true, true)); - Mocha.test("test - return", () => Test_utils.eq("File \"js_null_undefined_test.res\", line 31, characters 7-14", true, true)); - Mocha.test("bind - null", () => Test_utils.eq("File \"js_null_undefined_test.res\", line 34, characters 7-14", null, Js_null_undefined.bind(null, v => v))); - Mocha.test("bind - undefined", () => Test_utils.eq("File \"js_null_undefined_test.res\", line 37, characters 7-14", undefined, Js_null_undefined.bind(undefined, v => v))); - Mocha.test("bind - empty", () => Test_utils.eq("File \"js_null_undefined_test.res\", line 40, characters 7-14", undefined, Js_null_undefined.bind(undefined, v => v))); - Mocha.test("bind - 'a", () => Test_utils.eq("File \"js_null_undefined_test.res\", line 43, characters 7-14", 4, Js_null_undefined.bind(2, n => (n << 1)))); - Mocha.test("iter - null", () => { - let hit = { - contents: false - }; - Js_null_undefined.iter(null, param => { - hit.contents = true; - }); - Test_utils.eq("File \"js_null_undefined_test.res\", line 48, characters 7-14", false, hit.contents); - }); - Mocha.test("iter - undefined", () => { - let hit = { - contents: false - }; - Js_null_undefined.iter(undefined, param => { - hit.contents = true; - }); - Test_utils.eq("File \"js_null_undefined_test.res\", line 53, characters 7-14", false, hit.contents); - }); - Mocha.test("iter - empty", () => { - let hit = { - contents: false - }; - Js_null_undefined.iter(undefined, param => { - hit.contents = true; - }); - Test_utils.eq("File \"js_null_undefined_test.res\", line 58, characters 7-14", false, hit.contents); - }); - Mocha.test("iter - 'a", () => { - let hit = { - contents: 0 - }; - Js_null_undefined.iter(2, v => { - hit.contents = v; - }); - Test_utils.eq("File \"js_null_undefined_test.res\", line 63, characters 7-14", 2, hit.contents); - }); - Mocha.test("fromOption - None", () => Test_utils.eq("File \"js_null_undefined_test.res\", line 66, characters 7-14", undefined, Js_null_undefined.fromOption(undefined))); - Mocha.test("fromOption - Some", () => Test_utils.eq("File \"js_null_undefined_test.res\", line 69, characters 7-14", 2, Js_null_undefined.fromOption(2))); - Mocha.test("null <> undefined", () => Test_utils.eq("File \"js_null_undefined_test.res\", line 72, characters 7-14", true, true)); - Mocha.test("null <> empty", () => Test_utils.eq("File \"js_null_undefined_test.res\", line 75, characters 7-14", true, true)); - Mocha.test("undefined = empty", () => Test_utils.eq("File \"js_null_undefined_test.res\", line 78, characters 7-14", true, true)); - Mocha.test("null variable", () => Test_utils.eq("File \"js_null_undefined_test.res\", line 82, characters 7-14", true, true)); -}); - -/* Not a pure module */ diff --git a/tests/tests/src/js_null_undefined_test.res b/tests/tests/src/js_null_undefined_test.res deleted file mode 100644 index fe9c7e36ea4..00000000000 --- a/tests/tests/src/js_null_undefined_test.res +++ /dev/null @@ -1,84 +0,0 @@ -open Js_null_undefined -open Mocha -open Test_utils - -describe(__MODULE__, () => { - test("toOption - null", () => { - eq(__LOC__, None, toOption(null)) - }) - test("toOption - undefined", () => { - eq(__LOC__, None, toOption(undefined)) - }) - test("toOption - empty", () => { - eq(__LOC__, None, toOption(undefined)) - }) - test("toOption - return", () => { - eq(__LOC__, Some("foo"), toOption(return("foo"))) - }) - test("return", () => { - eq(__LOC__, Some("something"), toOption(return("something"))) - }) - test("test - null", () => { - eq(__LOC__, true, isNullable(null)) - }) - test("test - undefined", () => { - eq(__LOC__, true, isNullable(undefined)) - }) - test("test - empty", () => { - eq(__LOC__, true, isNullable(undefined)) - }) - test("test - return", () => { - eq(__LOC__, true, isNullable(return())) - }) - test("bind - null", () => { - eq(__LOC__, null, bind(null, v => v)) - }) - test("bind - undefined", () => { - eq(__LOC__, undefined, bind(undefined, v => v)) - }) - test("bind - empty", () => { - eq(__LOC__, undefined, bind(undefined, v => v)) - }) - test("bind - 'a", () => { - eq(__LOC__, return(4), bind(return(2), n => n * 2)) - }) - test("iter - null", () => { - let hit = ref(false) - let _ = iter(null, _ => hit := true) - eq(__LOC__, false, hit.contents) - }) - test("iter - undefined", () => { - let hit = ref(false) - let _ = iter(undefined, _ => hit := true) - eq(__LOC__, false, hit.contents) - }) - test("iter - empty", () => { - let hit = ref(false) - let _ = iter(undefined, _ => hit := true) - eq(__LOC__, false, hit.contents) - }) - test("iter - 'a", () => { - let hit = ref(0) - let _ = iter(return(2), v => hit := v) - eq(__LOC__, 2, hit.contents) - }) - test("fromOption - None", () => { - eq(__LOC__, undefined, fromOption(None)) - }) - test("fromOption - Some", () => { - eq(__LOC__, return(2), fromOption(Some(2))) - }) - test("null <> undefined", () => { - eq(__LOC__, true, null != undefined) - }) - test("null <> empty", () => { - eq(__LOC__, true, null != undefined) - }) - test("undefined = empty", () => { - eq(__LOC__, true, undefined == undefined) - }) - test("null variable", () => { - let null = 3 - eq(__LOC__, true, !Js.isNullable(Js.Nullable.return(null))) - }) -}) diff --git a/tests/tests/src/js_nullable_test.mjs b/tests/tests/src/js_nullable_test.mjs deleted file mode 100644 index 9a7c290b91f..00000000000 --- a/tests/tests/src/js_nullable_test.mjs +++ /dev/null @@ -1,34 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Mocha from "mocha"; -import * as Test_utils from "./test_utils.mjs"; - -function test_return_nullable(dom) { - let elem = dom.getElementById("haha"); - if (elem == null) { - return 1; - } else { - console.log(elem); - return 2; - } -} - -function f(x, y) { - console.log("no inline"); - return x + y | 0; -} - -Mocha.describe("Js_nullable_test", () => { - Mocha.test("Js.Nullable operations", () => { - Test_utils.eq("File \"js_nullable_test.res\", line 25, characters 7-14", false, false); - Test_utils.eq("File \"js_nullable_test.res\", line 26, characters 7-14", (f(1, 2) == null), false); - Test_utils.eq("File \"js_nullable_test.res\", line 27, characters 7-14", (null == null), true); - Test_utils.eq("File \"js_nullable_test.res\", line 31, characters 7-14", false, false); - }); -}); - -export { - test_return_nullable, - f, -} -/* Not a pure module */ diff --git a/tests/tests/src/js_nullable_test.res b/tests/tests/src/js_nullable_test.res deleted file mode 100644 index 228d24c44d1..00000000000 --- a/tests/tests/src/js_nullable_test.res +++ /dev/null @@ -1,33 +0,0 @@ -open Mocha -open Test_utils - -type element -type dom -@send @return(nullable) external getElementById: (dom, string) => option = "getElementById" - -let test_return_nullable = dom => { - let elem = dom->getElementById("haha") - switch elem { - | None => 1 - | Some(ui) => - Console.log(ui) - 2 - } -} - -let f = (x, y) => { - Console.log("no inline") - Js.Nullable.return(x + y) -} - -describe(__MODULE__, () => { - test("Js.Nullable operations", () => { - eq(__LOC__, Js.isNullable(Js.Nullable.return(3)), false) - eq(__LOC__, Js.isNullable(f(1, 2)), false) - eq(__LOC__, Js.isNullable(%raw("null")), true) - - let null2 = Js.Nullable.return(3) - let null = null2 - eq(__LOC__, Js.isNullable(null), false) - }) -}) diff --git a/tests/tests/src/js_obj_test.mjs b/tests/tests/src/js_obj_test.mjs deleted file mode 100644 index 106e15b2449..00000000000 --- a/tests/tests/src/js_obj_test.mjs +++ /dev/null @@ -1,15 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Mocha from "mocha"; -import * as Test_utils from "./test_utils.mjs"; - -Mocha.describe("Js_obj_test", () => { - Mocha.test("empty", () => Test_utils.eq("File \"js_obj_test.res\", line 9, characters 7-14", 0, Object.keys({}).length)); - Mocha.test("assign", () => Test_utils.eq("File \"js_obj_test.res\", line 13, characters 7-14", { - a: 1 - }, Object.assign({}, { - a: 1 - }))); -}); - -/* Not a pure module */ diff --git a/tests/tests/src/js_obj_test.res b/tests/tests/src/js_obj_test.res deleted file mode 100644 index a7906102d69..00000000000 --- a/tests/tests/src/js_obj_test.res +++ /dev/null @@ -1,15 +0,0 @@ -open Js_obj -open Mocha -open Test_utils - -type x = {"say": int => int} - -describe(__MODULE__, () => { - test("empty", () => { - eq(__LOC__, 0, Belt.Array.length(keys(empty()))) - }) - - test("assign", () => { - eq(__LOC__, {"a": 1}, assign(empty(), {"a": 1})) - }) -}) diff --git a/tests/tests/src/js_option_test.mjs b/tests/tests/src/js_option_test.mjs deleted file mode 100644 index fe50b75b328..00000000000 --- a/tests/tests/src/js_option_test.mjs +++ /dev/null @@ -1,40 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Mocha from "mocha"; -import * as Js_option from "@rescript/runtime/lib/es6/Js_option.mjs"; -import * as Test_utils from "./test_utils.mjs"; - -function simpleEq(a, b) { - return a === b; -} - -Mocha.describe("Js_option_test", () => { - Mocha.test("option_isSome_Some", () => Test_utils.eq("File \"js_option_test.res\", line 8, characters 7-14", true, Js_option.isSome(1))); - Mocha.test("option_isSome_None", () => Test_utils.eq("File \"js_option_test.res\", line 12, characters 7-14", false, Js_option.isSome(undefined))); - Mocha.test("option_isNone_Some", () => Test_utils.eq("File \"js_option_test.res\", line 16, characters 7-14", false, Js_option.isNone(1))); - Mocha.test("option_isNone_None", () => Test_utils.eq("File \"js_option_test.res\", line 20, characters 7-14", true, Js_option.isNone(undefined))); - Mocha.test("option_isSomeValue_Eq", () => Test_utils.eq("File \"js_option_test.res\", line 24, characters 7-14", true, Js_option.isSomeValue(simpleEq, 2, 2))); - Mocha.test("option_isSomeValue_Diff", () => Test_utils.eq("File \"js_option_test.res\", line 28, characters 7-14", false, Js_option.isSomeValue(simpleEq, 1, 2))); - Mocha.test("option_isSomeValue_DiffNone", () => Test_utils.eq("File \"js_option_test.res\", line 32, characters 7-14", false, Js_option.isSomeValue(simpleEq, 1, undefined))); - Mocha.test("option_getExn_Some", () => Test_utils.eq("File \"js_option_test.res\", line 36, characters 7-14", 2, Js_option.getExn(2))); - Mocha.test("option_equal_Eq", () => Test_utils.eq("File \"js_option_test.res\", line 40, characters 7-14", true, Js_option.equal(simpleEq, 2, 2))); - Mocha.test("option_equal_Diff", () => Test_utils.eq("File \"js_option_test.res\", line 44, characters 7-14", false, Js_option.equal(simpleEq, 1, 2))); - Mocha.test("option_equal_DiffNone", () => Test_utils.eq("File \"js_option_test.res\", line 48, characters 7-14", false, Js_option.equal(simpleEq, 1, undefined))); - Mocha.test("option_andThen_SomeSome", () => Test_utils.eq("File \"js_option_test.res\", line 53, characters 6-13", true, Js_option.isSomeValue(simpleEq, 3, Js_option.andThen(a => a + 1 | 0, 2)))); - Mocha.test("option_andThen_SomeNone", () => Test_utils.eq("File \"js_option_test.res\", line 60, characters 7-14", false, Js_option.isSomeValue(simpleEq, 3, Js_option.andThen(param => {}, 2)))); - Mocha.test("option_map_Some", () => Test_utils.eq("File \"js_option_test.res\", line 64, characters 7-14", true, Js_option.isSomeValue(simpleEq, 3, Js_option.map(a => a + 1 | 0, 2)))); - Mocha.test("option_map_None", () => Test_utils.eq("File \"js_option_test.res\", line 68, characters 7-14", undefined, Js_option.map(a => a + 1 | 0, undefined))); - Mocha.test("option_default_Some", () => Test_utils.eq("File \"js_option_test.res\", line 72, characters 7-14", 2, Js_option.getWithDefault(3, 2))); - Mocha.test("option_default_None", () => Test_utils.eq("File \"js_option_test.res\", line 76, characters 7-14", 3, Js_option.getWithDefault(3, undefined))); - Mocha.test("option_filter_Pass", () => Test_utils.eq("File \"js_option_test.res\", line 81, characters 6-13", true, Js_option.isSomeValue(simpleEq, 2, Js_option.filter(a => a % 2 === 0, 2)))); - Mocha.test("option_filter_Reject", () => Test_utils.eq("File \"js_option_test.res\", line 88, characters 7-14", undefined, Js_option.filter(a => a % 3 === 0, 2))); - Mocha.test("option_filter_None", () => Test_utils.eq("File \"js_option_test.res\", line 92, characters 7-14", undefined, Js_option.filter(a => a % 3 === 0, undefined))); - Mocha.test("option_firstSome_First", () => Test_utils.eq("File \"js_option_test.res\", line 96, characters 7-14", true, Js_option.isSomeValue(simpleEq, 3, Js_option.firstSome(3, 2)))); - Mocha.test("option_firstSome_Second", () => Test_utils.eq("File \"js_option_test.res\", line 100, characters 7-14", true, Js_option.isSomeValue(simpleEq, 2, Js_option.firstSome(undefined, 2)))); - Mocha.test("option_firstSome_None", () => Test_utils.eq("File \"js_option_test.res\", line 104, characters 7-14", undefined, Js_option.firstSome(undefined, undefined))); -}); - -export { - simpleEq, -} -/* Not a pure module */ diff --git a/tests/tests/src/js_option_test.res b/tests/tests/src/js_option_test.res deleted file mode 100644 index e9893b1ceac..00000000000 --- a/tests/tests/src/js_option_test.res +++ /dev/null @@ -1,106 +0,0 @@ -open Mocha -open Test_utils - -let simpleEq = (a: int, b) => a == b - -describe(__MODULE__, () => { - test("option_isSome_Some", () => { - eq(__LOC__, true, Js.Option.isSome(Some(1))) - }) - - test("option_isSome_None", () => { - eq(__LOC__, false, Js.Option.isSome(None)) - }) - - test("option_isNone_Some", () => { - eq(__LOC__, false, Js.Option.isNone(Some(1))) - }) - - test("option_isNone_None", () => { - eq(__LOC__, true, Js.Option.isNone(None)) - }) - - test("option_isSomeValue_Eq", () => { - eq(__LOC__, true, Js.Option.isSomeValue(simpleEq, 2, Some(2))) - }) - - test("option_isSomeValue_Diff", () => { - eq(__LOC__, false, Js.Option.isSomeValue(simpleEq, 1, Some(2))) - }) - - test("option_isSomeValue_DiffNone", () => { - eq(__LOC__, false, Js.Option.isSomeValue(simpleEq, 1, None)) - }) - - test("option_getExn_Some", () => { - eq(__LOC__, 2, Js.Option.getExn(Some(2))) - }) - - test("option_equal_Eq", () => { - eq(__LOC__, true, Js.Option.equal(simpleEq, Some(2), Some(2))) - }) - - test("option_equal_Diff", () => { - eq(__LOC__, false, Js.Option.equal(simpleEq, Some(1), Some(2))) - }) - - test("option_equal_DiffNone", () => { - eq(__LOC__, false, Js.Option.equal(simpleEq, Some(1), None)) - }) - - test("option_andThen_SomeSome", () => { - eq( - __LOC__, - true, - Js.Option.isSomeValue(simpleEq, 3, Js.Option.andThen(a => Some(a + 1), Some(2))), - ) - }) - - test("option_andThen_SomeNone", () => { - eq(__LOC__, false, Js.Option.isSomeValue(simpleEq, 3, Js.Option.andThen(_ => None, Some(2)))) - }) - - test("option_map_Some", () => { - eq(__LOC__, true, Js.Option.isSomeValue(simpleEq, 3, Js.Option.map(a => a + 1, Some(2)))) - }) - - test("option_map_None", () => { - eq(__LOC__, None, Js.Option.map(a => a + 1, None)) - }) - - test("option_default_Some", () => { - eq(__LOC__, 2, Js.Option.getWithDefault(3, Some(2))) - }) - - test("option_default_None", () => { - eq(__LOC__, 3, Js.Option.getWithDefault(3, None)) - }) - - test("option_filter_Pass", () => { - eq( - __LOC__, - true, - Js.Option.isSomeValue(simpleEq, 2, Js.Option.filter(a => mod(a, 2) == 0, Some(2))), - ) - }) - - test("option_filter_Reject", () => { - eq(__LOC__, None, Js.Option.filter(a => mod(a, 3) == 0, Some(2))) - }) - - test("option_filter_None", () => { - eq(__LOC__, None, Js.Option.filter(a => mod(a, 3) == 0, None)) - }) - - test("option_firstSome_First", () => { - eq(__LOC__, true, Js.Option.isSomeValue(simpleEq, 3, Js.Option.firstSome(Some(3), Some(2)))) - }) - - test("option_firstSome_Second", () => { - eq(__LOC__, true, Js.Option.isSomeValue(simpleEq, 2, Js.Option.firstSome(None, Some(2)))) - }) - - test("option_firstSome_None", () => { - eq(__LOC__, None, Js.Option.firstSome(None, None)) - }) -}) diff --git a/tests/tests/src/js_re_test.mjs b/tests/tests/src/js_re_test.mjs deleted file mode 100644 index 0467eeee414..00000000000 --- a/tests/tests/src/js_re_test.mjs +++ /dev/null @@ -1,113 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Mocha from "mocha"; -import * as Test_utils from "./test_utils.mjs"; -import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.mjs"; - -Mocha.describe("Js_re_test", () => { - Mocha.test("fromString", () => { - let contentOf = (tag, xmlString) => { - let x = Primitive_option.fromNull(new RegExp("<" + (tag + (">(.*?)<\\/" + (tag + ">")))).exec(xmlString)); - if (x !== undefined) { - return Primitive_option.fromNullable(Primitive_option.valFromOption(x)[1]); - } - }; - Test_utils.eq("File \"js_re_test.res\", line 31, characters 7-14", "Hi", contentOf("div", "
Hi
")); - }); - Mocha.test("exec_literal", () => { - let res = /[^.]+/.exec("http://xxx.domain.com"); - if (res !== null) { - return Test_utils.eq("File \"js_re_test.res\", line 36, characters 9-16", "http://xxx", res[0]); - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "js_re_test.res", - 37, - 14 - ], - Error: new Error() - }; - }); - Mocha.test("exec_no_match", () => { - let match = /https:\/\/(.*)/.exec("http://xxx.domain.com"); - if (match !== null) { - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "js_re_test.res", - 42, - 17 - ], - Error: new Error() - }; - } - Test_utils.eq("File \"js_re_test.res\", line 43, characters 17-24", true, true); - }); - Mocha.test("test_str", () => { - let res = new RegExp("foo").test("#foo#"); - Test_utils.eq("File \"js_re_test.res\", line 48, characters 7-14", true, res); - }); - Mocha.test("fromStringWithFlags", () => { - let res = new RegExp("foo", "g"); - Test_utils.eq("File \"js_re_test.res\", line 52, characters 7-14", true, res.global); - }); - Mocha.test("result_index", () => { - let res = new RegExp("zbar").exec("foobarbazbar"); - if (res !== null) { - return Test_utils.eq("File \"js_re_test.res\", line 56, characters 22-29", 8, res.index); - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "js_re_test.res", - 57, - 14 - ], - Error: new Error() - }; - }); - Mocha.test("result_input", () => { - let input = "foobar"; - let res = /foo/g.exec(input); - if (res !== null) { - return Test_utils.eq("File \"js_re_test.res\", line 63, characters 22-29", input, res.input); - } - throw { - RE_EXN_ID: "Assert_failure", - _1: [ - "js_re_test.res", - 64, - 14 - ], - Error: new Error() - }; - }); - Mocha.test("t_flags", () => Test_utils.eq("File \"js_re_test.res\", line 69, characters 7-14", "gi", /./ig.flags)); - Mocha.test("t_global", () => Test_utils.eq("File \"js_re_test.res\", line 72, characters 7-14", true, /./ig.global)); - Mocha.test("t_ignoreCase", () => Test_utils.eq("File \"js_re_test.res\", line 75, characters 7-14", true, /./ig.ignoreCase)); - Mocha.test("t_lastIndex", () => { - let re = /na/g; - re.exec("banana"); - Test_utils.eq("File \"js_re_test.res\", line 83, characters 7-14", 4, re.lastIndex); - }); - Mocha.test("t_setLastIndex", () => { - let re = /na/g; - let before = re.lastIndex; - re.lastIndex = 42; - let after = re.lastIndex; - Test_utils.eq("File \"js_re_test.res\", line 90, characters 7-14", [ - 0, - 42 - ], [ - before, - after - ]); - }); - Mocha.test("t_multiline", () => Test_utils.eq("File \"js_re_test.res\", line 93, characters 7-14", false, /./ig.multiline)); - Mocha.test("t_source", () => Test_utils.eq("File \"js_re_test.res\", line 96, characters 7-14", "f.+o", /f.+o/ig.source)); - Mocha.test("t_sticky", () => Test_utils.eq("File \"js_re_test.res\", line 100, characters 7-14", true, /./yg.sticky)); - Mocha.test("t_unicode", () => Test_utils.eq("File \"js_re_test.res\", line 103, characters 7-14", false, /./yg.unicode)); -}); - -/* Not a pure module */ diff --git a/tests/tests/src/js_re_test.res b/tests/tests/src/js_re_test.res deleted file mode 100644 index 5581600821b..00000000000 --- a/tests/tests/src/js_re_test.res +++ /dev/null @@ -1,105 +0,0 @@ -open Mocha -open Test_utils - -describe(__MODULE__, () => { - // ( - // "captures", - // _ => { - // let re = /(\d+)-(?:(\d+))?/g - // let str = "3-" - // switch re->Js.Re.exec_(str) { - // | Some(result) => - // let defined = Js.Re.captures(result)[1] - // let undefined = Js.Re.captures(result)[2] - // Eq((Js.Nullable.return("3"), Js.Nullable.null), (defined, undefined)) - // | None => Fail() - // } - // }, - // ), - test("fromString", () => { - /* From the example in js_re.mli */ - let contentOf = (tag, xmlString) => - Js.Re.fromString("<" ++ (tag ++ (">(.*?)<\\/" ++ (tag ++ ">")))) - ->Js.Re.exec_(xmlString) - ->( - x => - switch x { - | Some(result) => Js.Nullable.toOption(Js.Re.captures(result)->Array.getUnsafe(1)) - | None => None - } - ) - eq(__LOC__, Some("Hi"), contentOf("div", "
Hi
")) - }) - test("exec_literal", () => { - switch /[^.]+/->Js.Re.exec_("http://xxx.domain.com") { - | Some(res) => - eq(__LOC__, Js.Nullable.return("http://xxx"), Js.Re.captures(res)->Array.getUnsafe(0)) - | None => assert(false) - } - }) - test("exec_no_match", () => { - switch /https:\/\/(.*)/->Js.Re.exec_("http://xxx.domain.com") { - | Some(_) => assert(false) - | None => eq(__LOC__, true, true) - } - }) - test("test_str", () => { - let res = "foo"->Js.Re.fromString->Js.Re.test_("#foo#") - eq(__LOC__, true, res) - }) - test("fromStringWithFlags", () => { - let res = Js.Re.fromStringWithFlags("foo", ~flags="g") - eq(__LOC__, true, res->Js.Re.global) - }) - test("result_index", () => { - switch "zbar"->Js.Re.fromString->Js.Re.exec_("foobarbazbar") { - | Some(res) => eq(__LOC__, 8, Js.Re.index(res)) - | None => assert(false) - } - }) - test("result_input", () => { - let input = "foobar" - switch /foo/g->Js.Re.exec_(input) { - | Some(res) => eq(__LOC__, input, Js.Re.input(res)) - | None => assert(false) - } - }) - /* es2015 */ - test("t_flags", () => { - eq(__LOC__, "gi", /./ig->Js.Re.flags) - }) - test("t_global", () => { - eq(__LOC__, true, /./ig->Js.Re.global) - }) - test("t_ignoreCase", () => { - eq(__LOC__, true, /./ig->Js.Re.ignoreCase) - }) - test("t_lastIndex", () => { - let re = /na/g - let _ = - re->Js.Re.exec_( - "banana", - ) /* Caml_option.null_to_opt post operation is not dropped in 4.06 which seems to be reduandant */ - eq(__LOC__, 4, re->Js.Re.lastIndex) - }) - test("t_setLastIndex", () => { - let re = /na/g - let before = Js.Re.lastIndex(re) - let () = Js.Re.setLastIndex(re, 42) - let after = Js.Re.lastIndex(re) - eq(__LOC__, (0, 42), (before, after)) - }) - test("t_multiline", () => { - eq(__LOC__, false, /./ig->Js.Re.multiline) - }) - test("t_source", () => { - eq(__LOC__, "f.+o", /f.+o/ig->Js.Re.source) - }) - /* es2015 */ - test("t_sticky", () => { - eq(__LOC__, true, /./yg->Js.Re.sticky) - }) - test("t_unicode", () => { - eq(__LOC__, false, /./yg->Js.Re.unicode) - }) -}) diff --git a/tests/tests/src/js_string_test.mjs b/tests/tests/src/js_string_test.mjs deleted file mode 100644 index ffe51a228eb..00000000000 --- a/tests/tests/src/js_string_test.mjs +++ /dev/null @@ -1,128 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Mocha from "mocha"; -import * as Js_string from "@rescript/runtime/lib/es6/Js_string.mjs"; -import * as Test_utils from "./test_utils.mjs"; -import * as Belt_Option from "@rescript/runtime/lib/es6/Belt_Option.mjs"; -import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.mjs"; - -Mocha.describe("Js_string_test", () => { - Mocha.test("make", () => Test_utils.eq("File \"js_string_test.res\", line 5, characters 24-31", "null", String(null).concat(""))); - Mocha.test("fromCharCode", () => Test_utils.eq("File \"js_string_test.res\", line 6, characters 32-39", "a", String.fromCharCode(97))); - Mocha.test("fromCharCodeMany", () => Test_utils.eq("File \"js_string_test.res\", line 7, characters 36-43", "az", String.fromCharCode(97, 122))); - Mocha.test("fromCodePoint", () => Test_utils.eq("File \"js_string_test.res\", line 9, characters 33-40", "a", String.fromCodePoint(97))); - Mocha.test("fromCodePointMany", () => Test_utils.eq("File \"js_string_test.res\", line 10, characters 37-44", "az", String.fromCodePoint(97, 122))); - Mocha.test("length", () => Test_utils.eq("File \"js_string_test.res\", line 11, characters 26-33", 3, "foo".length)); - Mocha.test("get", () => Test_utils.eq("File \"js_string_test.res\", line 12, characters 23-30", "a", "foobar"[4])); - Mocha.test("charAt", () => Test_utils.eq("File \"js_string_test.res\", line 13, characters 26-33", "a", "foobar".charAt(4))); - Mocha.test("charCodeAt", () => Test_utils.eq("File \"js_string_test.res\", line 14, characters 30-37", 97, "foobar".charCodeAt(4))); - Mocha.test("codePointAt", () => Test_utils.eq("File \"js_string_test.res\", line 16, characters 31-38", 97, "foobar".codePointAt(4))); - Mocha.test("codePointAt - out of bounds", () => Test_utils.eq("File \"js_string_test.res\", line 17, characters 47-54", undefined, "foobar".codePointAt(98))); - Mocha.test("concat", () => Test_utils.eq("File \"js_string_test.res\", line 18, characters 26-33", "foobar", "foo".concat("bar"))); - Mocha.test("concatMany", () => Test_utils.eq("File \"js_string_test.res\", line 19, characters 30-37", "foobarbaz", "foo".concat("bar", "baz"))); - Mocha.test("endsWith", () => Test_utils.eq("File \"js_string_test.res\", line 21, characters 28-35", true, "foobar".endsWith("bar"))); - Mocha.test("endsWithFrom", () => Test_utils.eq("File \"js_string_test.res\", line 22, characters 32-39", false, "foobar".endsWith("bar", 1))); - Mocha.test("includes", () => Test_utils.eq("File \"js_string_test.res\", line 24, characters 28-35", true, "foobarbaz".includes("bar"))); - Mocha.test("includesFrom", () => Test_utils.eq("File \"js_string_test.res\", line 25, characters 32-39", false, "foobarbaz".includes("bar", 4))); - Mocha.test("indexOf", () => Test_utils.eq("File \"js_string_test.res\", line 26, characters 27-34", 3, "foobarbaz".indexOf("bar"))); - Mocha.test("indexOfFrom", () => Test_utils.eq("File \"js_string_test.res\", line 27, characters 31-38", -1, "foobarbaz".indexOf("bar", 4))); - Mocha.test("lastIndexOf", () => Test_utils.eq("File \"js_string_test.res\", line 28, characters 31-38", 3, "foobarbaz".lastIndexOf("bar"))); - Mocha.test("lastIndexOfFrom", () => Test_utils.eq("File \"js_string_test.res\", line 29, characters 35-42", 3, "foobarbaz".lastIndexOf("bar", 4))); - Mocha.test("localeCompare", () => Test_utils.eq("File \"js_string_test.res\", line 30, characters 33-40", 0, "foo".localeCompare("foo"))); - Mocha.test("match", () => Test_utils.eq("File \"js_string_test.res\", line 32, characters 7-14", [ - "na", - "na" - ], Primitive_option.fromNull("banana".match(/na+/g)))); - Mocha.test("match - no match", () => Test_utils.eq("File \"js_string_test.res\", line 34, characters 36-43", undefined, Primitive_option.fromNull("banana".match(/nanana+/g)))); - Mocha.test("match - not found capture groups", () => Test_utils.eq("File \"js_string_test.res\", line 37, characters 6-13", [ - "hello ", - undefined - ], Belt_Option.map(Primitive_option.fromNull("hello word".match(/hello (world)?/)), prim => prim.slice()))); - Mocha.test("normalize", () => Test_utils.eq("File \"js_string_test.res\", line 43, characters 29-36", "foo", "foo".normalize())); - Mocha.test("normalizeByForm", () => Test_utils.eq("File \"js_string_test.res\", line 44, characters 35-42", "foo", "foo".normalize("NFKD"))); - Mocha.test("repeat", () => Test_utils.eq("File \"js_string_test.res\", line 46, characters 26-33", "foofoofoo", "foo".repeat(3))); - Mocha.test("replace", () => Test_utils.eq("File \"js_string_test.res\", line 47, characters 27-34", "fooBORKbaz", "foobarbaz".replace("bar", "BORK"))); - Mocha.test("replaceByRe", () => Test_utils.eq("File \"js_string_test.res\", line 49, characters 7-14", "fooBORKBORK", "foobarbaz".replace(/ba./g, "BORK"))); - Mocha.test("unsafeReplaceBy0", () => { - let replace = (whole, offset, s) => { - if (whole === "bar") { - return "BORK"; - } else { - return "DORK"; - } - }; - Test_utils.eq("File \"js_string_test.res\", line 59, characters 7-14", "fooBORKDORK", "foobarbaz".replace(/ba./g, replace)); - }); - Mocha.test("unsafeReplaceBy1", () => { - let replace = (whole, p1, offset, s) => { - if (whole === "bar") { - return "BORK"; - } else { - return "DORK"; - } - }; - Test_utils.eq("File \"js_string_test.res\", line 69, characters 7-14", "fooBORKDORK", "foobarbaz".replace(/ba./g, replace)); - }); - Mocha.test("unsafeReplaceBy2", () => { - let replace = (whole, p1, p2, offset, s) => { - if (whole === "bar") { - return "BORK"; - } else { - return "DORK"; - } - }; - Test_utils.eq("File \"js_string_test.res\", line 79, characters 7-14", "fooBORKDORK", "foobarbaz".replace(/ba./g, replace)); - }); - Mocha.test("unsafeReplaceBy3", () => { - let replace = (whole, p1, p2, p3, offset, s) => { - if (whole === "bar") { - return "BORK"; - } else { - return "DORK"; - } - }; - Test_utils.eq("File \"js_string_test.res\", line 89, characters 7-14", "fooBORKDORK", "foobarbaz".replace(/ba./g, replace)); - }); - Mocha.test("search", () => Test_utils.eq("File \"js_string_test.res\", line 91, characters 26-33", 3, "foobarbaz".search(/ba./g))); - Mocha.test("slice", () => Test_utils.eq("File \"js_string_test.res\", line 92, characters 25-32", "bar", "foobarbaz".slice(3, 6))); - Mocha.test("sliceToEnd", () => Test_utils.eq("File \"js_string_test.res\", line 93, characters 30-37", "barbaz", "foobarbaz".slice(3))); - Mocha.test("split", () => Test_utils.eq("File \"js_string_test.res\", line 94, characters 25-32", [ - "foo", - "bar", - "baz" - ], "foo bar baz".split(" "))); - Mocha.test("splitAtMost", () => Test_utils.eq("File \"js_string_test.res\", line 96, characters 7-14", [ - "foo", - "bar" - ], "foo bar baz".split(" ", 2))); - Mocha.test("splitByRe", () => Test_utils.eq("File \"js_string_test.res\", line 100, characters 6-13", [ - "a", - "#", - undefined, - "b", - "#", - ":", - "c" - ], Js_string.splitByRe(/(#)(:)?/, "a#b#:c"))); - Mocha.test("splitByReAtMost", () => Test_utils.eq("File \"js_string_test.res\", line 107, characters 6-13", [ - "a", - "#", - undefined - ], Js_string.splitByReAtMost(/(#)(:)?/, 3, "a#b#:c"))); - Mocha.test("startsWith", () => Test_utils.eq("File \"js_string_test.res\", line 113, characters 30-37", true, "foobarbaz".startsWith("foo"))); - Mocha.test("startsWithFrom", () => Test_utils.eq("File \"js_string_test.res\", line 114, characters 34-41", false, "foobarbaz".startsWith("foo", 1))); - Mocha.test("substr", () => Test_utils.eq("File \"js_string_test.res\", line 115, characters 26-33", "barbaz", "foobarbaz".substr(3))); - Mocha.test("substrAtMost", () => Test_utils.eq("File \"js_string_test.res\", line 117, characters 7-14", "bar", "foobarbaz".substr(3, 3))); - Mocha.test("substring", () => Test_utils.eq("File \"js_string_test.res\", line 119, characters 29-36", "bar", "foobarbaz".substring(3, 6))); - Mocha.test("substringToEnd", () => Test_utils.eq("File \"js_string_test.res\", line 121, characters 7-14", "barbaz", "foobarbaz".substring(3))); - Mocha.test("toLowerCase", () => Test_utils.eq("File \"js_string_test.res\", line 123, characters 31-38", "bork", "BORK".toLowerCase())); - Mocha.test("toLocaleLowerCase", () => Test_utils.eq("File \"js_string_test.res\", line 124, characters 37-44", "bork", "BORK".toLocaleLowerCase())); - Mocha.test("toUpperCase", () => Test_utils.eq("File \"js_string_test.res\", line 125, characters 31-38", "FUBAR", "fubar".toUpperCase())); - Mocha.test("toLocaleUpperCase", () => Test_utils.eq("File \"js_string_test.res\", line 126, characters 37-44", "FUBAR", "fubar".toLocaleUpperCase())); - Mocha.test("trim", () => Test_utils.eq("File \"js_string_test.res\", line 127, characters 24-31", "foo", " foo ".trim())); - Mocha.test("anchor", () => Test_utils.eq("File \"js_string_test.res\", line 129, characters 26-33", "
foo", "foo".anchor("bar"))); - Mocha.test("link", () => Test_utils.eq("File \"js_string_test.res\", line 132, characters 6-13", "foo", "foo".link("https://reason.ml"))); - Mocha.test("File \"js_string_test.res\", line 137, characters 7-14", () => Test_utils.ok("File \"js_string_test.res\", line 137, characters 25-32", "ab".includes("a"))); -}); - -/* Not a pure module */ diff --git a/tests/tests/src/js_string_test.res b/tests/tests/src/js_string_test.res deleted file mode 100644 index a834f135189..00000000000 --- a/tests/tests/src/js_string_test.res +++ /dev/null @@ -1,138 +0,0 @@ -open Mocha -open Test_utils - -describe(__MODULE__, () => { - test("make", () => eq(__LOC__, "null", Js.String2.make(Js.null)->Js.String2.concat(""))) - test("fromCharCode", () => eq(__LOC__, "a", Js.String2.fromCharCode(97))) - test("fromCharCodeMany", () => eq(__LOC__, "az", Js.String2.fromCharCodeMany([97, 122]))) - /* es2015 */ - test("fromCodePoint", () => eq(__LOC__, "a", Js.String2.fromCodePoint(0x61))) - test("fromCodePointMany", () => eq(__LOC__, "az", Js.String2.fromCodePointMany([0x61, 0x7a]))) - test("length", () => eq(__LOC__, 3, "foo"->Js.String2.length)) - test("get", () => eq(__LOC__, "a", Js.String2.get("foobar", 4))) - test("charAt", () => eq(__LOC__, "a", "foobar"->Js.String2.charAt(4))) - test("charCodeAt", () => eq(__LOC__, 97., "foobar"->Js.String2.charCodeAt(4))) - /* es2015 */ - test("codePointAt", () => eq(__LOC__, Some(0x61), "foobar"->Js.String2.codePointAt(4))) - test("codePointAt - out of bounds", () => eq(__LOC__, None, "foobar"->Js.String2.codePointAt(98))) - test("concat", () => eq(__LOC__, "foobar", "foo"->Js.String2.concat("bar"))) - test("concatMany", () => eq(__LOC__, "foobarbaz", "foo"->Js.String2.concatMany(["bar", "baz"]))) - /* es2015 */ - test("endsWith", () => eq(__LOC__, true, "foobar"->Js.String2.endsWith("bar"))) - test("endsWithFrom", () => eq(__LOC__, false, "foobar"->Js.String2.endsWithFrom("bar", 1))) - /* es2015 */ - test("includes", () => eq(__LOC__, true, "foobarbaz"->Js.String2.includes("bar"))) - test("includesFrom", () => eq(__LOC__, false, "foobarbaz"->Js.String2.includesFrom("bar", 4))) - test("indexOf", () => eq(__LOC__, 3, "foobarbaz"->Js.String2.indexOf("bar"))) - test("indexOfFrom", () => eq(__LOC__, -1, "foobarbaz"->Js.String2.indexOfFrom("bar", 4))) - test("lastIndexOf", () => eq(__LOC__, 3, "foobarbaz"->Js.String2.lastIndexOf("bar"))) - test("lastIndexOfFrom", () => eq(__LOC__, 3, "foobarbaz"->Js.String2.lastIndexOfFrom("bar", 4))) - test("localeCompare", () => eq(__LOC__, 0., "foo"->Js.String2.localeCompare("foo"))) - test("match", () => - eq(__LOC__, Some([Some("na"), Some("na")]), "banana"->Js.String2.match_(/na+/g)) - ) - test("match - no match", () => eq(__LOC__, None, "banana"->Js.String2.match_(/nanana+/g))) - test("match - not found capture groups", () => - eq( - __LOC__, - Some([Some("hello "), None]), - "hello word"->Js.String2.match_(/hello (world)?/)->Belt.Option.map(Js.Array.copy), - ) - ) - /* es2015 */ - test("normalize", () => eq(__LOC__, "foo", "foo"->Js.String2.normalize)) - test("normalizeByForm", () => eq(__LOC__, "foo", "foo"->Js.String2.normalizeByForm("NFKD"))) - /* es2015 */ - test("repeat", () => eq(__LOC__, "foofoofoo", "foo"->Js.String2.repeat(3))) - test("replace", () => eq(__LOC__, "fooBORKbaz", "foobarbaz"->Js.String2.replace("bar", "BORK"))) - test("replaceByRe", () => - eq(__LOC__, "fooBORKBORK", "foobarbaz"->Js.String2.replaceByRe(/ba./g, "BORK")) - ) - test("unsafeReplaceBy0", () => { - let replace = (whole, offset, s) => - if whole == "bar" { - "BORK" - } else { - "DORK" - } - - eq(__LOC__, "fooBORKDORK", "foobarbaz"->Js.String2.unsafeReplaceBy0(/ba./g, replace)) - }) - test("unsafeReplaceBy1", () => { - let replace = (whole, p1, offset, s) => - if whole == "bar" { - "BORK" - } else { - "DORK" - } - - eq(__LOC__, "fooBORKDORK", "foobarbaz"->Js.String2.unsafeReplaceBy1(/ba./g, replace)) - }) - test("unsafeReplaceBy2", () => { - let replace = (whole, p1, p2, offset, s) => - if whole == "bar" { - "BORK" - } else { - "DORK" - } - - eq(__LOC__, "fooBORKDORK", "foobarbaz"->Js.String2.unsafeReplaceBy2(/ba./g, replace)) - }) - test("unsafeReplaceBy3", () => { - let replace = (whole, p1, p2, p3, offset, s) => - if whole == "bar" { - "BORK" - } else { - "DORK" - } - - eq(__LOC__, "fooBORKDORK", "foobarbaz"->Js.String2.unsafeReplaceBy3(/ba./g, replace)) - }) - test("search", () => eq(__LOC__, 3, "foobarbaz"->Js.String2.search(/ba./g))) - test("slice", () => eq(__LOC__, "bar", "foobarbaz"->Js.String2.slice(~from=3, ~to_=6))) - test("sliceToEnd", () => eq(__LOC__, "barbaz", "foobarbaz"->Js.String2.sliceToEnd(~from=3))) - test("split", () => eq(__LOC__, ["foo", "bar", "baz"], "foo bar baz"->Js.String2.split(" "))) - test("splitAtMost", () => - eq(__LOC__, ["foo", "bar"], "foo bar baz"->Js.String2.splitAtMost(" ", ~limit=2)) - ) - test("splitByRe", () => - eq( - __LOC__, - [Some("a"), Some("#"), None, Some("b"), Some("#"), Some(":"), Some("c")], - Js.String.splitByRe(/(#)(:)?/, "a#b#:c"), - ) - ) - test("splitByReAtMost", () => - eq( - __LOC__, - [Some("a"), Some("#"), None], - Js.String.splitByReAtMost(/(#)(:)?/, ~limit=3, "a#b#:c"), - ) - ) - /* es2015 */ - test("startsWith", () => eq(__LOC__, true, "foobarbaz"->Js.String2.startsWith("foo"))) - test("startsWithFrom", () => eq(__LOC__, false, "foobarbaz"->Js.String2.startsWithFrom("foo", 1))) - test("substr", () => eq(__LOC__, "barbaz", "foobarbaz"->Js.String2.substr(~from=3))) - test("substrAtMost", () => - eq(__LOC__, "bar", "foobarbaz"->Js.String2.substrAtMost(~from=3, ~length=3)) - ) - test("substring", () => eq(__LOC__, "bar", "foobarbaz"->Js.String2.substring(~from=3, ~to_=6))) - test("substringToEnd", () => - eq(__LOC__, "barbaz", "foobarbaz"->Js.String2.substringToEnd(~from=3)) - ) - test("toLowerCase", () => eq(__LOC__, "bork", "BORK"->Js.String2.toLowerCase)) - test("toLocaleLowerCase", () => eq(__LOC__, "bork", "BORK"->Js.String2.toLocaleLowerCase)) - test("toUpperCase", () => eq(__LOC__, "FUBAR", "fubar"->Js.String2.toUpperCase)) - test("toLocaleUpperCase", () => eq(__LOC__, "FUBAR", "fubar"->Js.String2.toLocaleUpperCase)) - test("trim", () => eq(__LOC__, "foo", " foo "->Js.String2.trim)) - /* es2015 */ - test("anchor", () => eq(__LOC__, "foo", "foo"->Js.String2.anchor("bar"))) - test("link", () => - eq( - __LOC__, - "foo", - "foo"->Js.String2.link("https://reason.ml"), - ) - ) - test(__LOC__, () => ok(__LOC__, Js.String2.includes("ab", "a"))) -}) diff --git a/tests/tests/src/js_undefined_test.mjs b/tests/tests/src/js_undefined_test.mjs deleted file mode 100644 index a78df1e48c9..00000000000 --- a/tests/tests/src/js_undefined_test.mjs +++ /dev/null @@ -1,37 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as Mocha from "mocha"; -import * as Test_utils from "./test_utils.mjs"; -import * as Js_undefined from "@rescript/runtime/lib/es6/Js_undefined.mjs"; - -Mocha.describe("Js_undefined_test", () => { - Mocha.test("toOption - empty", () => Test_utils.eq("File \"js_undefined_test.res\", line 7, characters 7-14", undefined, Js_undefined.toOption(undefined))); - Mocha.test("toOption - return", () => Test_utils.eq("File \"js_undefined_test.res\", line 10, characters 7-14", undefined, Js_undefined.toOption())); - Mocha.test("return", () => Test_utils.eq("File \"js_undefined_test.res\", line 13, characters 7-14", "something", Js_undefined.toOption("something"))); - Mocha.test("test - empty", () => Test_utils.eq("File \"js_undefined_test.res\", line 16, characters 7-14", true, true)); - Mocha.test("test - return", () => Test_utils.eq("File \"js_undefined_test.res\", line 19, characters 7-14", true, true)); - Mocha.test("bind - empty", () => Test_utils.eq("File \"js_undefined_test.res\", line 22, characters 7-14", undefined, Js_undefined.bind(undefined, v => v))); - Mocha.test("bind - 'a", () => Test_utils.eq("File \"js_undefined_test.res\", line 25, characters 7-14", 4, Js_undefined.bind(2, n => (n << 1)))); - Mocha.test("iter - empty", () => { - let hit = { - contents: false - }; - Js_undefined.iter(undefined, param => { - hit.contents = true; - }); - Test_utils.eq("File \"js_undefined_test.res\", line 30, characters 7-14", false, hit.contents); - }); - Mocha.test("iter - 'a", () => { - let hit = { - contents: 0 - }; - Js_undefined.iter(2, v => { - hit.contents = v; - }); - Test_utils.eq("File \"js_undefined_test.res\", line 35, characters 7-14", 2, hit.contents); - }); - Mocha.test("fromOption - None", () => Test_utils.eq("File \"js_undefined_test.res\", line 38, characters 7-14", undefined, Js_undefined.fromOption(undefined))); - Mocha.test("fromOption - Some", () => Test_utils.eq("File \"js_undefined_test.res\", line 41, characters 7-14", 2, Js_undefined.fromOption(2))); -}); - -/* Not a pure module */ diff --git a/tests/tests/src/js_undefined_test.res b/tests/tests/src/js_undefined_test.res deleted file mode 100644 index fa0defa2d9f..00000000000 --- a/tests/tests/src/js_undefined_test.res +++ /dev/null @@ -1,43 +0,0 @@ -open Js_undefined -open Mocha -open Test_utils - -describe(__MODULE__, () => { - test("toOption - empty", () => { - eq(__LOC__, None, toOption(empty)) - }) - test("toOption - return", () => { - eq(__LOC__, None, toOption(return())) - }) - test("return", () => { - eq(__LOC__, Some("something"), toOption(return("something"))) - }) - test("test - empty", () => { - eq(__LOC__, true, empty == Js.undefined) - }) - test("test - return", () => { - eq(__LOC__, true, return() == Js.undefined) - }) - test("bind - empty", () => { - eq(__LOC__, empty, bind(empty, v => v)) - }) - test("bind - 'a", () => { - eq(__LOC__, return(4), bind(return(2), n => n * 2)) - }) - test("iter - empty", () => { - let hit = ref(false) - let _ = iter(empty, _ => hit := true) - eq(__LOC__, false, hit.contents) - }) - test("iter - 'a", () => { - let hit = ref(0) - let _ = iter(return(2), v => hit := v) - eq(__LOC__, 2, hit.contents) - }) - test("fromOption - None", () => { - eq(__LOC__, empty, fromOption(None)) - }) - test("fromOption - Some", () => { - eq(__LOC__, return(2), fromOption(Some(2))) - }) -}) diff --git a/tests/tests/src/js_val.mjs b/tests/tests/src/js_val.mjs deleted file mode 100644 index 9e179b40f5d..00000000000 --- a/tests/tests/src/js_val.mjs +++ /dev/null @@ -1,19 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - -import * as X from "x"; - -let h = u; - -let hh = X.vv; - -let hhh = X.vv; - -let hhhh = X.vvvv; - -export { - h, - hh, - hhh, - hhhh, -} -/* h Not a pure module */ diff --git a/tests/tests/src/js_val.res b/tests/tests/src/js_val.res deleted file mode 100644 index 45fd8813566..00000000000 --- a/tests/tests/src/js_val.res +++ /dev/null @@ -1,13 +0,0 @@ -@val external u: int = "u" - -@val @module("x") external vv: int = "vv" - -@val @module(("x", "U")) external vvv: int = "vv" -@module(("x", "U")) external vvvv: int = "vvvv" - -/* TODO: unify all [module] name, here ideally, - we should have only one [require("x")] here */ -let h = u -let hh = vv -let hhh = vvv -let hhhh = vvvv diff --git a/tests/tests/src/key_word_property_plus_test.mjs b/tests/tests/src/key_word_property_plus_test.mjs index b763fe8bf28..561e16339cf 100644 --- a/tests/tests/src/key_word_property_plus_test.mjs +++ b/tests/tests/src/key_word_property_plus_test.mjs @@ -2,15 +2,16 @@ import * as Mocha from "mocha"; import * as Test_utils from "./test_utils.mjs"; +import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.mjs"; import * as Ident_mangles from "./ident_mangles.mjs"; Mocha.describe("Key_word_property_plus_test", () => { - Mocha.test("keyword property plus with reduce", () => Test_utils.eq("File \"key_word_property_plus_test.res\", line 7, characters 6-13", [ + Mocha.test("keyword property plus with reduce", () => Test_utils.eq("File \"key_word_property_plus_test.res\", line 7, characters 6-13", Stdlib_Array.reduce([ 1, 2, 3, 4 - ].reduce((x, y) => x + y | 0, 0), ((Ident_mangles.$$__dirname + Ident_mangles.$$__filename | 0) + Ident_mangles.$$exports | 0) + Ident_mangles.$$require | 0)); + ], 0, (x, y) => x + y | 0), ((Ident_mangles.$$__dirname + Ident_mangles.$$__filename | 0) + Ident_mangles.$$exports | 0) + Ident_mangles.$$require | 0)); }); /* Not a pure module */ diff --git a/tests/tests/src/key_word_property_plus_test.res b/tests/tests/src/key_word_property_plus_test.res index 0bb5d6d0723..678196cc734 100644 --- a/tests/tests/src/key_word_property_plus_test.res +++ b/tests/tests/src/key_word_property_plus_test.res @@ -5,7 +5,7 @@ describe(__MODULE__, () => { test("keyword property plus with reduce", () => { eq( __LOC__, - Js.Array2.reduce([1, 2, 3, 4], (x, y) => x + y, 0), + Array.reduce([1, 2, 3, 4], 0, (x, y) => x + y), { open Ident_mangles __dirname + __filename + exports + require diff --git a/tests/tests/src/lib_js_test.res b/tests/tests/src/lib_js_test.res index 5b672d3dde2..2e43b55abb1 100644 --- a/tests/tests/src/lib_js_test.res +++ b/tests/tests/src/lib_js_test.res @@ -12,5 +12,4 @@ let () = { describe(__MODULE__, () => { test("anything_to_string", () => eq(__LOC__, "3", of_any(3))) /* in js, array is printed as {[ 1,2 ]} without brackets */ - /* "array_to_string", (fun _ -> Eq("[0]", Js.anything_to_string [|0|])) */ }) diff --git a/tests/tests/src/mario_game.mjs b/tests/tests/src/mario_game.mjs index 7323efc2c6a..0857748d8a1 100644 --- a/tests/tests/src/mario_game.mjs +++ b/tests/tests/src/mario_game.mjs @@ -1463,8 +1463,8 @@ function clear_canvas(canvas) { } function hud(canvas, score, coins) { - let score_string = score.toString(); - let coin_string = coins.toString(); + let score_string = String(score); + let coin_string = String(coins); let context = canvas.getContext("2d"); context.font = "10px 'Press Start 2P'"; context.fillText("Score: " + score_string, canvas.width - 140, 18); diff --git a/tests/tests/src/mario_game.res b/tests/tests/src/mario_game.res index 8691547076c..098fe281542 100644 --- a/tests/tests/src/mario_game.res +++ b/tests/tests/src/mario_game.res @@ -1460,8 +1460,8 @@ module Draw: { /* Displays the text for score and coins. */ let hud = (canvas, score, coins) => { - let score_string = Js.Int.toString(score) - let coin_string = Js.Int.toString(coins) + let score_string = Int.toString(score) + let coin_string = Int.toString(coins) let canvas = Dom_html.canvasElementToJsObj(canvas) let context = Dom_html.canvasRenderingContext2DToJsObj(canvas["getContext"]("2d")) ignore(context["font"] = "10px 'Press Start 2P'") @@ -1473,7 +1473,7 @@ module Draw: { /* Displays the fps. */ let fps = (canvas, fps_val) => { - let fps_str = fps_val->Js.Float.toFixed + let fps_str = fps_val->Stdlib_Float.toFixed let canvas = Dom_html.canvasElementToJsObj(canvas) let context = Dom_html.canvasRenderingContext2DToJsObj(canvas["getContext"]("2d")) ignore(context["fillText"](fps_str, 10., 18.)) diff --git a/tests/tests/src/module_alias_test.res b/tests/tests/src/module_alias_test.res index e6916c6b13d..d454669c4ab 100644 --- a/tests/tests/src/module_alias_test.res +++ b/tests/tests/src/module_alias_test.res @@ -6,7 +6,7 @@ module N = List module V = Ext_pervasives_test.LargeFile -module J = Js.Json +module J = JSON module type X = module type of List diff --git a/tests/tests/src/obj_magic_test.res b/tests/tests/src/obj_magic_test.res index 98824943c1e..f589851ea6e 100644 --- a/tests/tests/src/obj_magic_test.res +++ b/tests/tests/src/obj_magic_test.res @@ -6,7 +6,7 @@ /* let empty_backtrace = Obj.obj (Obj.new_block Obj.abstract_tag 0) */ -let is_block = x => Js.typeof(Obj.repr(x)) != "number" +let is_block = x => typeof(Obj.repr(x)) != #number open Mocha open Test_utils diff --git a/tests/tests/src/omit_trailing_undefined_in_external_calls.res b/tests/tests/src/omit_trailing_undefined_in_external_calls.res index d800e4abb51..d2872a4203f 100644 --- a/tests/tests/src/omit_trailing_undefined_in_external_calls.res +++ b/tests/tests/src/omit_trailing_undefined_in_external_calls.res @@ -3,17 +3,16 @@ type dateFormatOptions = {someOption?: bool} @module("SomeModule") -external formatDate: (Js.Date.t, ~options: dateFormatOptions=?, ~done: bool=?) => string = - "formatDate" +external formatDate: (Date.t, ~options: dateFormatOptions=?, ~done: bool=?) => string = "formatDate" -let x = formatDate(Js.Date.make()) -let x = formatDate(Js.Date.make(), ~options={someOption: true}) -let x = formatDate(Js.Date.make(), ~done=true) +let x = formatDate(Date.make()) +let x = formatDate(Date.make(), ~options={someOption: true}) +let x = formatDate(Date.make(), ~done=true) @send external floatToString: (float, ~radix: int=?) => string = "toString" let x = floatToString(42.) -@new external regExpFromString: (string, ~flags: string=?) => Js.Re.t = "RegExp" +@new external regExpFromString: (string, ~flags: string=?) => RegExp.t = "RegExp" let x = regExpFromString("ab+c") diff --git a/tests/tests/src/option_repr_test.res b/tests/tests/src/option_repr_test.res index b49fb97bfa7..1d27812cea4 100644 --- a/tests/tests/src/option_repr_test.res +++ b/tests/tests/src/option_repr_test.res @@ -114,15 +114,15 @@ let all_true = xs => Belt.List.every(xs, x => x) describe(__MODULE__, () => { test("option comparison operations", () => { - ok(__LOC__, None < Some(Js.null)) - ok(__LOC__, !(None > Some(Js.null))) - ok(__LOC__, Some(Js.null) > None) - ok(__LOC__, None < Some(Js.undefined)) - ok(__LOC__, Some(Js.undefined) > None) + ok(__LOC__, None < Some(null)) + ok(__LOC__, !(None > Some(null))) + ok(__LOC__, Some(null) > None) + ok(__LOC__, None < Some(undefined)) + ok(__LOC__, Some(undefined) > None) }) test("option greater than operations", () => { - ok(__LOC__, all_true(list{gtx(Some(Some(Js.null)), Some(None))})) + ok(__LOC__, all_true(list{gtx(Some(Some(null)), Some(None))})) }) test("option less than operations", () => { @@ -137,9 +137,9 @@ describe(__MODULE__, () => { ltx(Some(false), Some(true)), ltx(Some(Some(false)), Some(Some(true))), ltx(None, Some(None)), - ltx(None, Some(Js.null)), + ltx(None, Some(null)), ltx(None, Some(x => x)), - ltx(Some(Js.null), Some(Js.Null.return(3))), + ltx(Some(null), Some(Nullable.make(3))), }), ) }) @@ -149,7 +149,7 @@ describe(__MODULE__, () => { __LOC__, all_true(list{ eqx(None, None), - neqx(None, Some(Js.null)), + neqx(None, Some(null)), eqx(Some(None), Some(None)), eqx(Some(Some(None)), Some(Some(None))), neqx(Some(Some(Some(None))), Some(Some(None))), diff --git a/tests/tests/src/prepend_data_ffi.res b/tests/tests/src/prepend_data_ffi.res index 956812af570..33802f4e1b6 100644 --- a/tests/tests/src/prepend_data_ffi.res +++ b/tests/tests/src/prepend_data_ffi.res @@ -10,7 +10,7 @@ let v2: config2_expect = config2(~v=2, ()) @val external on_exit: (@as("exit") _, int => string) => unit = "process.on" -let () = on_exit(exit_code => Js.Int.toString(exit_code)) +let () = on_exit(exit_code => Int.toString(exit_code)) @val external on_exit_int: (@as(1) _, int => unit) => unit = "process.on" @@ -18,11 +18,11 @@ let () = on_exit_int(_ => ()) @val external on_exit3: (int => string, @as("exit") _) => unit = "process.on" -let () = on_exit3(i => Js.Int.toString(i)) +let () = on_exit3(i => Int.toString(i)) @val external on_exit4: (int => string, @as(1) _) => unit = "process.on" -let () = on_exit4(i => Js.Int.toString(i)) +let () = on_exit4(i => Int.toString(i)) @val @variadic external on_exit_slice: (int, @as(3) _, @as("xxx") _, array) => unit = "xx" diff --git a/tests/tests/src/rec_fun_test.res b/tests/tests/src/rec_fun_test.res index 61fcf25ced7..57a91f30c66 100644 --- a/tests/tests/src/rec_fun_test.res +++ b/tests/tests/src/rec_fun_test.res @@ -13,7 +13,7 @@ let g = () => { i + 1 } - Console.log(Js.Int.toString(next(0, true))) + Console.log(Int.toString(next(0, true))) } g() diff --git a/tests/tests/src/stdlib/Stdlib_DictTests.res b/tests/tests/src/stdlib/Stdlib_DictTests.res index 462910d2271..a8514610c63 100644 --- a/tests/tests/src/stdlib/Stdlib_DictTests.res +++ b/tests/tests/src/stdlib/Stdlib_DictTests.res @@ -22,7 +22,7 @@ module PatternMatching = { switch dict { | dict{"one": 1, "three": 3, "four": 4} => // Make sure that the dict is of correct type - dict->Js.Dict.set("five", 5) + dict->Dict.set("five", 5) | dict{"two": 1} => Console.log("two") | _ => Console.log("not one") } diff --git a/tests/tests/src/stdlib/Stdlib_TempTests.mjs b/tests/tests/src/stdlib/Stdlib_TempTests.mjs index a8608b32837..bb5e988ce52 100644 --- a/tests/tests/src/stdlib/Stdlib_TempTests.mjs +++ b/tests/tests/src/stdlib/Stdlib_TempTests.mjs @@ -249,7 +249,9 @@ let x = Symbol.for("Foo"); console.log(x); -let array$1 = "foo"[Symbol.iterator]().toArray(); +let it = "foo"[Symbol.iterator](); + +let array$1 = Array.from(it); console.log(array$1); @@ -354,6 +356,7 @@ export { set, regexp, x, + it, array$1 as array, timeout, z, diff --git a/tests/tests/src/stdlib/Stdlib_TempTests.res b/tests/tests/src/stdlib/Stdlib_TempTests.res index 9f5bbe3738e..93270c7d9f1 100644 --- a/tests/tests/src/stdlib/Stdlib_TempTests.res +++ b/tests/tests/src/stdlib/Stdlib_TempTests.res @@ -160,7 +160,8 @@ Console.info("Symbol") Console.info("---") let x = Symbol.getFor("Foo") Console.log(x) -let array: array = String.getSymbolUnsafe("foo", Symbol.iterator)()->IteratorObject.toArray +let it: IteratorObject.t = String.getSymbolUnsafe("foo", Symbol.iterator)() +let array: array = it->IteratorObject.asIterable->Array.fromIterable Console.log(array) Console.info("") diff --git a/tests/tests/src/string_set_test.res b/tests/tests/src/string_set_test.res index 044c45d80bd..af390e635b9 100644 --- a/tests/tests/src/string_set_test.res +++ b/tests/tests/src/string_set_test.res @@ -6,7 +6,7 @@ describe(__MODULE__, () => { let number = 1_000_00 let s = ref(String_set.empty) for i in 0 to number - 1 { - s := String_set.add(Js.Int.toString(i), s.contents) + s := String_set.add(Int.toString(i), s.contents) } eq(__LOC__, String_set.cardinal(s.contents), number) }) diff --git a/tests/tests/src/string_unicode_test.res b/tests/tests/src/string_unicode_test.res index 18eee5576f4..85759a22b74 100644 Binary files a/tests/tests/src/string_unicode_test.res and b/tests/tests/src/string_unicode_test.res differ diff --git a/tests/tests/src/test_cps.res b/tests/tests/src/test_cps.res index 9a8b97afc01..5f0dc482709 100644 --- a/tests/tests/src/test_cps.res +++ b/tests/tests/src/test_cps.res @@ -14,7 +14,7 @@ {n=n-1; acc= function() - {console.log(Pervasives.Js.Int.toString(n)); + {console.log(Pervasives.Int.toString(n)); return acc(/* () */0);}; continue f_tailcall_0001;}};}; @@ -32,7 +32,7 @@ {n=n-1; acc= function() - {console.log(Pervasives.Js.Int.toString(n)); + {console.log(Pervasives.Int.toString(n)); return acc(/* () */0);}; continue f_tailcall_0001;}}(n,acc)) };}; ]} @@ -54,7 +54,7 @@ var acc1 = acc ; var n1 = n; return function() { - console.log(Pervasives.Js.Int.toString(n1)); + console.log(Pervasives.Int.toString(n1)); return acc1(/* () */0);} }()); n=n-1; @@ -70,7 +70,7 @@ let rec f = (n, acc) => acc() } else { f(n - 1, _ => { - n->Js.Int.toString->Console.log + n->Int.toString->Console.log acc() }) } diff --git a/tests/tests/src/test_google_closure.res b/tests/tests/src/test_google_closure.res index 5e4f5703e5b..3884927cdd4 100644 --- a/tests/tests/src/test_google_closure.res +++ b/tests/tests/src/test_google_closure.res @@ -3,7 +3,7 @@ let f = (a, b, _) => a + b let f2 = a => f(a, 1, ...) let (a, b, c) = ( - Js.Int.toString(f(1, 2, 3)), + Int.toString(f(1, 2, 3)), { let f3 = f2(100) f3(2) diff --git a/tests/tests/src/test_side_effect_functor.res b/tests/tests/src/test_side_effect_functor.res index cff7ebc1d69..efa395b89c4 100644 --- a/tests/tests/src/test_side_effect_functor.res +++ b/tests/tests/src/test_side_effect_functor.res @@ -4,7 +4,7 @@ include ( let v = ref(0) { incr(v) - v.contents->Js.Int.toString->Console.log + v.contents->Int.toString->Console.log } let u = 3 let use_v = () => v.contents diff --git a/tests/tests/src/test_string_map.res b/tests/tests/src/test_string_map.res index 4117e351e6e..0ae1624c7fa 100644 --- a/tests/tests/src/test_string_map.res +++ b/tests/tests/src/test_string_map.res @@ -15,12 +15,12 @@ include ( let count = 1000000 timing("building", ...)(_ => for i in 0 to count { - m := m.contents->StringMap.set(Js.Int.toString(i), Js.Int.toString(i)) + m := m.contents->StringMap.set(Int.toString(i), Int.toString(i)) } ) timing("querying", ...)(_ => for i in 0 to count { - m.contents->StringMap.get(Js.Int.toString(i))->ignore + m.contents->StringMap.get(Int.toString(i))->ignore } ) } diff --git a/tests/tests/src/test_unsafe_cmp.mjs b/tests/tests/src/test_unsafe_cmp.mjs deleted file mode 100644 index b7e3afca7be..00000000000 --- a/tests/tests/src/test_unsafe_cmp.mjs +++ /dev/null @@ -1,25 +0,0 @@ -// Generated by ReScript, PLEASE EDIT WITH CARE - - -function f(x, y) { - return [ - x < y, - x <= y, - x > y, - x >= y - ]; -} - -function ff(x, y) { - if (x < y) { - return 1; - } else { - return 2; - } -} - -export { - f, - ff, -} -/* No side effect */ diff --git a/tests/tests/src/test_unsafe_cmp.res b/tests/tests/src/test_unsafe_cmp.res deleted file mode 100644 index ab65ea9f947..00000000000 --- a/tests/tests/src/test_unsafe_cmp.res +++ /dev/null @@ -1,11 +0,0 @@ -let f = (x, y) => { - open Js - (unsafe_lt(x, y), unsafe_le(x, y), unsafe_gt(x, y), unsafe_ge(x, y)) -} - -let ff = (x, y) => - if Js.unsafe_lt(x, y) { - 1 - } else { - 2 - } diff --git a/tests/tests/src/test_utils.res b/tests/tests/src/test_utils.res index f46c1221ea0..4c54bda2681 100644 --- a/tests/tests/src/test_utils.res +++ b/tests/tests/src/test_utils.res @@ -7,6 +7,6 @@ Approximate equality comparison with a threshold parameter. Returns true if the absolute difference between two values is less than or equal to the threshold. */ let approxEq = (loc, threshold, a, b) => { - let diff = Js.Math.abs_float(a -. b) + let diff = Math.abs(a -. b) Node_assert.ok(diff <= threshold, ~message=loc) } diff --git a/tests/tests/src/test_while_closure.res b/tests/tests/src/test_while_closure.res index 4c48416940f..61cd24cadd4 100644 --- a/tests/tests/src/test_while_closure.res +++ b/tests/tests/src/test_while_closure.res @@ -51,6 +51,6 @@ let f = () => { let () = { f() arr->Belt.Array.forEach(x => x()) - v.contents->Js.Int.toString->Console.log + v.contents->Int.toString->Console.log assert(v.contents == 45) } diff --git a/tests/tests/src/test_while_side_effect.res b/tests/tests/src/test_while_side_effect.res index 1c175feacd4..0b1e7717c1a 100644 --- a/tests/tests/src/test_while_side_effect.res +++ b/tests/tests/src/test_while_side_effect.res @@ -1,7 +1,7 @@ let v = ref(0) while { - v.contents->Js.Int.toString->Console.log + v.contents->Int.toString->Console.log incr(v) v.contents < 10 } { @@ -17,10 +17,10 @@ let x = ref(3) while { let y = ref(3) - x.contents->Js.Int.toString->Console.log + x.contents->Int.toString->Console.log incr(y) incr(x) fib(x.contents) + fib(x.contents) < 20 } { - 3->Js.Int.toString->Console.log + 3->Int.toString->Console.log } diff --git a/tests/tests/src/test_zero_nullable.mjs b/tests/tests/src/test_zero_nullable.mjs index 03c484a6d95..bfe8b6dc6f3 100644 --- a/tests/tests/src/test_zero_nullable.mjs +++ b/tests/tests/src/test_zero_nullable.mjs @@ -2,7 +2,6 @@ import * as Mocha from "mocha"; import * as Test_utils from "./test_utils.mjs"; -import * as Js_undefined from "@rescript/runtime/lib/es6/Js_undefined.mjs"; import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.mjs"; function f1(x) { @@ -91,88 +90,6 @@ let Test_null = { }; function f1$1(x) { - let x$1 = Js_undefined.toOption(x); - if (x$1 !== undefined) { - return x$1 + 1 | 0; - } else { - return 3; - } -} - -function f2$1(x) { - let u = Js_undefined.toOption(x); - if (u !== undefined) { - return u + 1 | 0; - } else { - return 3; - } -} - -function f5$1(h, x) { - let u = Js_undefined.toOption(h(32)); - if (u !== undefined) { - return u + 1 | 0; - } else { - return 3; - } -} - -function f4$1(h, x) { - let u = Js_undefined.toOption(h(32)); - let v = 32 + x | 0; - if (u !== undefined) { - return u + 1 | 0; - } else { - return 1 + v | 0; - } -} - -function f6$1(x, y) { - return x === y; -} - -function f7$1(x) { - return x; -} - -function f8$1(x) { - let x$1 = Js_undefined.toOption(x); - if (x$1 === undefined) { - return 2; - } - let match = Js_undefined.toOption(Primitive_option.valFromOption(x$1)); - if (match !== undefined) { - return 0; - } else { - return 1; - } -} - -let u$1 = f8$1(undefined); - -let f9$1 = Js_undefined.toOption; - -function f10$1(x) { - return x === undefined; -} - -let f11$1 = false; - -let Test_def = { - f1: f1$1, - f2: f2$1, - f5: f5$1, - f4: f4$1, - f6: f6$1, - f7: f7$1, - f8: f8$1, - u: u$1, - f9: f9$1, - f10: f10$1, - f11: f11$1 -}; - -function f1$2(x) { if (x == null) { return 3; } else { @@ -180,7 +97,7 @@ function f1$2(x) { } } -function f2$2(x) { +function f2$1(x) { if (x == null) { return 3; } else { @@ -188,7 +105,7 @@ function f2$2(x) { } } -function f5$2(h, x) { +function f5$1(h, x) { let u = h(32); if (u == null) { return 3; @@ -197,7 +114,7 @@ function f5$2(h, x) { } } -function f4$2(h, x) { +function f4$1(h, x) { let u = h(32); let v = 32 + x | 0; if (u == null) { @@ -207,15 +124,15 @@ function f4$2(h, x) { } } -function f6$2(x, y) { +function f6$1(x, y) { return x === y; } -function f7$2(x) { +function f7$1(x) { return x; } -function f8$2(x) { +function f8$1(x) { if (x == null) { return 2; } else if (x == null) { @@ -225,9 +142,9 @@ function f8$2(x) { } } -let u$2 = f8$2(undefined); +let u$1 = f8$1(undefined); -function f9$2(x) { +function f9$1(x) { if (x == null) { return; } else { @@ -235,34 +152,32 @@ function f9$2(x) { } } -function f10$2(x) { +function f10$1(x) { return x == null; } -let f11$2 = false; +let f11$1 = false; -let Test_null_def = { - f1: f1$2, - f2: f2$2, - f5: f5$2, - f4: f4$2, - f6: f6$2, - f7: f7$2, - f8: f8$2, - u: u$2, - f9: f9$2, - f10: f10$2, - f11: f11$2 +let Test_nullable = { + f1: f1$1, + f2: f2$1, + f5: f5$1, + f4: f4$1, + f6: f6$1, + f7: f7$1, + f8: f8$1, + u: u$1, + f9: f9$1, + f10: f10$1, + f11: f11$1 }; Mocha.describe("Test_zero_nullable", () => { - Mocha.test("Test_null_def.f1 with return(0)", () => Test_utils.eq("File \"test_zero_nullable.res\", line 240, characters 7-14", f1$2(0), 1)); - Mocha.test("Test_null_def.f1 with null", () => Test_utils.eq("File \"test_zero_nullable.res\", line 242, characters 46-53", f1$2(null), 3)); - Mocha.test("Test_null_def.f1 with undefined", () => Test_utils.eq("File \"test_zero_nullable.res\", line 243, characters 51-58", f1$2(undefined), 3)); - Mocha.test("Test_null.f1 with return(0)", () => Test_utils.eq("File \"test_zero_nullable.res\", line 245, characters 47-54", f1(0), 1)); - Mocha.test("Test_null.f1 with null", () => Test_utils.eq("File \"test_zero_nullable.res\", line 246, characters 42-49", f1(null), 3)); - Mocha.test("Test_def.f1 with return(0)", () => Test_utils.eq("File \"test_zero_nullable.res\", line 248, characters 46-53", f1$1(0), 1)); - Mocha.test("Test_def.f1 with undefined", () => Test_utils.eq("File \"test_zero_nullable.res\", line 249, characters 46-53", f1$1(undefined), 3)); + Mocha.test("Test_nullable.f1 with return(0)", () => Test_utils.eq("File \"test_zero_nullable.res\", line 161, characters 51-58", f1$1(0), 1)); + Mocha.test("Test_nullable.f1 with null", () => Test_utils.eq("File \"test_zero_nullable.res\", line 162, characters 46-53", f1$1(null), 3)); + Mocha.test("Test_nullable.f1 with undefined", () => Test_utils.eq("File \"test_zero_nullable.res\", line 163, characters 51-58", f1$1(undefined), 3)); + Mocha.test("Test_null.f1 with return(0)", () => Test_utils.eq("File \"test_zero_nullable.res\", line 165, characters 47-54", f1(0), 1)); + Mocha.test("Test_null.f1 with null", () => Test_utils.eq("File \"test_zero_nullable.res\", line 166, characters 42-49", f1(null), 3)); }); let a = null; @@ -277,8 +192,7 @@ let Null_undefined_neq = { export { Test_null, - Test_def, - Test_null_def, + Test_nullable, Null_undefined_neq, } /* u Not a pure module */ diff --git a/tests/tests/src/test_zero_nullable.res b/tests/tests/src/test_zero_nullable.res index 2f348083046..145969827d6 100644 --- a/tests/tests/src/test_zero_nullable.res +++ b/tests/tests/src/test_zero_nullable.res @@ -3,7 +3,7 @@ open Test_utils module Test_null = { let f1 = x => - switch Js.Null.toOption(x) { + switch Null.toOption(x) { | None => let sum = (x, y) => x + y sum(1, 2) @@ -13,7 +13,7 @@ module Test_null = { } let f2 = x => { - let u = Js.Null.toOption(x) + let u = Null.toOption(x) switch u { | None => let sum = (x, y) => x + y @@ -25,7 +25,7 @@ module Test_null = { } let f5 = (h, x) => { - let u = Js.Null.toOption(h(32)) + let u = Null.toOption(h(32)) switch u { | None => let sum = (x, y) => x + y @@ -37,7 +37,7 @@ module Test_null = { } let f4 = (h, x) => { - let u = Js.Null.toOption(h(32)) + let u = Null.toOption(h(32)) let v = 32 + x switch u { | None => @@ -57,31 +57,31 @@ module Test_null = { | Some(x) => x } - /* can [from_opt x ] generate [Some None] which has type ['a Js.opt Js.opt] ? + /* can [from_opt x] generate [Some(None)] with a nested option type? No, if [x] is [null] then None else [Some x] */ - let f8 = (x: Js.Null.t>) => - switch Js.Null.toOption(x) { + let f8 = (x: Null.t>) => + switch Null.toOption(x) { | Some(x) => - switch Js.Null.toOption(x) { + switch Null.toOption(x) { | Some(_) => 0 | None => 1 } | None => 2 } - let u = f8(Js.Null.return(Js.Null.return(None))) + let u = f8(Null.make(Null.make(None))) - let f9 = x => Js.Null.toOption(x) + let f9 = x => Null.toOption(x) - let f10 = x => x == Js.null + let f10 = x => x == Null.null - let f11 = Js.Null.return(3) == Js.null + let f11 = Null.make(3) == Null.null } -module Test_def = { +module Test_nullable = { let f1 = x => - switch Js.Undefined.toOption(x) { + switch Nullable.toOption(x) { | None => let sum = (x, y) => x + y sum(1, 2) @@ -91,7 +91,7 @@ module Test_def = { } let f2 = x => { - let u = Js.Undefined.toOption(x) + let u = Nullable.toOption(x) switch u { | None => let sum = (x, y) => x + y @@ -103,7 +103,7 @@ module Test_def = { } let f5 = (h, x) => { - let u = Js.Undefined.toOption(h(32)) + let u = Nullable.toOption(h(32)) switch u { | None => let sum = (x, y) => x + y @@ -115,7 +115,7 @@ module Test_def = { } let f4 = (h, x) => { - let u = Js.Undefined.toOption(h(32)) + let u = Nullable.toOption(h(32)) let v = 32 + x switch u { | None => @@ -135,118 +135,35 @@ module Test_def = { | Some(x) => x } - /* can [from_def x ] generate [Some None] which has type ['a Js.opt Js.opt] ? + /* can [from_opt x] generate [Some(None)] with a nested option type? No, if [x] is [null] then None else [Some x] */ - let f8 = x => - switch Js.Undefined.toOption(x) { + let f8 = (x: Nullable.t>) => + switch Nullable.toOption(x) { | Some(x) => - switch Js.Undefined.toOption(x) { + switch Nullable.toOption(x) { | Some(_) => 0 | None => 1 } | None => 2 } - let u = f8(Js.Undefined.return(Js.Undefined.return(None))) + let u = f8(Nullable.make(Nullable.make(None))) - let f9 = x => Js.Undefined.toOption(x) + let f9 = x => Nullable.toOption(x) - let f10 = x => x == Js.undefined - let f11 = Js.Undefined.return(3) == Js.undefined -} + let f10 = x => Nullable.isNullable(x) -module Test_null_def = { - open Js.Null_undefined - let f1 = x => - switch toOption(x) { - | None => - let sum = (x, y) => x + y - sum(1, 2) - | Some(x) => - let sum = (x, y) => x + y - sum(x, 1) - } - - let f2 = x => { - let u = toOption(x) - switch u { - | None => - let sum = (x, y) => x + y - sum(1, 2) - | Some(x) => - let sum = (x, y) => x + y - sum(x, 1) - } - } - - let f5 = (h, x) => { - let u = toOption(h(32)) - switch u { - | None => - let sum = (x, y) => x + y - sum(1, 2) - | Some(x) => - let sum = (x, y) => x + y - sum(x, 1) - } - } - - let f4 = (h, x) => { - let u = toOption(h(32)) - let v = 32 + x - switch u { - | None => - let sum = (x, y) => x + y - sum(1, v) - | Some(x) => - let sum = (x, y) => x + y - sum(x, 1) - } - } - - let f6 = (x, y) => x === y - - let f7 = x => - switch Some(x) { - | None => None - | Some(x) => x - } - - /* can [from_opt x ] generate [Some None] which has type ['a Js.opt Js.opt] ? - No, if [x] is [null] then None else [Some x] - */ - let f8 = (x: t>) => - switch toOption(x) { - | Some(x) => - switch toOption(x) { - | Some(_) => 0 - | None => 1 - } - | None => 2 - } - - let u = f8(return(return(None))) - - let f9 = x => toOption(x) - - let f10 = x => isNullable(x) - - let f11 = isNullable(return(3)) + let f11 = Nullable.isNullable(Nullable.make(3)) } describe(__MODULE__, () => { - test("Test_null_def.f1 with return(0)", () => - eq(__LOC__, Test_null_def.f1(Js.Null_undefined.return(0)), 1) - ) - test("Test_null_def.f1 with null", () => eq(__LOC__, Test_null_def.f1(%raw("null")), 3)) - test("Test_null_def.f1 with undefined", () => eq(__LOC__, Test_null_def.f1(%raw("undefined")), 3)) + test("Test_nullable.f1 with return(0)", () => eq(__LOC__, Test_nullable.f1(Nullable.make(0)), 1)) + test("Test_nullable.f1 with null", () => eq(__LOC__, Test_nullable.f1(%raw("null")), 3)) + test("Test_nullable.f1 with undefined", () => eq(__LOC__, Test_nullable.f1(%raw("undefined")), 3)) - test("Test_null.f1 with return(0)", () => eq(__LOC__, Test_null.f1(Js.Null.return(0)), 1)) + test("Test_null.f1 with return(0)", () => eq(__LOC__, Test_null.f1(Null.make(0)), 1)) test("Test_null.f1 with null", () => eq(__LOC__, Test_null.f1(%raw("null")), 3)) - - test("Test_def.f1 with return(0)", () => eq(__LOC__, Test_def.f1(Js.Undefined.return(0)), 1)) - test("Test_def.f1 with undefined", () => eq(__LOC__, Test_def.f1(%raw("undefined")), 3)) }) module Null_undefined_neq = { diff --git a/tests/tests/src/ticker.mjs b/tests/tests/src/ticker.mjs index c5d63b4b01a..2814daec777 100644 --- a/tests/tests/src/ticker.mjs +++ b/tests/tests/src/ticker.mjs @@ -22,11 +22,11 @@ function split(delim, s) { let i$p = s.lastIndexOf(delim, x - 1 | 0); if (i$p === -1) { return { - hd: s.substr(0, x), + hd: s.slice(0, x), tl: l }; } - let l_0 = s.substr(i$p + 1 | 0, (x - i$p | 0) - 1 | 0); + let l_0 = s.slice(i$p + 1 | 0, x); let l$1 = { hd: l_0, tl: l @@ -46,7 +46,7 @@ function split(delim, s) { function string_of_float_option(x) { if (x !== undefined) { - return x.toString(); + return String(x); } else { return "nan"; } diff --git a/tests/tests/src/ticker.res b/tests/tests/src/ticker.res index 3bf55ab701a..c0411b94deb 100644 --- a/tests/tests/src/ticker.res +++ b/tests/tests/src/ticker.res @@ -8,10 +8,10 @@ module Util = { switch x { | 0 => l | i => - switch Js.String2.lastIndexOfFrom(s, delim, i - 1) { - | -1 => list{Js.String2.substrAtMost(s, ~from=0, ~length=i), ...l} + switch String.lastIndexOfFrom(s, delim, i - 1) { + | -1 => list{String.slice(s, ~start=0, ~end=i), ...l} | i' => - let l = list{Js.String2.substrAtMost(s, ~from=i' + 1, ~length=i - i' - 1), ...l} + let l = list{String.slice(s, ~start=i' + 1, ~end=i), ...l} let l = if i' == 0 { list{"", ...l} } else { @@ -21,7 +21,7 @@ module Util = { } } - let len = Js.String2.length(s) + let len = String.length(s) switch len { | 0 => list{} | _ => loop(list{}, len) @@ -30,7 +30,7 @@ module Util = { let string_of_float_option = x => switch x { - | Some(x) => Js.Float.toString(x) + | Some(x) => Float.toString(x) | None => "nan" } } @@ -87,17 +87,17 @@ let print_all_composite = all_tickers => module Ticker_map = Map.String -/** For each market tickers, this function will compute +/** For each market tickers, this function will compute the associated list of tickers value to be updated - based on the correct graph ordering + based on the correct graph ordering - We first rank all the tickers with a depth first search - algorithm (lowest rank for the deepest nodes). + We first rank all the tickers with a depth first search + algorithm (lowest rank for the deepest nodes). - We then collect all the tickers which depends on each of the - market tickers and finally we `sort_uniq` that list by rank to - guarantee that a composite ticker is update only once and in - the correct order. + We then collect all the tickers which depends on each of the + market tickers and finally we `sort_uniq` that list by rank to + guarantee that a composite ticker is update only once and in + the correct order. */ let compute_update_sequences = all_tickers => { /* Ranking */ @@ -167,7 +167,7 @@ let compute_update_sequences = all_tickers => { }) } -/** Process a new quote for a market ticker +/** Process a new quote for a market ticker */ let process_quote = (ticker_map, new_ticker, new_value) => { let update_sequence = ticker_map->Ticker_map.getExn(new_ticker) diff --git a/tests/tests/src/to_string_test.res b/tests/tests/src/to_string_test.res index e7d724f4440..0b9df5278fd 100644 --- a/tests/tests/src/to_string_test.res +++ b/tests/tests/src/to_string_test.res @@ -1,8 +1,8 @@ open Mocha open Test_utils -let ff = v => Js.Float.toString(v) -let f = v => Js.Int.toString(v) +let ff = v => Float.toString(v) +let f = v => Int.toString(v) describe(__MODULE__, () => { test("infinity to string", () => eq(__LOC__, ff(infinity), "Infinity")) diff --git a/tests/tests/src/typeof_test.mjs b/tests/tests/src/typeof_test.mjs index fb5052f1eda..5f6082358c0 100644 --- a/tests/tests/src/typeof_test.mjs +++ b/tests/tests/src/typeof_test.mjs @@ -1,51 +1,47 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Mocha from "mocha"; -import * as Js_types from "@rescript/runtime/lib/es6/Js_types.mjs"; import * as Test_utils from "./test_utils.mjs"; +import * as Stdlib_Type from "@rescript/runtime/lib/es6/Stdlib_Type.mjs"; function string_or_number(x) { - let ty = Js_types.classify(x); + let ty = Stdlib_Type.Classify.classify(x); if (typeof ty !== "object") { - switch (ty) { - default: - return false; - } - } else { - switch (ty.TAG) { - case "JSNumber" : - console.log(ty._0 + 3); - return true; - case "JSString" : - console.log(ty._0 + "hei"); - return true; - case "JSFunction" : - console.log("Function"); - return false; - case "JSBigInt" : - console.log(ty._0.toString()); - return true; - default: - return false; - } + return false; + } + switch (ty.TAG) { + case "String" : + console.log(ty._0 + "hei"); + return true; + case "Number" : + console.log(ty._0 + 3); + return true; + case "Function" : + console.log("Function"); + return false; + case "BigInt" : + console.log(ty._0.toString()); + return true; + default: + return false; } } Mocha.describe("Typeof_test", () => { Mocha.test("int_type", () => Test_utils.eq("File \"typeof_test.res\", line 29, characters 7-14", "number", "number")); Mocha.test("string_type", () => Test_utils.eq("File \"typeof_test.res\", line 33, characters 7-14", "string", "string")); - Mocha.test("number_gadt_test", () => Test_utils.eq("File \"typeof_test.res\", line 37, characters 7-14", Js_types.test(3, "Number"), true)); - Mocha.test("boolean_gadt_test", () => Test_utils.eq("File \"typeof_test.res\", line 41, characters 7-14", Js_types.test(true, "Boolean"), true)); - Mocha.test("undefined_gadt_test", () => Test_utils.eq("File \"typeof_test.res\", line 45, characters 7-14", Js_types.test(undefined, "Undefined"), true)); + Mocha.test("number_gadt_test", () => Test_utils.eq("File \"typeof_test.res\", line 37, characters 7-14", "number", "number")); + Mocha.test("boolean_gadt_test", () => Test_utils.eq("File \"typeof_test.res\", line 41, characters 7-14", "boolean", "boolean")); + Mocha.test("undefined_gadt_test", () => Test_utils.eq("File \"typeof_test.res\", line 45, characters 7-14", typeof undefined, "undefined")); Mocha.test("string_on_number1", () => Test_utils.eq("File \"typeof_test.res\", line 49, characters 7-14", string_or_number("xx"), true)); Mocha.test("string_on_number2", () => Test_utils.eq("File \"typeof_test.res\", line 53, characters 7-14", string_or_number(3.02), true)); Mocha.test("string_on_number3", () => Test_utils.eq("File \"typeof_test.res\", line 57, characters 7-14", string_or_number(x => x), false)); - Mocha.test("string_gadt_test", () => Test_utils.eq("File \"typeof_test.res\", line 61, characters 7-14", Js_types.test("3", "String"), true)); - Mocha.test("string_gadt_test_neg", () => Test_utils.eq("File \"typeof_test.res\", line 65, characters 7-14", Js_types.test(3, "String"), false)); - Mocha.test("function_gadt_test", () => Test_utils.eq("File \"typeof_test.res\", line 69, characters 7-14", Js_types.test(x => x, "Function"), true)); - Mocha.test("object_gadt_test", () => Test_utils.eq("File \"typeof_test.res\", line 73, characters 7-14", Js_types.test({ + Mocha.test("string_gadt_test", () => Test_utils.eq("File \"typeof_test.res\", line 61, characters 7-14", "string", "string")); + Mocha.test("string_gadt_test_neg", () => Test_utils.eq("File \"typeof_test.res\", line 65, characters 7-14", "number" === "string", false)); + Mocha.test("function_gadt_test", () => Test_utils.eq("File \"typeof_test.res\", line 69, characters 7-14", typeof (x => x), "function")); + Mocha.test("object_gadt_test", () => Test_utils.eq("File \"typeof_test.res\", line 73, characters 7-14", typeof ({ x: 3 - }, "Object"), true)); + }), "object")); }); export { diff --git a/tests/tests/src/typeof_test.res b/tests/tests/src/typeof_test.res index 885a88bf855..1351c9040c5 100644 --- a/tests/tests/src/typeof_test.res +++ b/tests/tests/src/typeof_test.res @@ -2,47 +2,47 @@ open Mocha open Test_utils let string_or_number = (type t, x) => { - let ty = Js.Types.classify(x) + let ty = Type.Classify.classify(x) switch ty { - | JSString(v) => + | String(v) => Console.log(v ++ "hei") true /* type check */ - | JSNumber(v) => + | Number(v) => Console.log(v +. 3.) true /* type check */ - | JSUndefined => false - | JSNull => false - | JSFalse | JSTrue => false - | JSFunction(_) => + | Undefined => false + | Null => false + | Bool(_) => false + | Function(_) => Console.log("Function") false - | JSObject(_) => false - | JSSymbol(_) => false - | JSBigInt(v) => - v->Js.BigInt.toString->Console.log + | Object(_) => false + | Symbol(_) => false + | BigInt(v) => + v->BigInt.toString->Console.log true } } describe(__MODULE__, () => { test("int_type", () => { - eq(__LOC__, Js.typeof(3), "number") + eq(__LOC__, Type.typeof(3), #number) }) test("string_type", () => { - eq(__LOC__, Js.typeof("x"), "string") + eq(__LOC__, Type.typeof("x"), #string) }) test("number_gadt_test", () => { - eq(__LOC__, Js.Types.test(3, Number), true) + eq(__LOC__, Type.typeof(3), #number) }) test("boolean_gadt_test", () => { - eq(__LOC__, Js.Types.test(true, Boolean), true) + eq(__LOC__, Type.typeof(true), #boolean) }) test("undefined_gadt_test", () => { - eq(__LOC__, Js.Types.test(Js.undefined, Undefined), true) + eq(__LOC__, Type.typeof(undefined), #undefined) }) test("string_on_number1", () => { @@ -58,18 +58,18 @@ describe(__MODULE__, () => { }) test("string_gadt_test", () => { - eq(__LOC__, Js.Types.test("3", String), true) + eq(__LOC__, Type.typeof("3"), #string) }) test("string_gadt_test_neg", () => { - eq(__LOC__, Js.Types.test(3, String), false) + eq(__LOC__, Type.typeof(3) == #string, false) }) test("function_gadt_test", () => { - eq(__LOC__, Js.Types.test(x => x, Function), true) + eq(__LOC__, Type.typeof(x => x), #function) }) test("object_gadt_test", () => { - eq(__LOC__, Js.Types.test({"x": 3}, Object), true) + eq(__LOC__, Type.typeof({"x": 3}), #object) }) }) diff --git a/tests/tests/src/undef_regression_test.mjs b/tests/tests/src/undef_regression_test.mjs index e2369555f73..29a180a4a21 100644 --- a/tests/tests/src/undef_regression_test.mjs +++ b/tests/tests/src/undef_regression_test.mjs @@ -1,6 +1,5 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Js_undefined from "@rescript/runtime/lib/es6/Js_undefined.mjs"; import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.mjs"; function f(obj) { @@ -8,9 +7,8 @@ function f(obj) { return; } let size = obj.length; - let s = Js_undefined.toOption(size); - if (s !== undefined) { - console.log(Primitive_option.valFromOption(s)); + if (size !== undefined) { + console.log(Primitive_option.valFromOption(size)); return; } } diff --git a/tests/tests/src/undef_regression_test.res b/tests/tests/src/undef_regression_test.res index 6fa13b8906d..99efaab43d4 100644 --- a/tests/tests/src/undef_regression_test.res +++ b/tests/tests/src/undef_regression_test.res @@ -1,11 +1,11 @@ -@get external size_of_t: Obj.t => Js.undefined<'a> = "length" +@get external size_of_t: Obj.t => option<'a> = "length" let f = obj => - if Js.typeof(obj) == "function" { + if typeof(obj) == #function { () } else { let size = size_of_t(obj) - switch Js.Undefined.toOption(size) { + switch size { | None => () | Some(s) => Console.log(s) } diff --git a/tests/tests/src/variantsMatching.res b/tests/tests/src/variantsMatching.res index 1c7be9d907d..742f4623446 100644 --- a/tests/tests/src/variantsMatching.res +++ b/tests/tests/src/variantsMatching.res @@ -256,7 +256,7 @@ module TaggedUnions = { let area = (shape: shape): float => { switch shape { - | Circle({radius}) => Js.Math._PI *. radius ** 2. + | Circle({radius}) => Math.Constants.pi *. radius ** 2. | Square({sideLength}) => sideLength ** 2. | Rectangle({width, height}) => width *. height } diff --git a/tests/tests/src/webpack_config.res b/tests/tests/src/webpack_config.res index a013d1456e4..6928a298c87 100644 --- a/tests/tests/src/webpack_config.res +++ b/tests/tests/src/webpack_config.res @@ -1,24 +1,24 @@ open Belt module type Config = { - let configx: Js.Json.t + let configx: JSON.t } module WebpackConfig: Config = { - @module external configx: Js.Json.t = "../../../webpack.config.js" + @module external configx: JSON.t = "../../../webpack.config.js" } module WebpackDevMiddlewareConfig: Config = { - @module external configx: Js.Json.t = "../../../webpack.middleware.config.js" + @module external configx: JSON.t = "../../../webpack.middleware.config.js" } @module("../../../webpack.middleware.config.js") @val -external configX: unit => Js.Json.t = "configX" +external configX: unit => JSON.t = "configX" let configX = configX module U: { - let configX: unit => Js.Json.t + let configX: unit => JSON.t } = { - @module("../../../webpack.config.js") @val external configX: unit => Js.Json.t = "configX" + @module("../../../webpack.config.js") @val external configX: unit => JSON.t = "configX" } @module("List") external hey: unit => unit = "xx" module A = { diff --git a/tests/tools_tests/src/DocExtraction2.res b/tests/tools_tests/src/DocExtraction2.res index 3c60e9adcfe..4cde2e5cc8b 100644 --- a/tests/tools_tests/src/DocExtraction2.res +++ b/tests/tools_tests/src/DocExtraction2.res @@ -11,4 +11,4 @@ module InnerModule = { // ^dex -let log = msg => Js.log(msg) +let log = msg => Console.log(msg) diff --git a/tests/tools_tests/src/expected/StdlibMigration_Array.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Array.res.expected deleted file mode 100644 index e0a35425f92..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Array.res.expected +++ /dev/null @@ -1,176 +0,0 @@ -let shift1 = [1, 2, 3]->Array.shift -let shift2 = Array.shift([1, 2, 3]) - -let slice1 = [1, 2, 3]->Array.slice(~start=1, ~end=2) -let slice2 = Array.slice([1, 2, 3], ~start=1, ~end=2) - -external someArrayLike: Array.arrayLike = "whatever" - -let from1 = someArrayLike->Array.fromArrayLike -let from2 = Array.fromArrayLike(someArrayLike) - -let fromMap1 = someArrayLike->Array.fromArrayLikeWithMap(s => s ++ "!") -let fromMap2 = Array.fromArrayLikeWithMap(someArrayLike, s => s ++ "!") - -let isArray1 = [1, 2, 3]->Array.isArray -let isArray2 = Array.isArray([1, 2, 3]) - -let length1 = [1, 2, 3]->Array.length -let length2 = Array.length([1, 2, 3]) - -let fillInPlace1 = [1, 2, 3]->Array.fillAll(0) -let fillInPlace2 = Array.fillAll([1, 2, 3], 0) - -let fillFromInPlace1 = [1, 2, 3, 4]->Array.fillToEnd(0, ~start=2) -let fillFromInPlace2 = Array.fillToEnd([1, 2, 3, 4], 0, ~start=2) - -let fillRangeInPlace1 = [1, 2, 3, 4]->Array.fill(0, ~start=1, ~end=3) -let fillRangeInPlace2 = Array.fill([1, 2, 3, 4], 0, ~start=1, ~end=3) - -let pop1 = [1, 2, 3]->Array.pop -let pop2 = Array.pop([1, 2, 3]) - -let reverseInPlace1 = [1, 2, 3]->Array.reverse -let reverseInPlace2 = Array.reverse([1, 2, 3]) - -let concat1 = [1, 2]->Array.concat([3, 4]) -let concat2 = Array.concat([1, 2], [3, 4]) - -let concatMany1 = [1, 2]->Array.concatMany([[3, 4], [5, 6]]) -let concatMany2 = Array.concatMany([1, 2], [[3, 4], [5, 6]]) - -let includes1 = [1, 2, 3]->Array.includes(2) -let includes2 = Array.includes([1, 2, 3], 2) - -let indexOf1 = [1, 2, 3]->Array.indexOf(2) -let indexOf2 = Array.indexOf([1, 2, 3], 2) - -let indexOfFrom1 = [1, 2, 1, 3]->Array.indexOfFrom(1, 2) -let indexOfFrom2 = Array.indexOfFrom([1, 2, 1, 3], 1, 2) - -let joinWith1 = [1, 2, 3]->Array.joinUnsafe(",") -let joinWith2 = Array.joinUnsafe([1, 2, 3], ",") - -let lastIndexOf1 = [1, 2, 1, 3]->Array.lastIndexOf(1) -let lastIndexOf2 = Array.lastIndexOf([1, 2, 1, 3], 1) - -let lastIndexOfFrom1 = [1, 2, 1, 3, 1]->Array.lastIndexOfFrom(1, 3) -let lastIndexOfFrom2 = Array.lastIndexOfFrom([1, 2, 1, 3, 1], 1, 3) - -let copy1 = [1, 2, 3]->Array.copy -let copy2 = Array.copy([1, 2, 3]) - -let sliceFrom1 = [1, 2, 3, 4]->Array.slice(~start=2) -let sliceFrom2 = Array.slice([1, 2, 3, 4], ~start=2) - -let toString1 = [1, 2, 3]->Array.toString -let toString2 = Array.toString([1, 2, 3]) - -let toLocaleString1 = [1, 2, 3]->Array.toLocaleString -let toLocaleString2 = Array.toLocaleString([1, 2, 3]) - -let every1 = [2, 4, 6]->Array.every(x => mod(x, 2) == 0) -let every2 = Array.every([2, 4, 6], x => mod(x, 2) == 0) - -let everyi1 = [0, 1, 2]->Array.everyWithIndex((x, i) => x == i) -let everyi2 = Array.everyWithIndex([0, 1, 2], (x, i) => x == i) - -let filter1 = [1, 2, 3, 4]->Array.filter(x => x > 2) -let filter2 = Array.filter([1, 2, 3, 4], x => x > 2) - -let filteri1 = [0, 1, 2, 3]->Array.filterWithIndex((_x, i) => i > 1) -let filteri2 = Array.filterWithIndex([0, 1, 2, 3], (_x, i) => i > 1) - -let find1 = [1, 2, 3, 4]->Array.find(x => x > 2) -let find2 = Array.find([1, 2, 3, 4], x => x > 2) - -let findi1 = [0, 1, 2, 3]->Array.findWithIndex((_x, i) => i > 1) -let findi2 = Array.findWithIndex([0, 1, 2, 3], (_x, i) => i > 1) - -let findIndex1 = [1, 2, 3, 4]->Array.findIndex(x => x > 2) -let findIndex2 = Array.findIndex([1, 2, 3, 4], x => x > 2) - -let findIndexi1 = [0, 1, 2, 3]->Array.findIndexWithIndex((_x, i) => i > 1) -let findIndexi2 = Array.findIndexWithIndex([0, 1, 2, 3], (_x, i) => i > 1) - -let forEach1 = [1, 2, 3]->Array.forEach(x => ignore(x)) -let forEach2 = Array.forEach([1, 2, 3], x => ignore(x)) - -let forEachi1 = [1, 2, 3]->Array.forEachWithIndex((x, i) => ignore(x + i)) -let forEachi2 = Array.forEachWithIndex([1, 2, 3], (x, i) => ignore(x + i)) - -let map1 = [1, 2, 3]->Array.map(x => x * 2) -let map2 = Array.map([1, 2, 3], x => x * 2) - -let mapi1 = [1, 2, 3]->Array.mapWithIndex((x, i) => x + i) -let mapi2 = Array.mapWithIndex([1, 2, 3], (x, i) => x + i) - -let some1 = [1, 2, 3, 4]->Array.some(x => x > 3) -let some2 = Array.some([1, 2, 3, 4], x => x > 3) - -let somei1 = [0, 1, 2, 3]->Array.someWithIndex((_x, i) => i > 2) -let somei2 = Array.someWithIndex([0, 1, 2, 3], (_x, i) => i > 2) - -let unsafeGet1 = [1, 2, 3]->Array.getUnsafe(1) -let unsafeGet2 = Array.getUnsafe([1, 2, 3], 1) - -let unsafeSet1 = [1, 2, 3]->Array.setUnsafe(1, 5) -let unsafeSet2 = Array.setUnsafe([1, 2, 3], 1, 5) - -let copyWithin1 = [1, 2, 3, 4, 5]->Array.copyAllWithin(~target=2) -let copyWithin2 = Array.copyAllWithin([1, 2, 3, 4, 5], ~target=2) - -let copyWithinFrom1 = [1, 2, 3, 4, 5]->Array.copyWithinToEnd(~target=0, ~start=2) -let copyWithinFrom2 = Array.copyWithinToEnd([1, 2, 3, 4, 5], ~target=0, ~start=2) - -let copyWithinFromRange1 = [1, 2, 3, 4, 5, 6]->Array.copyWithin(~start=2, ~target=1, ~end=5) -let copyWithinFromRange2 = Array.copyWithin([1, 2, 3, 4, 5, 6], ~start=2, ~target=1, ~end=5) - -let push1 = [1, 2, 3]->Array.push(4) -let push2 = Array.push([1, 2, 3], 4) - -let pushMany1 = [1, 2, 3]->Array.pushMany([4, 5]) -let pushMany2 = Array.pushMany([1, 2, 3], [4, 5]) - -let sortInPlace1 = - ["c", "a", "b"]->Array.toSorted((_a, _b) => - %todo("This needs a comparator function. Use `String.compare` for strings, etc.") - ) -let sortInPlace2 = Array.toSorted(["c", "a", "b"], (_a, _b) => - %todo("This needs a comparator function. Use `String.compare` for strings, etc.") -) - -let unshift1 = [1, 2, 3]->Array.unshift(4) -let unshift2 = Array.unshift([1, 2, 3], 4) - -let unshiftMany1 = [1, 2, 3]->Array.unshiftMany([4, 5]) -let unshiftMany2 = Array.unshiftMany([1, 2, 3], [4, 5]) - -let reduce1 = [1, 2, 3]->Array.reduce(0, (acc, x) => acc + x) -let reduce2 = Array.reduce([1, 2, 3], 0, (acc, x) => acc + x) - -let spliceInPlace1 = [1, 2, 3]->Array.splice(~start=1, ~remove=1, ~insert=[4, 5]) -let spliceInPlace2 = Array.splice([1, 2, 3], ~start=1, ~remove=1, ~insert=[4, 5]) - -let removeFromInPlace1 = [1, 2, 3]->Array.removeInPlace(1) -let removeFromInPlace2 = Array.removeInPlace([1, 2, 3], 1) - -let removeCountInPlace1 = [1, 2, 3]->Array.splice(~start=1, ~remove=1, ~insert=[]) -let removeCountInPlace2 = Array.splice([1, 2, 3], ~start=1, ~remove=1, ~insert=[]) - -let reducei1 = [1, 2, 3]->Array.reduceWithIndex(0, (acc, x, i) => acc + x + i) -let reducei2 = Array.reduceWithIndex([1, 2, 3], 0, (acc, x, i) => acc + x + i) - -let reduceRight1 = [1, 2, 3]->Array.reduceRight(0, (acc, x) => acc + x) -let reduceRight2 = Array.reduceRight([1, 2, 3], 0, (acc, x) => acc + x) - -let reduceRighti1 = [1, 2, 3]->Array.reduceRightWithIndex(0, (acc, x, i) => acc + x + i) -let reduceRighti2 = Array.reduceRightWithIndex([1, 2, 3], 0, (acc, x, i) => acc + x + i) - -let pipeChain = - [1, 2, 3]->Array.map(x => x * 2)->Array.filter(x => x > 2)->Array.reduce(0, (acc, x) => acc + x) - -// Type alias migrations -let arrT: array = [1, 2, 3] -let arr2T: array = [1, 2, 3] - diff --git a/tests/tools_tests/src/expected/StdlibMigration_ArrayAppend.res.expected b/tests/tools_tests/src/expected/StdlibMigration_ArrayAppend.res.expected deleted file mode 100644 index 3d3d701e8df..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_ArrayAppend.res.expected +++ /dev/null @@ -1,3 +0,0 @@ -let ys = Array.concat([1], [2]) -let zs = [1]->Array.concat([1], [2]) - diff --git a/tests/tools_tests/src/expected/StdlibMigration_BigInt.res.expected b/tests/tools_tests/src/expected/StdlibMigration_BigInt.res.expected deleted file mode 100644 index fc8caeecd25..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_BigInt.res.expected +++ /dev/null @@ -1,49 +0,0 @@ -let fromStringExn1 = "123"->BigInt.fromStringOrThrow -let fromStringExn2 = BigInt.fromStringOrThrow("123") - -let land1 = 7n &&& 4n -let land2 = 7n &&& 4n -let land3 = 7n->BigInt.toString->BigInt.fromStringOrThrow->BigInt.bitwiseAnd(4n) - -let lor1 = 7n ||| 4n -let lor2 = 7n ||| 4n - -let lxor1 = 7n ^^^ 4n -let lxor2 = 7n ^^^ 4n - -let lnot1 = 2n->Js.BigInt.lnot -let lnot2 = Js.BigInt.lnot(2n) - -let lsl1 = 4n << 1n -let lsl2 = 4n << 1n - -let asr1 = 8n >> 1n -let asr2 = 8n >> 1n - -let toString1 = 123n->BigInt.toString -let toString2 = BigInt.toString(123n) - -let toLocaleString1 = 123n->BigInt.toLocaleString -let toLocaleString2 = BigInt.toLocaleString(123n) - -// From the stdlib module -let stdlib_fromStringExn1 = "123"->BigInt.fromStringOrThrow -let stdlib_fromStringExn2 = BigInt.fromStringOrThrow("123") - -let stdlib_land1 = 7n &&& 4n -let stdlib_land2 = 7n &&& 4n - -let stdlib_lor1 = 7n ||| 4n - -let stdlib_lxor1 = 7n ^^^ 4n -let stdlib_lxor2 = 7n ^^^ 4n - -let stdlib_lnot1 = ~~~2n -let stdlib_lnot2 = ~~~2n - -let stdlib_lsl1 = 4n << 1n -let stdlib_lsl2 = 4n << 1n - -let stdlib_asr1 = 8n >> 1n -let stdlib_asr2 = 8n >> 1n - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Console.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Console.res.expected deleted file mode 100644 index 472198684f9..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Console.res.expected +++ /dev/null @@ -1,29 +0,0 @@ -let log = Console.log("Hello, World!") -let log2 = Console.log2("Hello", "World") -let log3 = Console.log3("Hello", "World", "!") -let log4 = Console.log4("Hello", "World", "!", "!") -let logMany = Console.logMany(["Hello", "World"]) - -let info = Console.info("Hello, World!") -let info2 = Console.info2("Hello", "World") -let info3 = Console.info3("Hello", "World", "!") -let info4 = Console.info4("Hello", "World", "!", "!") -let infoMany = Console.infoMany(["Hello", "World"]) - -let warn = Console.warn("Hello, World!") -let warn2 = Console.warn2("Hello", "World") -let warn3 = Console.warn3("Hello", "World", "!") -let warn4 = Console.warn4("Hello", "World", "!", "!") -let warnMany = Console.warnMany(["Hello", "World"]) - -let error = Console.error("Hello, World!") -let error2 = Console.error2("Hello", "World") -let error3 = Console.error3("Hello", "World", "!") -let error4 = Console.error4("Hello", "World", "!", "!") -let errorMany = Console.errorMany(["Hello", "World"]) - -let trace = Console.trace() -let timeStart = Console.time("Hello, World!") -let timeEnd = Console.timeEnd("Hello, World!") -let table = Console.table(["Hello", "World"]) - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Date.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Date.res.expected deleted file mode 100644 index 2b3dd5658bc..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Date.res.expected +++ /dev/null @@ -1,191 +0,0 @@ -let d1 = Date.make() -let d2 = Date.fromString("1973-11-29T21:30:54.321Z") -let d3 = Date.fromTime(123456789.0) - -let msNow = Date.now() - -let v1 = d2->Date.getTime -let v2 = Date.getTime(d2) - -let y = d2->Date.getFullYear -let mo = d2->Date.getMonth -let dayOfMonth = d2->Date.getDate -let dayOfWeek = d2->Date.getDay -let h = d2->Date.getHours -let mi = d2->Date.getMinutes -let s = d2->Date.getSeconds -let ms = d2->Date.getMilliseconds -let tz = d2->Date.getTimezoneOffset - -let uy = d2->Date.getUTCFullYear -let um = d2->Date.getUTCMonth -let ud = d2->Date.getUTCDate -let uday = d2->Date.getUTCDay -let uh = d2->Date.getUTCHours -let umi = d2->Date.getUTCMinutes -let us = d2->Date.getUTCSeconds -let ums = d2->Date.getUTCMilliseconds - -let s1 = d2->Date.toISOString -let s2 = d2->Date.toUTCString -let s3 = d2->Date.toString -let s4 = d2->Date.toTimeString -let s5 = d2->Date.toDateString -let s6 = d2->Date.toLocaleString -let s7 = d2->Date.toLocaleDateString -let s8 = d2->Date.toLocaleTimeString - -/* Additional deprecated APIs to exercise migration */ - -/* getters and legacy variants */ -let t = d2->Date.getTime -let y2 = d2->Date.getFullYear - -/* constructors with components */ -let mym = Date.makeWithYM(~year=Float.toInt(2020.0), ~month=Float.toInt(10.0)) -let mymd = Date.makeWithYMD( - ~year=Float.toInt(1973.0), - ~month=Float.toInt(10.0), - ~day=Float.toInt(29.0), -) -let mymdh = Date.makeWithYMDH( - ~year=Float.toInt(1973.0), - ~month=Float.toInt(10.0), - ~day=Float.toInt(29.0), - ~hours=Float.toInt(21.0), -) -let mymdhm = Date.makeWithYMDHM( - ~year=Float.toInt(1973.0), - ~month=Float.toInt(10.0), - ~day=Float.toInt(29.0), - ~hours=Float.toInt(21.0), - ~minutes=Float.toInt(30.0), -) -let mymdhms = Date.makeWithYMDHMS( - ~year=Float.toInt(1973.0), - ~month=Float.toInt(10.0), - ~day=Float.toInt(29.0), - ~hours=Float.toInt(21.0), - ~minutes=Float.toInt(30.0), - ~seconds=Float.toInt(54.0), -) - -/* Date.UTC variants */ -let uym = Date.UTC.makeWithYM(~year=Float.toInt(2020.0), ~month=Float.toInt(10.0)) -let uymd = Date.UTC.makeWithYMD( - ~year=Float.toInt(1973.0), - ~month=Float.toInt(10.0), - ~day=Float.toInt(29.0), -) -let uymdh = Date.UTC.makeWithYMDH( - ~year=Float.toInt(1973.0), - ~month=Float.toInt(10.0), - ~day=Float.toInt(29.0), - ~hours=Float.toInt(21.0), -) -let uymdhm = Date.UTC.makeWithYMDHM( - ~year=Float.toInt(1973.0), - ~month=Float.toInt(10.0), - ~day=Float.toInt(29.0), - ~hours=Float.toInt(21.0), - ~minutes=Float.toInt(30.0), -) -let uymdhms = Date.UTC.makeWithYMDHMS( - ~year=Float.toInt(1973.0), - ~month=Float.toInt(10.0), - ~day=Float.toInt(29.0), - ~hours=Float.toInt(21.0), - ~minutes=Float.toInt(30.0), - ~seconds=Float.toInt(54.0), -) - -/* parse APIs */ -let p = Date.fromString("1973-11-29T21:30:54.321Z") -let pf = Date.getTime(Date.fromString("1973-11-29T21:30:54.321Z")) - -/* setters (local time) */ -let setD = d2->Date.setDate(Float.toInt(15.0)) -let setFY = d2->Date.setFullYear(Float.toInt(1974.0)) - -let setFYM = d2->Date.setFullYearM(~year=Float.toInt(1974.0), ~month=Float.toInt(0.0)) -let setFYMD = - d2->Date.setFullYearMD(~year=Float.toInt(1974.0), ~month=Float.toInt(0.0), ~day=Float.toInt(7.0)) -let setH = d2->Date.setHours(Float.toInt(22.0)) -let setHM = d2->Date.setHoursM(~hours=Float.toInt(22.0), ~minutes=Float.toInt(46.0)) -let setHMS = - d2->Date.setHoursMS( - ~hours=Float.toInt(22.0), - ~minutes=Float.toInt(46.0), - ~seconds=Float.toInt(37.0), - ) -let setHMSMs = - d2->Date.setHoursMSMs( - ~hours=Float.toInt(22.0), - ~minutes=Float.toInt(46.0), - ~seconds=Float.toInt(37.0), - ~milliseconds=Float.toInt(494.0), - ) -let setMs = d2->Date.setMilliseconds(Float.toInt(494.0)) -let setMin = d2->Date.setMinutes(Float.toInt(34.0)) -let setMinS = d2->Date.setMinutesS(~minutes=Float.toInt(34.0), ~seconds=Float.toInt(56.0)) -let setMinSMs = - d2->Date.setMinutesSMs( - ~minutes=Float.toInt(34.0), - ~seconds=Float.toInt(56.0), - ~milliseconds=Float.toInt(789.0), - ) -let setMon = d2->Date.setMonth(Float.toInt(11.0)) -let setMonD = d2->Js.Date.setMonthD(~month=11.0, ~date=8.0, ()) -let setSec = d2->Date.setSeconds(Float.toInt(56.0)) -let setSecMs = d2->Date.setSecondsMs(~seconds=Float.toInt(56.0), ~milliseconds=Float.toInt(789.0)) - -/* setters (UTC) */ -let setUD = d2->Date.setUTCDate(Float.toInt(15.0)) -let setUFY = d2->Date.setUTCFullYear(Float.toInt(1974.0)) -let setUFYM = d2->Date.setUTCFullYearM(~year=Float.toInt(1974.0), ~month=Float.toInt(0.0)) -let setUFYMD = - d2->Date.setUTCFullYearMD( - ~year=Float.toInt(1974.0), - ~month=Float.toInt(0.0), - ~day=Float.toInt(7.0), - ) -let setUH = d2->Date.setUTCHours(Float.toInt(22.0)) -let setUHM = d2->Date.setUTCHoursM(~hours=Float.toInt(22.0), ~minutes=Float.toInt(46.0)) -let setUHMS = - d2->Date.setUTCHoursMS( - ~hours=Float.toInt(22.0), - ~minutes=Float.toInt(46.0), - ~seconds=Float.toInt(37.0), - ) -let setUHMSMs = - d2->Date.setUTCHoursMSMs( - ~hours=Float.toInt(22.0), - ~minutes=Float.toInt(46.0), - ~seconds=Float.toInt(37.0), - ~milliseconds=Float.toInt(494.0), - ) -let setUMs = d2->Date.setUTCMilliseconds(Float.toInt(494.0)) -let setUMin = d2->Date.setUTCMinutes(Float.toInt(34.0)) -let setUMinS = d2->Date.setUTCMinutesS(~minutes=Float.toInt(34.0), ~seconds=Float.toInt(56.0)) -let setUMinSMs = - d2->Date.setUTCMinutesSMs( - ~minutes=Float.toInt(34.0), - ~seconds=Float.toInt(56.0), - ~milliseconds=Float.toInt(789.0), - ) -let setUMon = d2->Date.setUTCMonth(Float.toInt(11.0)) -let setUMonD = d2->Js.Date.setUTCMonthD(~month=11.0, ~date=8.0, ()) -let setUSec = d2->Date.setUTCSeconds(Float.toInt(56.0)) -let setUSecMs = - d2->Date.setUTCSecondsMs(~seconds=Float.toInt(56.0), ~milliseconds=Float.toInt(789.0)) -let setUT = d2->Js.Date.setUTCTime(198765432101.0) -let setYr = d2->Js.Date.setYear(1999.0) - -/* other string conversions */ -let s9 = d2->Date.toUTCString -let j1 = d2->Date.toJSON -let j2 = d2->Date.toJSON - -// Type alias migration -external someDate: Date.t = "someDate" - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Dict.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Dict.res.expected deleted file mode 100644 index 2cacd2c0d48..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Dict.res.expected +++ /dev/null @@ -1,34 +0,0 @@ -let d = Dict.make() - -let get1 = d->Dict.get("k") -let get2 = Dict.get(d, "k") - -let unsafeGet1 = d->Dict.getUnsafe("k") -let unsafeGet2 = Dict.getUnsafe(d, "k") - -let set1 = d->Dict.set("k", 1) -let set2 = Dict.set(d, "k", 1) - -let keys1 = d->Dict.keysToArray -let keys2 = Dict.keysToArray(d) - -let values1 = d->Dict.valuesToArray -let values2 = Dict.valuesToArray(d) - -let entries1 = d->Dict.toArray -let entries2 = Dict.toArray(d) - -let dStr: dict = Dict.make() -let del1 = dStr->Dict.delete("k") -let del2 = Dict.delete(dStr, "k") - -let empty1: dict = Dict.make() - -let fromArray1 = [("a", 1), ("b", 2)]->Dict.fromArray -let fromArray2 = Dict.fromArray([("a", 1), ("b", 2)]) - -let fromList1 = list{("a", 1), ("b", 2)}->Js.Dict.fromList -let fromList2 = Js.Dict.fromList(list{("a", 1), ("b", 2)}) - -let map2 = Dict.mapValues(d, x => x + 1) - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Extern.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Extern.res.expected deleted file mode 100644 index c28d1259e16..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Extern.res.expected +++ /dev/null @@ -1,7 +0,0 @@ -// Exercise migrations from Js_extern to new Stdlib APIs - -let isNullish = Nullable.isNullable(%raw("null")) -let n = Nullable.null -let u = Nullable.undefined -let ty = Type.typeof("hello") - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Float.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Float.res.expected deleted file mode 100644 index 1e70760134e..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Float.res.expected +++ /dev/null @@ -1,35 +0,0 @@ -let nan1 = Float.Constants.nan - -let isNaN1 = Float.Constants.nan->Float.isNaN -let isNaN2 = Float.isNaN(Float.Constants.nan) - -let isFinite1 = 1234.0->Float.isFinite -let isFinite2 = Float.isFinite(1234.0) - -let toExponential1 = 77.1234->Float.toExponential -let toExponential2 = Float.toExponential(77.1234) - -let toExponentialWithPrecision1 = 77.1234->Float.toExponential(~digits=2) -let toExponentialWithPrecision2 = Float.toExponential(77.1234, ~digits=2) - -let toFixed1 = 12345.6789->Float.toFixed -let toFixed2 = Float.toFixed(12345.6789) - -let toFixedWithPrecision1 = 12345.6789->Float.toFixed(~digits=1) -let toFixedWithPrecision2 = Float.toFixed(12345.6789, ~digits=1) - -let toPrecision1 = 12345.6789->Float.toPrecision -let toPrecision2 = Float.toPrecision(12345.6789) - -let toPrecisionWithPrecision1 = 12345.6789->Float.toPrecision(~digits=2) -let toPrecisionWithPrecision2 = Float.toPrecision(12345.6789, ~digits=2) - -let toString1 = 12345.6789->Float.toString -let toString2 = Float.toString(12345.6789) - -let toStringWithRadix1 = 6.0->Float.toString(~radix=2) -let toStringWithRadix2 = Float.toString(6.0, ~radix=2) - -let parse1 = "123"->Float.parseFloat -let parse2 = Float.parseFloat("123") - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Global.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Global.res.expected deleted file mode 100644 index 69e573d1350..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Global.res.expected +++ /dev/null @@ -1,16 +0,0 @@ -let t1: timeoutId = setTimeout(() => (), 1000) -let t2: timeoutId = setTimeoutFloat(() => (), 1000.0) - -clearTimeout(t1) - -let i1: intervalId = setInterval(() => (), 2000) -let i2: intervalId = setIntervalFloat(() => (), 2000.0) - -clearInterval(i1) - -let e1 = encodeURI("https://rescript-lang.org?array=[someValue]") -let d1 = decodeURI("https://rescript-lang.org?array=%5BsomeValue%5D") - -let e2 = encodeURIComponent("array=[someValue]") -let d2 = decodeURIComponent("array%3D%5BsomeValue%5D") - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Interface.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Interface.res.expected deleted file mode 100644 index 7906b96b41a..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Interface.res.expected +++ /dev/null @@ -1,9 +0,0 @@ -/* Implementation to satisfy interface build for tests */ - -external arr: array = "arr" -external reT: RegExp.t = "re" -external json: JSON.t = "json" -external nestedArr: array = "nestedArr" - -external useSet: Set.t => unit = "useSet" - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Interface.resi.expected b/tests/tools_tests/src/expected/StdlibMigration_Interface.resi.expected deleted file mode 100644 index d6ce02a731e..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Interface.resi.expected +++ /dev/null @@ -1,11 +0,0 @@ -/* Migration tests for interface (.resi) files using stdlib deprecations */ - -// Type alias migrations exercised via externals -external arr: array = "arr" -external reT: RegExp.t = "re" -external json: JSON.t = "json" -external nestedArr: array = "nestedArr" - -// Function type using a deprecated alias -external useSet: Set.t => unit = "useSet" - diff --git a/tests/tools_tests/src/expected/StdlibMigration_JSON.res.expected b/tests/tools_tests/src/expected/StdlibMigration_JSON.res.expected deleted file mode 100644 index 5f8cd42d0f7..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_JSON.res.expected +++ /dev/null @@ -1,23 +0,0 @@ -external someJson: JSON.t = "someJson" -external strToJson: string => JSON.t = "strToJson" - -let decodeString1 = someJson->JSON.Decode.string -let decodeString2 = JSON.Decode.string(someJson) -let decodeString3 = - [1, 2, 3]->Array.map(v => v->Int.toString)->Array.join(" ")->strToJson->JSON.Decode.string - -let decodeNumber1 = someJson->JSON.Decode.float -let decodeNumber2 = JSON.Decode.float(someJson) - -let decodeObject1 = someJson->JSON.Decode.object -let decodeObject2 = JSON.Decode.object(someJson) - -let decodeArray1 = someJson->JSON.Decode.array -let decodeArray2 = JSON.Decode.array(someJson) - -let decodeBoolean1 = someJson->JSON.Decode.bool -let decodeBoolean2 = JSON.Decode.bool(someJson) - -let decodeNull1 = someJson->JSON.Decode.null -let decodeNull2 = JSON.Decode.null(someJson) - diff --git a/tests/tools_tests/src/expected/StdlibMigration_JSON_ParseStringify.res.expected b/tests/tools_tests/src/expected/StdlibMigration_JSON_ParseStringify.res.expected deleted file mode 100644 index 5711d673acf..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_JSON_ParseStringify.res.expected +++ /dev/null @@ -1,15 +0,0 @@ -let p1 = JSON.parseExn("{}", ~reviver=(k, v) => v) -let p2 = JSON.parseExnWithReviver("{}", (k, v) => v) - -let s1 = JSON.stringifyWithIndent(JSON.Object(dict{}), 2) -let s2 = JSON.stringifyWithReplacer(JSON.Number(1.), (k, v) => v) -let s3 = JSON.stringifyWithReplacerAndIndent(JSON.Boolean(true), (k, v) => v, 2) -let s4 = JSON.stringifyWithFilter(JSON.Array([JSON.Number(1.)]), ["a"]) -let s5 = JSON.stringifyWithFilterAndIndent(JSON.Array([JSON.Number(1.)]), ["a"], 2) - -let a1 = JSON.stringifyAnyWithIndent(1, 2) -let a2 = JSON.stringifyAnyWithReplacer(1, (k, v) => v) -let a3 = JSON.stringifyAnyWithReplacerAndIndent(1, (k, v) => v, 2) -let a4 = JSON.stringifyAnyWithFilter(1, ["a"]) -let a5 = JSON.stringifyAnyWithFilterAndIndent(1, ["a"], 2) - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Js.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Js.res.expected deleted file mode 100644 index e87cdd9b258..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Js.res.expected +++ /dev/null @@ -1,6 +0,0 @@ -let consoleLog1 = Console.log("Hello") -let consoleLog2 = Console.log2("Hello", "World") -let consoleLog3 = Console.log3("Hello", "World", "!") -let consoleLog4 = Console.log4("Hello", "World", "!", "!") -let consoleLogMany = Console.logMany(["Hello", "World"]) - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Js_Array.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Js_Array.res.expected deleted file mode 100644 index 1e95f687c86..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Js_Array.res.expected +++ /dev/null @@ -1,34 +0,0 @@ -// Migration tests for Js.Array (old) -> Array module - -external someArrayLike: Array.arrayLike = "whatever" - -let from1 = someArrayLike->Array.fromArrayLike -let from2 = Array.fromArrayLike(someArrayLike) - -let fromMap1 = someArrayLike->Array.fromArrayLikeWithMap(s => s ++ "!") -let fromMap2 = Array.fromArrayLikeWithMap(someArrayLike, s => s ++ "!") - -let isArray1 = [1, 2, 3]->Array.isArray -let isArray2 = Array.isArray([1, 2, 3]) - -let length1 = [1, 2, 3]->Array.length -let length2 = Array.length([1, 2, 3]) - -let pop1 = [1, 2, 3]->Array.pop -let pop2 = Array.pop([1, 2, 3]) - -let reverseInPlace1 = [1, 2, 3]->Array.reverse -let reverseInPlace2 = Array.reverse([1, 2, 3]) - -let shift1 = [1, 2, 3]->Array.shift -let shift2 = Array.shift([1, 2, 3]) - -let toString1 = [1, 2, 3]->Array.toString -let toString2 = Array.toString([1, 2, 3]) - -let toLocaleString1 = [1, 2, 3]->Array.toLocaleString -let toLocaleString2 = Array.toLocaleString([1, 2, 3]) - -// Type alias migration -let arrT: array = [1, 2, 3] - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Js_Int.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Js_Int.res.expected deleted file mode 100644 index 2852afd3ba9..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Js_Int.res.expected +++ /dev/null @@ -1,24 +0,0 @@ -let toExponential1 = 77->Int.toExponential -let toExponential2 = Int.toExponential(77) - -let toExponentialWithPrecision1 = 77->Int.toExponential(~digits=2) -let toExponentialWithPrecision2 = Int.toExponential(77, ~digits=2) - -let toPrecision1 = 123456789->Int.toPrecision -let toPrecision2 = Int.toPrecision(123456789) - -let toPrecisionWithPrecision1 = 123456789->Int.toPrecision(~digits=2) -let toPrecisionWithPrecision2 = Int.toPrecision(123456789, ~digits=2) - -let toString1 = 123456789->Int.toString -let toString2 = Int.toString(123456789) - -let toStringWithRadix1 = 373592855->Int.toString(~radix=16) -let toStringWithRadix2 = Int.toString(373592855, ~radix=16) - -let toFloat1 = 42->Int.toFloat -let toFloat2 = Int.toFloat(42) - -let equal1 = Js.Int.equal(1, 1) -let equal2 = 1->Js.Int.equal(2) - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Js_More.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Js_More.res.expected deleted file mode 100644 index 4317a49af9d..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Js_More.res.expected +++ /dev/null @@ -1,8 +0,0 @@ -// Migration tests for new deprecations in packages/@rescript/runtime/Js.res - -// typeof migration -let tyNum = typeof(1) - -// nullToOption -let nToOpt = Null.toOption(Null.make(1)) - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Js_Re.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Js_Re.res.expected deleted file mode 100644 index 73388f2bed1..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Js_Re.res.expected +++ /dev/null @@ -1,51 +0,0 @@ -let re1 = RegExp.fromString("foo") -let re2 = RegExp.fromString("foo", ~flags="gi") - -let flags1 = re2->RegExp.flags -let flags2 = RegExp.flags(re2) - -let g1 = re2->RegExp.global -let g2 = RegExp.global(re2) - -let ic1 = re2->RegExp.ignoreCase -let ic2 = RegExp.ignoreCase(re2) - -let m1 = re2->RegExp.multiline -let m2 = RegExp.multiline(re2) - -let u1 = re2->RegExp.unicode -let u2 = RegExp.unicode(re2) - -let y1 = re2->RegExp.sticky -let y2 = RegExp.sticky(re2) - -let src1 = re2->RegExp.source -let src2 = RegExp.source(re2) - -let li1 = re2->RegExp.lastIndex -let () = re2->RegExp.setLastIndex(0) - -let exec1 = re2->RegExp.exec("Foo bar") -let exec2 = RegExp.exec(re2, "Foo bar") - -let test1 = re2->RegExp.test("Foo bar") -let test2 = RegExp.test(re2, "Foo bar") - -// Type alias migration -external reT: RegExp.t = "re" - -let matches_access = switch re2->RegExp.exec("Foo bar") { -| None => 0 -| Some(r) => RegExp.Result.matches(r)->Array.length -} - -let result_index = switch re2->RegExp.exec("Foo bar") { -| None => 0 -| Some(r) => RegExp.Result.index(r) -} - -let result_input = switch re2->RegExp.exec("Foo bar") { -| None => "" -| Some(r) => RegExp.Result.input(r) -} - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Js_String.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Js_String.res.expected deleted file mode 100644 index b2a4f5b63c7..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Js_String.res.expected +++ /dev/null @@ -1,44 +0,0 @@ -// Migration tests for Js.String (old) -> String module - -let make1 = 1->String.make -let make2 = String.make(1) - -let fromCharCode1 = 65->String.fromCharCode -let fromCharCode2 = String.fromCharCode(65) - -let fromCharCodeMany1 = [65, 66, 67]->String.fromCharCodeMany -let fromCharCodeMany2 = String.fromCharCodeMany([65, 66, 67]) - -let fromCodePoint1 = 65->String.fromCodePoint -let fromCodePoint2 = String.fromCodePoint(65) - -let fromCodePointMany1 = [65, 66, 67]->String.fromCodePointMany -let fromCodePointMany2 = String.fromCodePointMany([65, 66, 67]) - -let length1 = "abcde"->String.length -let length2 = String.length("abcde") - -let get1 = "abcde"->String.get(2) -let get2 = String.get("abcde", 2) - -let normalize1 = "abcde"->String.normalize -let normalize2 = String.normalize("abcde") - -let toLowerCase1 = "ABCDE"->String.toLowerCase -let toLowerCase2 = String.toLowerCase("ABCDE") - -let toUpperCase1 = "abcde"->String.toUpperCase -let toUpperCase2 = String.toUpperCase("abcde") - -let toLocaleLowerCase1 = "ABCDE"->String.toLocaleLowerCase -let toLocaleLowerCase2 = String.toLocaleLowerCase("ABCDE") - -let toLocaleUpperCase1 = "abcde"->String.toLocaleUpperCase -let toLocaleUpperCase2 = String.toLocaleUpperCase("abcde") - -let trim1 = " abcde "->String.trim -let trim2 = String.trim(" abcde ") - -// Type alias migration -let sT: string = "abc" - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Js_Types_Interface.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Js_Types_Interface.res.expected deleted file mode 100644 index 82501d26c0b..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Js_Types_Interface.res.expected +++ /dev/null @@ -1,10 +0,0 @@ -/* Implementation to satisfy interface build for tests */ - -external nullT: Null.t = "nullT" -external nullableT: Nullable.t = "nullableT" -external nullUndefT: Nullable.t = "nullUndefT" - -external symbolT: Symbol.t = "symbolT" -external objValT: Type.Classify.object = "objValT" -external functionValT: Type.Classify.function = "functionValT" - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Js_Types_Interface.resi.expected b/tests/tools_tests/src/expected/StdlibMigration_Js_Types_Interface.resi.expected deleted file mode 100644 index 6b4cf7b9932..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Js_Types_Interface.resi.expected +++ /dev/null @@ -1,12 +0,0 @@ -/* Migration tests for Js.res type deprecations */ - -// Type alias migrations exercised via externals -external nullT: Null.t = "nullT" -external nullableT: Nullable.t = "nullableT" -external nullUndefT: Nullable.t = "nullUndefT" - -// Js.Types migrations -external symbolT: Symbol.t = "symbolT" -external objValT: Type.Classify.object = "objValT" -external functionValT: Type.Classify.function = "functionValT" - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Js_Undefined.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Js_Undefined.res.expected deleted file mode 100644 index 19289cbc746..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Js_Undefined.res.expected +++ /dev/null @@ -1,36 +0,0 @@ -let make1 = "hello"->Nullable.make -let make2 = Nullable.make("hello") - -let empty1 = Nullable.undefined - -let getUnsafe1 = Nullable.make(1)->Nullable.getUnsafe -let getUnsafe2 = Nullable.getUnsafe(Nullable.make(1)) - -let getExn1 = Nullable.make(1)->Nullable.getOrThrow -let getExn2 = Nullable.getOrThrow(Nullable.make(1)) - -let map1 = Nullable.make(2)->Nullable.map(x => x + 1) -let map2 = Nullable.map(Nullable.make(2), x => x + 1) - -let forEach1 = Nullable.make(2)->Nullable.forEach(x => ignore(x)) -let forEach2 = Nullable.forEach(Nullable.make(2), x => ignore(x)) - -let fromOption1 = Some("x")->Nullable.fromOption -let fromOption2 = Nullable.fromOption(None) - -let from_opt1 = Some("y")->Nullable.fromOption -let from_opt2 = Nullable.fromOption(None) - -let toOption1 = Nullable.make(3)->Nullable.toOption -let toOption2 = Nullable.toOption(Nullable.make(3)) - -let to_opt1 = Nullable.make(4)->Nullable.toOption -let to_opt2 = Nullable.toOption(Nullable.make(4)) - -let test1 = Js.Undefined.empty->Js.Undefined.test -let test2 = Js.Undefined.test(Js.Undefined.empty) -let test3 = Js.Undefined.return(5)->Js.Undefined.bind(v => v)->Js.Undefined.test - -let testAny1 = Js.Undefined.testAny(Js.Undefined.empty) -let testAny2 = Js.Undefined.empty->Js.Undefined.testAny - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Js_typed_array.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Js_typed_array.res.expected deleted file mode 100644 index 4f4f5985388..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Js_typed_array.res.expected +++ /dev/null @@ -1,8 +0,0 @@ -let arr1 = Int8Array.fromArray([1, 2, 3]) - -let len = arr1->TypedArray.length - -let bytes = Int8Array.Constants.bytesPerElement -let off = Int8Array.fromBufferToEnd(ArrayBuffer.make(8), ~byteOffset=2) -let range = Int8Array.fromBufferWithRange(ArrayBuffer.make(8), ~byteOffset=2, ~length=2) - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Js_typed_array2.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Js_typed_array2.res.expected deleted file mode 100644 index 35d4cb885ed..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Js_typed_array2.res.expected +++ /dev/null @@ -1,19 +0,0 @@ -let arr = Int8Array.fromArray([1, 2, 3]) - -let len1 = arr->TypedArray.length -let includes1 = arr->TypedArray.includes(2) -let idxFrom1 = arr->TypedArray.indexOfFrom(2, 1) - -let slice1 = arr->TypedArray.slice(~start=1, ~end=2) -let sliceFrom1 = arr->TypedArray.sliceToEnd(~start=1) - -let map1 = arr->TypedArray.map(x => x + 1) -let reduce1 = arr->TypedArray.reduce((acc, x) => acc + x, 0) - -let bytes = Int8Array.Constants.bytesPerElement - -let fromBufToEnd = Int8Array.fromBufferToEnd(ArrayBuffer.make(8), ~byteOffset=2) -let fromBufRange = Int8Array.fromBufferWithRange(ArrayBuffer.make(8), ~byteOffset=2, ~length=2) - -let fromLength = Int8Array.fromLength(3) - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Js_typed_array2_Float32.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Js_typed_array2_Float32.res.expected deleted file mode 100644 index aae09609405..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Js_typed_array2_Float32.res.expected +++ /dev/null @@ -1,19 +0,0 @@ -let arr = Float32Array.fromArray([1.0, 2.0, 3.0]) - -let len1 = arr->TypedArray.length -let includes1 = arr->TypedArray.includes(2.0) -let idxFrom1 = arr->TypedArray.indexOfFrom(2.0, 1) - -let slice1 = arr->TypedArray.slice(~start=1, ~end=2) -let sliceFrom1 = arr->TypedArray.sliceToEnd(~start=1) - -let map1 = arr->TypedArray.map(x => x +. 1.0) -let reduce1 = arr->TypedArray.reduce((acc, x) => acc +. x, 0.0) - -let bytes = Float32Array.Constants.bytesPerElement - -let fromBufToEnd = Float32Array.fromBufferToEnd(ArrayBuffer.make(8), ~byteOffset=2) -let fromBufRange = Float32Array.fromBufferWithRange(ArrayBuffer.make(8), ~byteOffset=2, ~length=2) - -let fromLength = Float32Array.fromLength(3) - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Js_typed_array_Float32_Const.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Js_typed_array_Float32_Const.res.expected deleted file mode 100644 index 770165dc544..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Js_typed_array_Float32_Const.res.expected +++ /dev/null @@ -1,3 +0,0 @@ -// Float32 constants migration coverage for legacy Js.Typed_array -let bytesF32 = Float32Array.Constants.bytesPerElement - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Map.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Map.res.expected deleted file mode 100644 index ef71502bff9..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Map.res.expected +++ /dev/null @@ -1,3 +0,0 @@ -// Type alias migration for Js.Map.t -external m: Map.t = "m" - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Math.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Math.res.expected deleted file mode 100644 index ccce8ab209e..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Math.res.expected +++ /dev/null @@ -1,82 +0,0 @@ -// Exercise migrations from Js.Math to Math - -let e = Math.Constants.e -let pi = Math.Constants.pi -let ln2 = Math.Constants.ln2 -let ln10 = Math.Constants.ln10 -let log2e = Math.Constants.log2e -let log10e = Math.Constants.log10e -let sqrt_half = Math.Constants.sqrt1_2 -let sqrt2c = Math.Constants.sqrt2 - -let absInt1 = Math.Int.abs(-5) -let absFloat1 = Math.abs(-3.5) - -let acos1 = Math.acos(1.0) -let acosh1 = Math.acosh(1.5) -let asinh1 = Math.asinh(1.0) -let asin1 = Math.asin(0.5) -let atan1 = Math.atan(1.0) -let atanh1 = Math.atanh(0.5) - -let atan21 = Math.atan2(~y=0.0, ~x=10.0) - -let cbrt1 = Math.cbrt(27.0) - -let ceilInt1 = Math.Int.ceil(3.2) -let ceilInt2 = Math.Int.ceil(3.2) -let ceilFloat1 = Math.ceil(3.2) - -let clz1 = Math.Int.clz32(255) - -let cos1 = Math.cos(0.0) -let cosh1 = Math.cosh(0.0) -let exp1 = Math.exp(1.0) -let expm11 = Math.expm1(1.0) -let log1p1 = Math.log1p(1.0) - -let floorInt1 = Math.Int.floor(3.7) -let floorInt2 = Math.Int.floor(3.7) -let floorFloat1 = Math.floor(3.7) - -let fround1 = Math.fround(5.05) - -let hypot1 = Math.hypot(3.0, 4.0) -let hypotMany1 = Math.hypotMany([3.0, 4.0, 12.0]) - -let imul1 = Math.Int.imul(3, 4) - -let log1 = Math.log(Math.Constants.e) -let log10_1 = Math.log10(1000.0) -let log2_1 = Math.log2(512.0) - -let maxInt1 = Math.Int.max(1, 2) -let maxIntMany1 = Math.Int.maxMany([1, 10, 3]) -let maxFloat1 = Math.max(1.5, 2.5) -let maxFloatMany1 = Math.maxMany([1.5, 2.5, 0.5]) - -let minInt1 = Math.Int.min(1, 2) -let minIntMany1 = Math.Int.minMany([1, 10, 3]) -let minFloat1 = Math.min(1.5, 2.5) -let minFloatMany1 = Math.minMany([1.5, 2.5, 0.5]) - -let powInt1 = Math.Int.pow(3, ~exp=4) -let powFloat1 = Math.pow(3.0, ~exp=4.0) - -let rand1 = Math.random() - -let roundUnsafe1 = Float.toInt(Math.round(3.7)) -let round1 = Math.round(3.7) - -let signInt1 = Math.Int.sign(-5) -let signFloat1 = Math.sign(-5.0) - -let sin1 = Math.sin(0.0) -let sinh1 = Math.sinh(0.0) -let sqrt1 = Math.sqrt(9.0) -let tan1 = Math.tan(0.5) -let tanh1 = Math.tanh(0.0) - -let truncUnsafe1 = Float.toInt(Math.trunc(3.7)) -let trunc1 = Math.trunc(3.7) - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Null.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Null.res.expected deleted file mode 100644 index 7e7a2ac5fbd..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Null.res.expected +++ /dev/null @@ -1,36 +0,0 @@ -let make1 = "hello"->Null.make -let make2 = Null.make("hello") - -let empty1 = Null.null - -let getUnsafe1 = Null.make(1)->Null.getUnsafe -let getUnsafe2 = Null.getUnsafe(Null.make(1)) - -let getExn1 = Null.make(1)->Null.getOrThrow -let getExn2 = Null.getOrThrow(Null.make(1)) - -let map1 = Null.make(2)->Null.map(x => x + 1) -let map2 = Null.map(Null.make(2), x => x + 1) - -let forEach1 = Null.make(2)->Null.forEach(x => ignore(x)) -let forEach2 = Null.forEach(Null.make(2), x => ignore(x)) - -let fromOption1 = Some("x")->Null.fromOption -let fromOption2 = Null.fromOption(None) - -let from_opt1 = Some("y")->Null.fromOption -let from_opt2 = Null.fromOption(None) - -let toOption1 = Null.make(3)->Null.toOption -let toOption2 = Null.toOption(Null.make(3)) - -let to_opt1 = Null.make(4)->Null.toOption -let to_opt2 = Null.toOption(Null.make(4)) - -let test1 = Null.null === Null.null -let test2 = Null.null === Null.null -let test3 = Null.make(5)->Null.map(v => v)->Null.equal(Null, (a, b) => a === b) - -// Type alias migration -let nullT: Null.t = Null.make(1) - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Nullable.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Nullable.res.expected deleted file mode 100644 index 8412fd909ea..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Nullable.res.expected +++ /dev/null @@ -1,35 +0,0 @@ -let make1 = "hello"->Nullable.make -let make2 = Nullable.make("hello") - -let null1 = Nullable.null -let undefined1 = Nullable.undefined - -let isNullable1 = Nullable.null->Nullable.isNullable -let isNullable2 = Nullable.isNullable(Nullable.null) - -let map1 = Nullable.make(2)->Nullable.map(x => x + 1) -let map2 = Nullable.map(Nullable.make(2), x => x + 1) - -let forEach1 = Nullable.make(2)->Nullable.forEach(x => ignore(x)) -let forEach2 = Nullable.forEach(Nullable.make(2), x => ignore(x)) - -let fromOption1 = Some("x")->Nullable.fromOption -let fromOption2 = Nullable.fromOption(None) - -let from_opt1 = Some("y")->Nullable.fromOption -let from_opt2 = Nullable.fromOption(None) - -let toOption1 = Nullable.make(3)->Nullable.toOption -let toOption2 = Nullable.toOption(Nullable.make(3)) - -let to_opt1 = Nullable.make(4)->Nullable.toOption -let to_opt2 = Nullable.toOption(Nullable.make(4)) - -let optArrayOfNullableToOptArrayOfOpt: option>> => option< - array>, -> = x => - switch x { - | None => None - | Some(arr) => Some(arr->Belt.Array.map(Nullable.toOption)) - } - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Obj.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Obj.res.expected deleted file mode 100644 index ad86db6537f..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Obj.res.expected +++ /dev/null @@ -1,8 +0,0 @@ -let empty1 = Object.make() - -let assign1 = Object.make()->Object.assign({"a": 1}) -let assign2 = Object.assign(Object.make(), {"a": 1}) - -let keys1 = {"a": 1, "b": 2}->Object.keysToArray -let keys2 = Object.keysToArray({"a": 1, "b": 2}) - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Option.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Option.res.expected deleted file mode 100644 index 76a8b69111f..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Option.res.expected +++ /dev/null @@ -1,34 +0,0 @@ -let someCall = Js.Option.some(3) -let somePiped = 3->Js.Option.some - -let isSome1 = Some(1)->Option.isSome -let isSome2 = Option.isSome(None) - -let isNone1 = None->Option.isNone -let isNone2 = Option.isNone(Some(2)) - -let eq = (a: int, b: int) => a == b -// let isSomeValue1 = Js.Option.isSomeValue(eq, 2, Some(2)) - -let getExn1 = Option.getOrThrow(Some(3)) -let getExn2 = Some(3)->Option.getOrThrow - -let equal1 = Option.equal(Some(2), Some(2), eq) - -let f = (x: int) => x > 0 ? Some(x + 1) : None -let andThen1 = Option.flatMap(Some(2), f) - -let map1 = Option.map(Some(2), x => x * 2) - -let getWithDefault1 = Option.getOr(Some(2), 0) - -let default1 = Option.getOr(Some(2), 0) - -let filter1 = Option.filter(Some(1), x => x > 0) - -let firstSome1 = Option.orElse(Some(1), None) -let firstSome2 = Option.orElse(Some(1), None) - -// Type alias migration -let optT: option = Some(1) - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Promise.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Promise.res.expected deleted file mode 100644 index e4f878cc0fd..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Promise.res.expected +++ /dev/null @@ -1,40 +0,0 @@ -let p1 = Promise.resolve(1) -let p2 = Promise.reject(Failure("err")) - -let all1 = Promise.all([Promise.resolve(1), Promise.resolve(2)]) -let all2 = Promise.all2((Promise.resolve(1), Promise.resolve(2))) -let all3 = Promise.all3((Promise.resolve(1), Promise.resolve(2), Promise.resolve(3))) -let all4 = Promise.all4(( - Promise.resolve(1), - Promise.resolve(2), - Promise.resolve(3), - Promise.resolve(4), -)) -let all5 = Promise.all5(( - Promise.resolve(1), - Promise.resolve(2), - Promise.resolve(3), - Promise.resolve(4), - Promise.resolve(5), -)) -let all6 = Promise.all6(( - Promise.resolve(1), - Promise.resolve(2), - Promise.resolve(3), - Promise.resolve(4), - Promise.resolve(5), - Promise.resolve(6), -)) - -let race1 = Promise.race([Promise.resolve(10), Promise.resolve(20)]) - -// let thenPipe = Js.Promise.resolve(1)->Js.Promise.then_(x => Js.Promise.resolve(x + 1), _) -// let thenDirect = Js.Promise.then_(x => Js.Promise.resolve(x + 1), Js.Promise.resolve(1)) - -// Type alias migration -external p: promise = "p" - -// let catchPipe = Js.Promise.resolve(1)->Js.Promise.catch(_e => Js.Promise.resolve(0), _) -// let catchDirect = Js.Promise.catch(_e => Js.Promise.resolve(0), Js.Promise.resolve(1)) -let make1 = Promise.make((resolve, reject) => resolve(1)) - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Promise2.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Promise2.res.expected deleted file mode 100644 index c582406ff2e..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Promise2.res.expected +++ /dev/null @@ -1,43 +0,0 @@ -let p1 = Promise.resolve(1) -let _p2 = Promise.reject(Failure("err")) - -let all1 = Promise.all([Promise.resolve(1), Promise.resolve(2)]) -let all2 = Promise.all2((Promise.resolve(1), Promise.resolve(2))) -let all3 = Promise.all3((Promise.resolve(1), Promise.resolve(2), Promise.resolve(3))) - -let all4 = Promise.all4(( - Promise.resolve(1), - Promise.resolve(2), - Promise.resolve(3), - Promise.resolve(4), -)) -let all5 = Promise.all5(( - Promise.resolve(1), - Promise.resolve(2), - Promise.resolve(3), - Promise.resolve(4), - Promise.resolve(5), -)) -let all6 = Promise.all6(( - Promise.resolve(1), - Promise.resolve(2), - Promise.resolve(3), - Promise.resolve(4), - Promise.resolve(5), - Promise.resolve(6), -)) - -let race1 = Promise.race([Promise.resolve(10), Promise.resolve(20)]) - -let thenPipe = Promise.resolve(1)->Promise.then(x => Promise.resolve(x + 1)) -let thenDirect = Promise.then(Promise.resolve(1), x => Promise.resolve(x + 1)) - -// Type alias migration -external p2: promise = "p2" - -let catchPipe = Promise.resolve(1)->Promise.catch(_e => Promise.resolve(0)) -let catchDirect = Promise.catch(Promise.resolve(1), _e => Promise.resolve(0)) -let make1 = Promise.make((resolve, _) => resolve(1)) - -let _ = p2->Promise.then(x => Promise.resolve(x + 1)) - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Result.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Result.res.expected deleted file mode 100644 index 6451db2701c..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Result.res.expected +++ /dev/null @@ -1,3 +0,0 @@ -type r = result -let res: result = Ok(1) - diff --git a/tests/tools_tests/src/expected/StdlibMigration_Set.res.expected b/tests/tools_tests/src/expected/StdlibMigration_Set.res.expected deleted file mode 100644 index 3abe912e078..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_Set.res.expected +++ /dev/null @@ -1,3 +0,0 @@ -// Type alias migration for Js.Set.t -external s: Set.t = "s" - diff --git a/tests/tools_tests/src/expected/StdlibMigration_String.res.expected b/tests/tools_tests/src/expected/StdlibMigration_String.res.expected deleted file mode 100644 index b867bb3fdf3..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_String.res.expected +++ /dev/null @@ -1,130 +0,0 @@ -let make1 = 1->String.make -let make2 = String.make(1) - -let fromCharCode1 = 65->String.fromCharCode -let fromCharCode2 = String.fromCharCode(65) - -let fromCharCodeMany1 = [65, 66, 67]->String.fromCharCodeMany -let fromCharCodeMany2 = String.fromCharCodeMany([65, 66, 67]) - -let fromCodePoint1 = 65->String.fromCodePoint -let fromCodePoint2 = String.fromCodePoint(65) - -let fromCodePointMany1 = [65, 66, 67]->String.fromCodePointMany -let fromCodePointMany2 = String.fromCodePointMany([65, 66, 67]) - -let length1 = "abcde"->String.length -let length2 = String.length("abcde") - -let get1 = "abcde"->String.getUnsafe(2) -let get2 = String.getUnsafe("abcde", 2) - -let charAt1 = "abcde"->String.charAt(2) -let charAt2 = String.charAt("abcde", 2) - -let charCodeAt1 = "abcde"->String.charCodeAt(2) -let charCodeAt2 = String.charCodeAt("abcde", 2) - -let codePointAt1 = "abcde"->String.codePointAt(2) -let codePointAt2 = String.codePointAt("abcde", 2) - -let concat1 = "abcde"->String.concat("fghij") -let concat2 = String.concat("abcde", "fghij") - -let concatMany1 = "abcde"->String.concatMany(["fghij", "klmno"]) -let concatMany2 = String.concatMany("abcde", ["fghij", "klmno"]) - -let endsWith1 = "abcde"->String.endsWith("de") -let endsWith2 = String.endsWith("abcde", "de") - -let endsWithFrom1 = "abcde"->String.endsWithFrom("d", 2) -let endsWithFrom2 = String.endsWithFrom("abcde", "d", 2) - -let includes1 = "abcde"->String.includes("de") -let includes2 = String.includes("abcde", "de") - -let includesFrom1 = "abcde"->String.includesFrom("d", 2) -let includesFrom2 = String.includesFrom("abcde", "d", 2) - -let indexOf1 = "abcde"->String.indexOf("de") -let indexOf2 = String.indexOf("abcde", "de") - -let indexOfFrom1 = "abcde"->String.indexOfFrom("d", 2) -let indexOfFrom2 = String.indexOfFrom("abcde", "d", 2) - -let lastIndexOf1 = "abcde"->String.lastIndexOf("de") -let lastIndexOf2 = String.lastIndexOf("abcde", "de") - -let lastIndexOfFrom1 = "abcde"->String.lastIndexOfFrom("d", 2) -let lastIndexOfFrom2 = String.lastIndexOfFrom("abcde", "d", 2) - -let localeCompare1 = "abcde"->String.localeCompare("fghij") -let localeCompare2 = String.localeCompare("abcde", "fghij") - -let match1 = "abcde"->String.match(/d/) -let match2 = String.match("abcde", /d/) - -let normalize1 = "abcde"->String.normalize -let normalize2 = String.normalize("abcde") - -let repeat1 = "abcde"->String.repeat(2) -let repeat2 = String.repeat("abcde", 2) - -let replace1 = "abcde"->String.replace("d", "f") -let replace2 = String.replace("abcde", "d", "f") - -let replaceByRe1 = "abcde"->String.replaceRegExp(/d/, "f") -let replaceByRe2 = String.replaceRegExp("abcde", /d/, "f") - -let search1 = "abcde"->String.search(/d/) -let search2 = String.search("abcde", /d/) - -let slice1 = "abcde"->String.slice(~start=1, ~end=3) -let slice2 = String.slice("abcde", ~start=1, ~end=3) - -let sliceToEnd1 = "abcde"->String.slice(~start=1) -let sliceToEnd2 = String.slice("abcde", ~start=1) - -let split1 = "abcde"->String.split("d") -let split2 = String.split("abcde", "d") - -let splitAtMost1 = "abcde"->String.splitAtMost("d", ~limit=2) -let splitAtMost2 = String.splitAtMost("abcde", "d", ~limit=2) - -let splitByRe1 = "abcde"->String.splitByRegExp(/d/) -let splitByRe2 = String.splitByRegExp("abcde", /d/) - -let splitByReAtMost1 = "abcde"->String.splitByRegExpAtMost(/d/, ~limit=2) -let splitByReAtMost2 = String.splitByRegExpAtMost("abcde", /d/, ~limit=2) - -let startsWith1 = "abcde"->String.startsWith("ab") -let startsWith2 = String.startsWith("abcde", "ab") - -let startsWithFrom1 = "abcde"->String.startsWithFrom("b", 1) -let startsWithFrom2 = String.startsWithFrom("abcde", "b", 1) - -let substring1 = "abcde"->String.substring(~start=1, ~end=3) -let substring2 = String.substring("abcde", ~start=1, ~end=3) - -let substringToEnd1 = "abcde"->String.substringToEnd(~start=1) -let substringToEnd2 = String.substringToEnd("abcde", ~start=1) - -let toLowerCase1 = "abcde"->String.toLowerCase -let toLowerCase2 = String.toLowerCase("abcde") - -let toLocaleLowerCase1 = "abcde"->String.toLocaleLowerCase -let toLocaleLowerCase2 = String.toLocaleLowerCase("abcde") - -let toUpperCase1 = "abcde"->String.toUpperCase -let toUpperCase2 = String.toUpperCase("abcde") - -let toLocaleUpperCase1 = "abcde"->String.toLocaleUpperCase -let toLocaleUpperCase2 = String.toLocaleUpperCase("abcde") - -let trim1 = "abcde"->String.trim -let trim2 = String.trim("abcde") - -// Type alias migrations -let sT: string = "abc" -let s2T: string = "def" - diff --git a/tests/tools_tests/src/expected/StdlibMigration_TypedArray_Constructors.res.expected b/tests/tools_tests/src/expected/StdlibMigration_TypedArray_Constructors.res.expected deleted file mode 100644 index d91e6d05d6a..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_TypedArray_Constructors.res.expected +++ /dev/null @@ -1,4 +0,0 @@ -let a = Uint8Array.fromBuffer(ArrayBuffer.make(8), ~byteOffset=2) -let b = Uint8Array.fromBuffer(ArrayBuffer.make(8), ~byteOffset=2, ~length=2) -let c = Uint8Array.fromArrayLikeOrIterable([1, 2], ~map=(v, i) => v) - diff --git a/tests/tools_tests/src/expected/StdlibMigration_WeakMap.res.expected b/tests/tools_tests/src/expected/StdlibMigration_WeakMap.res.expected deleted file mode 100644 index 8dfa5ef1021..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_WeakMap.res.expected +++ /dev/null @@ -1,3 +0,0 @@ -// Type alias migration for Js.WeakMap.t -external wm: WeakMap.t<{..}, int> = "wm" - diff --git a/tests/tools_tests/src/expected/StdlibMigration_WeakSet.res.expected b/tests/tools_tests/src/expected/StdlibMigration_WeakSet.res.expected deleted file mode 100644 index aa547b1e220..00000000000 --- a/tests/tools_tests/src/expected/StdlibMigration_WeakSet.res.expected +++ /dev/null @@ -1,3 +0,0 @@ -// Type alias migration for Js.WeakSet.t -external ws: WeakSet.t<{..}> = "ws" - diff --git a/tests/tools_tests/src/migrate/StdlibMigrationNoCompile_Array.res b/tests/tools_tests/src/migrate/StdlibMigrationNoCompile_Array.res deleted file mode 100644 index 369db964f36..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigrationNoCompile_Array.res +++ /dev/null @@ -1,3 +0,0 @@ -// Migrations that will not compile after migration (by design) -let sortInPlaceWith1 = [3, 1, 2]->Js.Array2.sortInPlaceWith((a, b) => a - b) -let sortInPlaceWith2 = Js.Array2.sortInPlaceWith([3, 1, 2], (a, b) => a - b) diff --git a/tests/tools_tests/src/migrate/StdlibMigrationNoCompile_Js_Re.res b/tests/tools_tests/src/migrate/StdlibMigrationNoCompile_Js_Re.res deleted file mode 100644 index a820035008e..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigrationNoCompile_Js_Re.res +++ /dev/null @@ -1,10 +0,0 @@ -let re2 = Js.Re.fromStringWithFlags("foo", ~flags="gi") - -let capture_access = switch re2->Js.Re.exec_("Foo") { -| None => 0 -| Some(r) => - switch Js.Re.captures(r) { - | [Value(full), _] => String.length(full) - | _ => 0 - } -} diff --git a/tests/tools_tests/src/migrate/StdlibMigrationNoCompile_String.res b/tests/tools_tests/src/migrate/StdlibMigrationNoCompile_String.res deleted file mode 100644 index d377bf2d058..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigrationNoCompile_String.res +++ /dev/null @@ -1,11 +0,0 @@ -let normalizeByForm1 = "abcde"->Js.String2.normalizeByForm("a") -let normalizeByForm2 = Js.String2.normalizeByForm("abcde", "a") - -let unsafeReplaceBy01 = "abcde"->Js.String2.unsafeReplaceBy0(/d/, (_, _, _) => "f") -let unsafeReplaceBy02 = Js.String2.unsafeReplaceBy0("abcde", /d/, (_, _, _) => "f") - -let unsafeReplaceBy11 = "abcde"->Js.String2.unsafeReplaceBy1(/d/, (_, _, _, _) => "f") -let unsafeReplaceBy12 = Js.String2.unsafeReplaceBy1("abcde", /d/, (_, _, _, _) => "f") - -let unsafeReplaceBy21 = "abcde"->Js.String2.unsafeReplaceBy2(/d/, (_, _, _, _, _) => "f") -let unsafeReplaceBy22 = Js.String2.unsafeReplaceBy2("abcde", /d/, (_, _, _, _, _) => "f") diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Array.res b/tests/tools_tests/src/migrate/StdlibMigration_Array.res deleted file mode 100644 index c457b93b2e5..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Array.res +++ /dev/null @@ -1,179 +0,0 @@ -let shift1 = [1, 2, 3]->Js.Array2.shift -let shift2 = Js.Array2.shift([1, 2, 3]) - -let slice1 = [1, 2, 3]->Js.Array2.slice(~start=1, ~end_=2) -let slice2 = Js.Array2.slice([1, 2, 3], ~start=1, ~end_=2) - -external someArrayLike: Js_array2.array_like = "whatever" - -let from1 = someArrayLike->Js.Array2.from -let from2 = Js.Array2.from(someArrayLike) - -let fromMap1 = someArrayLike->Js.Array2.fromMap(s => s ++ "!") -let fromMap2 = Js.Array2.fromMap(someArrayLike, s => s ++ "!") - -let isArray1 = [1, 2, 3]->Js.Array2.isArray -let isArray2 = Js.Array2.isArray([1, 2, 3]) - -let length1 = [1, 2, 3]->Js.Array2.length -let length2 = Js.Array2.length([1, 2, 3]) - -let fillInPlace1 = [1, 2, 3]->Js.Array2.fillInPlace(0) -let fillInPlace2 = Js.Array2.fillInPlace([1, 2, 3], 0) - -let fillFromInPlace1 = [1, 2, 3, 4]->Js.Array2.fillFromInPlace(0, ~from=2) -let fillFromInPlace2 = Js.Array2.fillFromInPlace([1, 2, 3, 4], 0, ~from=2) - -let fillRangeInPlace1 = [1, 2, 3, 4]->Js.Array2.fillRangeInPlace(0, ~start=1, ~end_=3) -let fillRangeInPlace2 = Js.Array2.fillRangeInPlace([1, 2, 3, 4], 0, ~start=1, ~end_=3) - -let pop1 = [1, 2, 3]->Js.Array2.pop -let pop2 = Js.Array2.pop([1, 2, 3]) - -let reverseInPlace1 = [1, 2, 3]->Js.Array2.reverseInPlace -let reverseInPlace2 = Js.Array2.reverseInPlace([1, 2, 3]) - -let concat1 = [1, 2]->Js.Array2.concat([3, 4]) -let concat2 = Js.Array2.concat([1, 2], [3, 4]) - -let concatMany1 = [1, 2]->Js.Array2.concatMany([[3, 4], [5, 6]]) -let concatMany2 = Js.Array2.concatMany([1, 2], [[3, 4], [5, 6]]) - -let includes1 = [1, 2, 3]->Js.Array2.includes(2) -let includes2 = Js.Array2.includes([1, 2, 3], 2) - -let indexOf1 = [1, 2, 3]->Js.Array2.indexOf(2) -let indexOf2 = Js.Array2.indexOf([1, 2, 3], 2) - -let indexOfFrom1 = [1, 2, 1, 3]->Js.Array2.indexOfFrom(1, ~from=2) -let indexOfFrom2 = Js.Array2.indexOfFrom([1, 2, 1, 3], 1, ~from=2) - -let joinWith1 = [1, 2, 3]->Js.Array2.joinWith(",") -let joinWith2 = Js.Array2.joinWith([1, 2, 3], ",") - -let lastIndexOf1 = [1, 2, 1, 3]->Js.Array2.lastIndexOf(1) -let lastIndexOf2 = Js.Array2.lastIndexOf([1, 2, 1, 3], 1) - -let lastIndexOfFrom1 = [1, 2, 1, 3, 1]->Js.Array2.lastIndexOfFrom(1, ~from=3) -let lastIndexOfFrom2 = Js.Array2.lastIndexOfFrom([1, 2, 1, 3, 1], 1, ~from=3) - -let copy1 = [1, 2, 3]->Js.Array2.copy -let copy2 = Js.Array2.copy([1, 2, 3]) - -let sliceFrom1 = [1, 2, 3, 4]->Js.Array2.sliceFrom(2) -let sliceFrom2 = Js.Array2.sliceFrom([1, 2, 3, 4], 2) - -let toString1 = [1, 2, 3]->Js.Array2.toString -let toString2 = Js.Array2.toString([1, 2, 3]) - -let toLocaleString1 = [1, 2, 3]->Js.Array2.toLocaleString -let toLocaleString2 = Js.Array2.toLocaleString([1, 2, 3]) - -let every1 = [2, 4, 6]->Js.Array2.every(x => mod(x, 2) == 0) -let every2 = Js.Array2.every([2, 4, 6], x => mod(x, 2) == 0) - -let everyi1 = [0, 1, 2]->Js.Array2.everyi((x, i) => x == i) -let everyi2 = Js.Array2.everyi([0, 1, 2], (x, i) => x == i) - -let filter1 = [1, 2, 3, 4]->Js.Array2.filter(x => x > 2) -let filter2 = Js.Array2.filter([1, 2, 3, 4], x => x > 2) - -let filteri1 = [0, 1, 2, 3]->Js.Array2.filteri((_x, i) => i > 1) -let filteri2 = Js.Array2.filteri([0, 1, 2, 3], (_x, i) => i > 1) - -let find1 = [1, 2, 3, 4]->Js.Array2.find(x => x > 2) -let find2 = Js.Array2.find([1, 2, 3, 4], x => x > 2) - -let findi1 = [0, 1, 2, 3]->Js.Array2.findi((_x, i) => i > 1) -let findi2 = Js.Array2.findi([0, 1, 2, 3], (_x, i) => i > 1) - -let findIndex1 = [1, 2, 3, 4]->Js.Array2.findIndex(x => x > 2) -let findIndex2 = Js.Array2.findIndex([1, 2, 3, 4], x => x > 2) - -let findIndexi1 = [0, 1, 2, 3]->Js.Array2.findIndexi((_x, i) => i > 1) -let findIndexi2 = Js.Array2.findIndexi([0, 1, 2, 3], (_x, i) => i > 1) - -let forEach1 = [1, 2, 3]->Js.Array2.forEach(x => ignore(x)) -let forEach2 = Js.Array2.forEach([1, 2, 3], x => ignore(x)) - -let forEachi1 = [1, 2, 3]->Js.Array2.forEachi((x, i) => ignore(x + i)) -let forEachi2 = Js.Array2.forEachi([1, 2, 3], (x, i) => ignore(x + i)) - -let map1 = [1, 2, 3]->Js.Array2.map(x => x * 2) -let map2 = Js.Array2.map([1, 2, 3], x => x * 2) - -let mapi1 = [1, 2, 3]->Js.Array2.mapi((x, i) => x + i) -let mapi2 = Js.Array2.mapi([1, 2, 3], (x, i) => x + i) - -let some1 = [1, 2, 3, 4]->Js.Array2.some(x => x > 3) -let some2 = Js.Array2.some([1, 2, 3, 4], x => x > 3) - -let somei1 = [0, 1, 2, 3]->Js.Array2.somei((_x, i) => i > 2) -let somei2 = Js.Array2.somei([0, 1, 2, 3], (_x, i) => i > 2) - -let unsafeGet1 = [1, 2, 3]->Js.Array2.unsafe_get(1) -let unsafeGet2 = Js.Array2.unsafe_get([1, 2, 3], 1) - -let unsafeSet1 = [1, 2, 3]->Js.Array2.unsafe_set(1, 5) -let unsafeSet2 = Js.Array2.unsafe_set([1, 2, 3], 1, 5) - -let copyWithin1 = [1, 2, 3, 4, 5]->Js.Array2.copyWithin(~to_=2) -let copyWithin2 = Js.Array2.copyWithin([1, 2, 3, 4, 5], ~to_=2) - -let copyWithinFrom1 = [1, 2, 3, 4, 5]->Js.Array2.copyWithinFrom(~to_=0, ~from=2) -let copyWithinFrom2 = Js.Array2.copyWithinFrom([1, 2, 3, 4, 5], ~to_=0, ~from=2) - -let copyWithinFromRange1 = - [1, 2, 3, 4, 5, 6]->Js.Array2.copyWithinFromRange(~to_=1, ~start=2, ~end_=5) -let copyWithinFromRange2 = Js.Array2.copyWithinFromRange( - [1, 2, 3, 4, 5, 6], - ~to_=1, - ~start=2, - ~end_=5, -) - -let push1 = [1, 2, 3]->Js.Array2.push(4) -let push2 = Js.Array2.push([1, 2, 3], 4) - -let pushMany1 = [1, 2, 3]->Js.Array2.pushMany([4, 5]) -let pushMany2 = Js.Array2.pushMany([1, 2, 3], [4, 5]) - -let sortInPlace1 = ["c", "a", "b"]->Js.Array2.sortInPlace -let sortInPlace2 = Js.Array2.sortInPlace(["c", "a", "b"]) - -let unshift1 = [1, 2, 3]->Js.Array2.unshift(4) -let unshift2 = Js.Array2.unshift([1, 2, 3], 4) - -let unshiftMany1 = [1, 2, 3]->Js.Array2.unshiftMany([4, 5]) -let unshiftMany2 = Js.Array2.unshiftMany([1, 2, 3], [4, 5]) - -let reduce1 = [1, 2, 3]->Js.Array2.reduce((acc, x) => acc + x, 0) -let reduce2 = Js.Array2.reduce([1, 2, 3], (acc, x) => acc + x, 0) - -let spliceInPlace1 = [1, 2, 3]->Js.Array2.spliceInPlace(~pos=1, ~remove=1, ~add=[4, 5]) -let spliceInPlace2 = Js.Array2.spliceInPlace([1, 2, 3], ~pos=1, ~remove=1, ~add=[4, 5]) - -let removeFromInPlace1 = [1, 2, 3]->Js.Array2.removeFromInPlace(~pos=1) -let removeFromInPlace2 = Js.Array2.removeFromInPlace([1, 2, 3], ~pos=1) - -let removeCountInPlace1 = [1, 2, 3]->Js.Array2.removeCountInPlace(~pos=1, ~count=1) -let removeCountInPlace2 = Js.Array2.removeCountInPlace([1, 2, 3], ~pos=1, ~count=1) - -let reducei1 = [1, 2, 3]->Js.Array2.reducei((acc, x, i) => acc + x + i, 0) -let reducei2 = Js.Array2.reducei([1, 2, 3], (acc, x, i) => acc + x + i, 0) - -let reduceRight1 = [1, 2, 3]->Js.Array2.reduceRight((acc, x) => acc + x, 0) -let reduceRight2 = Js.Array2.reduceRight([1, 2, 3], (acc, x) => acc + x, 0) - -let reduceRighti1 = [1, 2, 3]->Js.Array2.reduceRighti((acc, x, i) => acc + x + i, 0) -let reduceRighti2 = Js.Array2.reduceRighti([1, 2, 3], (acc, x, i) => acc + x + i, 0) - -let pipeChain = - [1, 2, 3] - ->Js.Array2.map(x => x * 2) - ->Js.Array2.filter(x => x > 2) - ->Js.Array2.reduce((acc, x) => acc + x, 0) - -// Type alias migrations -let arrT: Js.Array.t = [1, 2, 3] -let arr2T: Js.Array2.t = [1, 2, 3] diff --git a/tests/tools_tests/src/migrate/StdlibMigration_BigInt.res b/tests/tools_tests/src/migrate/StdlibMigration_BigInt.res deleted file mode 100644 index 4503044abc1..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_BigInt.res +++ /dev/null @@ -1,48 +0,0 @@ -let fromStringExn1 = "123"->Js.BigInt.fromStringExn -let fromStringExn2 = Js.BigInt.fromStringExn("123") - -let land1 = 7n->Js.BigInt.land(4n) -let land2 = Js.BigInt.land(7n, 4n) -let land3 = 7n->Js.BigInt.toString->Js.BigInt.fromStringExn->Js.BigInt.land(4n) - -let lor1 = 7n->Js.BigInt.lor(4n) -let lor2 = Js.BigInt.lor(7n, 4n) - -let lxor1 = 7n->Js.BigInt.lxor(4n) -let lxor2 = Js.BigInt.lxor(7n, 4n) - -let lnot1 = 2n->Js.BigInt.lnot -let lnot2 = Js.BigInt.lnot(2n) - -let lsl1 = 4n->Js.BigInt.lsl(1n) -let lsl2 = Js.BigInt.lsl(4n, 1n) - -let asr1 = 8n->Js.BigInt.asr(1n) -let asr2 = Js.BigInt.asr(8n, 1n) - -let toString1 = 123n->Js.BigInt.toString -let toString2 = Js.BigInt.toString(123n) - -let toLocaleString1 = 123n->Js.BigInt.toLocaleString -let toLocaleString2 = Js.BigInt.toLocaleString(123n) - -// From the stdlib module -let stdlib_fromStringExn1 = "123"->BigInt.fromStringExn -let stdlib_fromStringExn2 = BigInt.fromStringExn("123") - -let stdlib_land1 = 7n->BigInt.land(4n) -let stdlib_land2 = BigInt.land(7n, 4n) - -let stdlib_lor1 = BigInt.lor(7n, 4n) - -let stdlib_lxor1 = 7n->BigInt.lxor(4n) -let stdlib_lxor2 = BigInt.lxor(7n, 4n) - -let stdlib_lnot1 = 2n->BigInt.lnot -let stdlib_lnot2 = BigInt.lnot(2n) - -let stdlib_lsl1 = 4n->BigInt.lsl(1n) -let stdlib_lsl2 = BigInt.lsl(4n, 1n) - -let stdlib_asr1 = 8n->BigInt.asr(1n) -let stdlib_asr2 = BigInt.asr(8n, 1n) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Console.res b/tests/tools_tests/src/migrate/StdlibMigration_Console.res deleted file mode 100644 index 0e142a0575f..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Console.res +++ /dev/null @@ -1,28 +0,0 @@ -let log = Js_console.log("Hello, World!") -let log2 = Js_console.log2("Hello", "World") -let log3 = Js_console.log3("Hello", "World", "!") -let log4 = Js_console.log4("Hello", "World", "!", "!") -let logMany = Js_console.logMany(["Hello", "World"]) - -let info = Js_console.info("Hello, World!") -let info2 = Js_console.info2("Hello", "World") -let info3 = Js_console.info3("Hello", "World", "!") -let info4 = Js_console.info4("Hello", "World", "!", "!") -let infoMany = Js_console.infoMany(["Hello", "World"]) - -let warn = Js_console.warn("Hello, World!") -let warn2 = Js_console.warn2("Hello", "World") -let warn3 = Js_console.warn3("Hello", "World", "!") -let warn4 = Js_console.warn4("Hello", "World", "!", "!") -let warnMany = Js_console.warnMany(["Hello", "World"]) - -let error = Js_console.error("Hello, World!") -let error2 = Js_console.error2("Hello", "World") -let error3 = Js_console.error3("Hello", "World", "!") -let error4 = Js_console.error4("Hello", "World", "!", "!") -let errorMany = Js_console.errorMany(["Hello", "World"]) - -let trace = Js_console.trace() -let timeStart = Js_console.timeStart("Hello, World!") -let timeEnd = Js_console.timeEnd("Hello, World!") -let table = Js_console.table(["Hello", "World"]) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Date.res b/tests/tools_tests/src/migrate/StdlibMigration_Date.res deleted file mode 100644 index 5621f35480b..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Date.res +++ /dev/null @@ -1,139 +0,0 @@ -let d1 = Js.Date.make() -let d2 = Js.Date.fromString("1973-11-29T21:30:54.321Z") -let d3 = Js.Date.fromFloat(123456789.0) - -let msNow = Js.Date.now() - -let v1 = d2->Js.Date.valueOf -let v2 = Js.Date.valueOf(d2) - -let y = d2->Js.Date.getFullYear -let mo = d2->Js.Date.getMonth -let dayOfMonth = d2->Js.Date.getDate -let dayOfWeek = d2->Js.Date.getDay -let h = d2->Js.Date.getHours -let mi = d2->Js.Date.getMinutes -let s = d2->Js.Date.getSeconds -let ms = d2->Js.Date.getMilliseconds -let tz = d2->Js.Date.getTimezoneOffset - -let uy = d2->Js.Date.getUTCFullYear -let um = d2->Js.Date.getUTCMonth -let ud = d2->Js.Date.getUTCDate -let uday = d2->Js.Date.getUTCDay -let uh = d2->Js.Date.getUTCHours -let umi = d2->Js.Date.getUTCMinutes -let us = d2->Js.Date.getUTCSeconds -let ums = d2->Js.Date.getUTCMilliseconds - -let s1 = d2->Js.Date.toISOString -let s2 = d2->Js.Date.toUTCString -let s3 = d2->Js.Date.toString -let s4 = d2->Js.Date.toTimeString -let s5 = d2->Js.Date.toDateString -let s6 = d2->Js.Date.toLocaleString -let s7 = d2->Js.Date.toLocaleDateString -let s8 = d2->Js.Date.toLocaleTimeString - -/* Additional deprecated APIs to exercise migration */ - -/* getters and legacy variants */ -let t = d2->Js.Date.getTime -let y2 = d2->Js.Date.getYear - -/* constructors with components */ -let mym = Js.Date.makeWithYM(~year=2020.0, ~month=10.0, ()) -let mymd = Js.Date.makeWithYMD(~year=1973.0, ~month=10.0, ~date=29.0, ()) -let mymdh = Js.Date.makeWithYMDH(~year=1973.0, ~month=10.0, ~date=29.0, ~hours=21.0, ()) -let mymdhm = Js.Date.makeWithYMDHM( - ~year=1973.0, - ~month=10.0, - ~date=29.0, - ~hours=21.0, - ~minutes=30.0, - (), -) -let mymdhms = Js.Date.makeWithYMDHMS( - ~year=1973.0, - ~month=10.0, - ~date=29.0, - ~hours=21.0, - ~minutes=30.0, - ~seconds=54.0, - (), -) - -/* Date.UTC variants */ -let uym = Js.Date.utcWithYM(~year=2020.0, ~month=10.0, ()) -let uymd = Js.Date.utcWithYMD(~year=1973.0, ~month=10.0, ~date=29.0, ()) -let uymdh = Js.Date.utcWithYMDH(~year=1973.0, ~month=10.0, ~date=29.0, ~hours=21.0, ()) -let uymdhm = Js.Date.utcWithYMDHM( - ~year=1973.0, - ~month=10.0, - ~date=29.0, - ~hours=21.0, - ~minutes=30.0, - (), -) -let uymdhms = Js.Date.utcWithYMDHMS( - ~year=1973.0, - ~month=10.0, - ~date=29.0, - ~hours=21.0, - ~minutes=30.0, - ~seconds=54.0, - (), -) - -/* parse APIs */ -let p = Js.Date.parse("1973-11-29T21:30:54.321Z") -let pf = Js.Date.parseAsFloat("1973-11-29T21:30:54.321Z") - -/* setters (local time) */ -let setD = d2->Js.Date.setDate(15.0) -let setFY = d2->Js.Date.setFullYear(1974.0) - -let setFYM = d2->Js.Date.setFullYearM(~year=1974.0, ~month=0.0, ()) -let setFYMD = d2->Js.Date.setFullYearMD(~year=1974.0, ~month=0.0, ~date=7.0, ()) -let setH = d2->Js.Date.setHours(22.0) -let setHM = d2->Js.Date.setHoursM(~hours=22.0, ~minutes=46.0, ()) -let setHMS = d2->Js.Date.setHoursMS(~hours=22.0, ~minutes=46.0, ~seconds=37.0, ()) -let setHMSMs = - d2->Js.Date.setHoursMSMs(~hours=22.0, ~minutes=46.0, ~seconds=37.0, ~milliseconds=494.0, ()) -let setMs = d2->Js.Date.setMilliseconds(494.0) -let setMin = d2->Js.Date.setMinutes(34.0) -let setMinS = d2->Js.Date.setMinutesS(~minutes=34.0, ~seconds=56.0, ()) -let setMinSMs = d2->Js.Date.setMinutesSMs(~minutes=34.0, ~seconds=56.0, ~milliseconds=789.0, ()) -let setMon = d2->Js.Date.setMonth(11.0) -let setMonD = d2->Js.Date.setMonthD(~month=11.0, ~date=8.0, ()) -let setSec = d2->Js.Date.setSeconds(56.0) -let setSecMs = d2->Js.Date.setSecondsMs(~seconds=56.0, ~milliseconds=789.0, ()) - -/* setters (UTC) */ -let setUD = d2->Js.Date.setUTCDate(15.0) -let setUFY = d2->Js.Date.setUTCFullYear(1974.0) -let setUFYM = d2->Js.Date.setUTCFullYearM(~year=1974.0, ~month=0.0, ()) -let setUFYMD = d2->Js.Date.setUTCFullYearMD(~year=1974.0, ~month=0.0, ~date=7.0, ()) -let setUH = d2->Js.Date.setUTCHours(22.0) -let setUHM = d2->Js.Date.setUTCHoursM(~hours=22.0, ~minutes=46.0, ()) -let setUHMS = d2->Js.Date.setUTCHoursMS(~hours=22.0, ~minutes=46.0, ~seconds=37.0, ()) -let setUHMSMs = - d2->Js.Date.setUTCHoursMSMs(~hours=22.0, ~minutes=46.0, ~seconds=37.0, ~milliseconds=494.0, ()) -let setUMs = d2->Js.Date.setUTCMilliseconds(494.0) -let setUMin = d2->Js.Date.setUTCMinutes(34.0) -let setUMinS = d2->Js.Date.setUTCMinutesS(~minutes=34.0, ~seconds=56.0, ()) -let setUMinSMs = d2->Js.Date.setUTCMinutesSMs(~minutes=34.0, ~seconds=56.0, ~milliseconds=789.0, ()) -let setUMon = d2->Js.Date.setUTCMonth(11.0) -let setUMonD = d2->Js.Date.setUTCMonthD(~month=11.0, ~date=8.0, ()) -let setUSec = d2->Js.Date.setUTCSeconds(56.0) -let setUSecMs = d2->Js.Date.setUTCSecondsMs(~seconds=56.0, ~milliseconds=789.0, ()) -let setUT = d2->Js.Date.setUTCTime(198765432101.0) -let setYr = d2->Js.Date.setYear(1999.0) - -/* other string conversions */ -let s9 = d2->Js.Date.toGMTString -let j1 = d2->Js.Date.toJSON -let j2 = d2->Js.Date.toJSONUnsafe - -// Type alias migration -external someDate: Js.Date.t = "someDate" diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Dict.res b/tests/tools_tests/src/migrate/StdlibMigration_Dict.res deleted file mode 100644 index b0f00cd7cbe..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Dict.res +++ /dev/null @@ -1,33 +0,0 @@ -let d = Js.Dict.empty() - -let get1 = d->Js.Dict.get("k") -let get2 = Js.Dict.get(d, "k") - -let unsafeGet1 = d->Js.Dict.unsafeGet("k") -let unsafeGet2 = Js.Dict.unsafeGet(d, "k") - -let set1 = d->Js.Dict.set("k", 1) -let set2 = Js.Dict.set(d, "k", 1) - -let keys1 = d->Js.Dict.keys -let keys2 = Js.Dict.keys(d) - -let values1 = d->Js.Dict.values -let values2 = Js.Dict.values(d) - -let entries1 = d->Js.Dict.entries -let entries2 = Js.Dict.entries(d) - -let dStr: Js.Dict.t = Js.Dict.empty() -let del1 = dStr->Js.Dict.unsafeDeleteKey("k") -let del2 = Js.Dict.unsafeDeleteKey(dStr, "k") - -let empty1: Js.Dict.t = Js.Dict.empty() - -let fromArray1 = [("a", 1), ("b", 2)]->Js.Dict.fromArray -let fromArray2 = Js.Dict.fromArray([("a", 1), ("b", 2)]) - -let fromList1 = list{("a", 1), ("b", 2)}->Js.Dict.fromList -let fromList2 = Js.Dict.fromList(list{("a", 1), ("b", 2)}) - -let map2 = Js.Dict.map(x => x + 1, d) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Extern.res b/tests/tools_tests/src/migrate/StdlibMigration_Extern.res deleted file mode 100644 index 3ff65d4bba3..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Extern.res +++ /dev/null @@ -1,6 +0,0 @@ -// Exercise migrations from Js_extern to new Stdlib APIs - -let isNullish = Js_extern.testAny(%raw("null")) -let n = Js_extern.null -let u = Js_extern.undefined -let ty = Js_extern.typeof("hello") diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Float.res b/tests/tools_tests/src/migrate/StdlibMigration_Float.res deleted file mode 100644 index e87cfb0e5c3..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Float.res +++ /dev/null @@ -1,34 +0,0 @@ -let nan1 = Js.Float._NaN - -let isNaN1 = Js.Float._NaN->Js.Float.isNaN -let isNaN2 = Js.Float.isNaN(Js.Float._NaN) - -let isFinite1 = 1234.0->Js.Float.isFinite -let isFinite2 = Js.Float.isFinite(1234.0) - -let toExponential1 = 77.1234->Js.Float.toExponential -let toExponential2 = Js.Float.toExponential(77.1234) - -let toExponentialWithPrecision1 = 77.1234->Js.Float.toExponentialWithPrecision(~digits=2) -let toExponentialWithPrecision2 = Js.Float.toExponentialWithPrecision(77.1234, ~digits=2) - -let toFixed1 = 12345.6789->Js.Float.toFixed -let toFixed2 = Js.Float.toFixed(12345.6789) - -let toFixedWithPrecision1 = 12345.6789->Js.Float.toFixedWithPrecision(~digits=1) -let toFixedWithPrecision2 = Js.Float.toFixedWithPrecision(12345.6789, ~digits=1) - -let toPrecision1 = 12345.6789->Js.Float.toPrecision -let toPrecision2 = Js.Float.toPrecision(12345.6789) - -let toPrecisionWithPrecision1 = 12345.6789->Js.Float.toPrecisionWithPrecision(~digits=2) -let toPrecisionWithPrecision2 = Js.Float.toPrecisionWithPrecision(12345.6789, ~digits=2) - -let toString1 = 12345.6789->Js.Float.toString -let toString2 = Js.Float.toString(12345.6789) - -let toStringWithRadix1 = 6.0->Js.Float.toStringWithRadix(~radix=2) -let toStringWithRadix2 = Js.Float.toStringWithRadix(6.0, ~radix=2) - -let parse1 = "123"->Js.Float.fromString -let parse2 = Js.Float.fromString("123") diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Global.res b/tests/tools_tests/src/migrate/StdlibMigration_Global.res deleted file mode 100644 index e15828838b2..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Global.res +++ /dev/null @@ -1,15 +0,0 @@ -let t1: Js.Global.timeoutId = Js.Global.setTimeout(() => (), 1000) -let t2: Js.Global.timeoutId = Js.Global.setTimeoutFloat(() => (), 1000.0) - -Js.Global.clearTimeout(t1) - -let i1: Js.Global.intervalId = Js.Global.setInterval(() => (), 2000) -let i2: Js.Global.intervalId = Js.Global.setIntervalFloat(() => (), 2000.0) - -Js.Global.clearInterval(i1) - -let e1 = Js.Global.encodeURI("https://rescript-lang.org?array=[someValue]") -let d1 = Js.Global.decodeURI("https://rescript-lang.org?array=%5BsomeValue%5D") - -let e2 = Js.Global.encodeURIComponent("array=[someValue]") -let d2 = Js.Global.decodeURIComponent("array%3D%5BsomeValue%5D") diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Interface.res b/tests/tools_tests/src/migrate/StdlibMigration_Interface.res deleted file mode 100644 index acb6e7ed5c3..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Interface.res +++ /dev/null @@ -1,8 +0,0 @@ -/* Implementation to satisfy interface build for tests */ - -external arr: Js.Array.t = "arr" -external reT: Js.Re.t = "re" -external json: Js.Json.t = "json" -external nestedArr: Js.Array.t = "nestedArr" - -external useSet: Js.Set.t => unit = "useSet" diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Interface.resi b/tests/tools_tests/src/migrate/StdlibMigration_Interface.resi deleted file mode 100644 index f9c987eea55..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Interface.resi +++ /dev/null @@ -1,10 +0,0 @@ -/* Migration tests for interface (.resi) files using stdlib deprecations */ - -// Type alias migrations exercised via externals -external arr: Js.Array.t = "arr" -external reT: Js.Re.t = "re" -external json: Js.Json.t = "json" -external nestedArr: Js.Array.t = "nestedArr" - -// Function type using a deprecated alias -external useSet: Js.Set.t => unit = "useSet" diff --git a/tests/tools_tests/src/migrate/StdlibMigration_JSON.res b/tests/tools_tests/src/migrate/StdlibMigration_JSON.res deleted file mode 100644 index ae75c80b96a..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_JSON.res +++ /dev/null @@ -1,26 +0,0 @@ -external someJson: Js_json.t = "someJson" -external strToJson: string => Js_json.t = "strToJson" - -let decodeString1 = someJson->Js_json.decodeString -let decodeString2 = Js_json.decodeString(someJson) -let decodeString3 = - [1, 2, 3] - ->Array.map(v => v->Int.toString) - ->Array.join(" ") - ->strToJson - ->Js_json.decodeString - -let decodeNumber1 = someJson->Js_json.decodeNumber -let decodeNumber2 = Js_json.decodeNumber(someJson) - -let decodeObject1 = someJson->Js_json.decodeObject -let decodeObject2 = Js_json.decodeObject(someJson) - -let decodeArray1 = someJson->Js_json.decodeArray -let decodeArray2 = Js_json.decodeArray(someJson) - -let decodeBoolean1 = someJson->Js_json.decodeBoolean -let decodeBoolean2 = Js_json.decodeBoolean(someJson) - -let decodeNull1 = someJson->Js_json.decodeNull -let decodeNull2 = Js_json.decodeNull(someJson) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Js.res b/tests/tools_tests/src/migrate/StdlibMigration_Js.res deleted file mode 100644 index 39deedf002f..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Js.res +++ /dev/null @@ -1,5 +0,0 @@ -let consoleLog1 = Js.log("Hello") -let consoleLog2 = Js.log2("Hello", "World") -let consoleLog3 = Js.log3("Hello", "World", "!") -let consoleLog4 = Js.log4("Hello", "World", "!", "!") -let consoleLogMany = Js.logMany(["Hello", "World"]) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Js_Array.res b/tests/tools_tests/src/migrate/StdlibMigration_Js_Array.res deleted file mode 100644 index 76dbf95b976..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Js_Array.res +++ /dev/null @@ -1,33 +0,0 @@ -// Migration tests for Js.Array (old) -> Array module - -external someArrayLike: Js_array.array_like = "whatever" - -let from1 = someArrayLike->Js.Array.from -let from2 = Js.Array.from(someArrayLike) - -let fromMap1 = someArrayLike->Js.Array.fromMap(s => s ++ "!") -let fromMap2 = Js.Array.fromMap(someArrayLike, s => s ++ "!") - -let isArray1 = [1, 2, 3]->Js.Array.isArray -let isArray2 = Js.Array.isArray([1, 2, 3]) - -let length1 = [1, 2, 3]->Js.Array.length -let length2 = Js.Array.length([1, 2, 3]) - -let pop1 = [1, 2, 3]->Js.Array.pop -let pop2 = Js.Array.pop([1, 2, 3]) - -let reverseInPlace1 = [1, 2, 3]->Js.Array.reverseInPlace -let reverseInPlace2 = Js.Array.reverseInPlace([1, 2, 3]) - -let shift1 = [1, 2, 3]->Js.Array.shift -let shift2 = Js.Array.shift([1, 2, 3]) - -let toString1 = [1, 2, 3]->Js.Array.toString -let toString2 = Js.Array.toString([1, 2, 3]) - -let toLocaleString1 = [1, 2, 3]->Js.Array.toLocaleString -let toLocaleString2 = Js.Array.toLocaleString([1, 2, 3]) - -// Type alias migration -let arrT: Js.Array.t = [1, 2, 3] diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Js_Int.res b/tests/tools_tests/src/migrate/StdlibMigration_Js_Int.res deleted file mode 100644 index b120c23691d..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Js_Int.res +++ /dev/null @@ -1,23 +0,0 @@ -let toExponential1 = 77->Js.Int.toExponential -let toExponential2 = Js.Int.toExponential(77) - -let toExponentialWithPrecision1 = 77->Js.Int.toExponentialWithPrecision(~digits=2) -let toExponentialWithPrecision2 = Js.Int.toExponentialWithPrecision(77, ~digits=2) - -let toPrecision1 = 123456789->Js.Int.toPrecision -let toPrecision2 = Js.Int.toPrecision(123456789) - -let toPrecisionWithPrecision1 = 123456789->Js.Int.toPrecisionWithPrecision(~digits=2) -let toPrecisionWithPrecision2 = Js.Int.toPrecisionWithPrecision(123456789, ~digits=2) - -let toString1 = 123456789->Js.Int.toString -let toString2 = Js.Int.toString(123456789) - -let toStringWithRadix1 = 373592855->Js.Int.toStringWithRadix(~radix=16) -let toStringWithRadix2 = Js.Int.toStringWithRadix(373592855, ~radix=16) - -let toFloat1 = 42->Js.Int.toFloat -let toFloat2 = Js.Int.toFloat(42) - -let equal1 = Js.Int.equal(1, 1) -let equal2 = 1->Js.Int.equal(2) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Js_More.res b/tests/tools_tests/src/migrate/StdlibMigration_Js_More.res deleted file mode 100644 index f589739aa59..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Js_More.res +++ /dev/null @@ -1,7 +0,0 @@ -// Migration tests for new deprecations in packages/@rescript/runtime/Js.res - -// typeof migration -let tyNum = Js.typeof(1) - -// nullToOption -let nToOpt = Js.nullToOption(Js.Null.return(1)) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Js_Re.res b/tests/tools_tests/src/migrate/StdlibMigration_Js_Re.res deleted file mode 100644 index 818abba9942..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Js_Re.res +++ /dev/null @@ -1,50 +0,0 @@ -let re1 = Js.Re.fromString("foo") -let re2 = Js.Re.fromStringWithFlags("foo", ~flags="gi") - -let flags1 = re2->Js.Re.flags -let flags2 = Js.Re.flags(re2) - -let g1 = re2->Js.Re.global -let g2 = Js.Re.global(re2) - -let ic1 = re2->Js.Re.ignoreCase -let ic2 = Js.Re.ignoreCase(re2) - -let m1 = re2->Js.Re.multiline -let m2 = Js.Re.multiline(re2) - -let u1 = re2->Js.Re.unicode -let u2 = Js.Re.unicode(re2) - -let y1 = re2->Js.Re.sticky -let y2 = Js.Re.sticky(re2) - -let src1 = re2->Js.Re.source -let src2 = Js.Re.source(re2) - -let li1 = re2->Js.Re.lastIndex -let () = re2->Js.Re.setLastIndex(0) - -let exec1 = re2->Js.Re.exec_("Foo bar") -let exec2 = Js.Re.exec_(re2, "Foo bar") - -let test1 = re2->Js.Re.test_("Foo bar") -let test2 = Js.Re.test_(re2, "Foo bar") - -// Type alias migration -external reT: Js.Re.t = "re" - -let matches_access = switch re2->Js.Re.exec_("Foo bar") { -| None => 0 -| Some(r) => Js.Re.matches(r)->Array.length -} - -let result_index = switch re2->Js.Re.exec_("Foo bar") { -| None => 0 -| Some(r) => Js.Re.index(r) -} - -let result_input = switch re2->Js.Re.exec_("Foo bar") { -| None => "" -| Some(r) => Js.Re.input(r) -} diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Js_String.res b/tests/tools_tests/src/migrate/StdlibMigration_Js_String.res deleted file mode 100644 index 67f8145323b..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Js_String.res +++ /dev/null @@ -1,43 +0,0 @@ -// Migration tests for Js.String (old) -> String module - -let make1 = 1->Js.String.make -let make2 = Js.String.make(1) - -let fromCharCode1 = 65->Js.String.fromCharCode -let fromCharCode2 = Js.String.fromCharCode(65) - -let fromCharCodeMany1 = [65, 66, 67]->Js.String.fromCharCodeMany -let fromCharCodeMany2 = Js.String.fromCharCodeMany([65, 66, 67]) - -let fromCodePoint1 = 65->Js.String.fromCodePoint -let fromCodePoint2 = Js.String.fromCodePoint(65) - -let fromCodePointMany1 = [65, 66, 67]->Js.String.fromCodePointMany -let fromCodePointMany2 = Js.String.fromCodePointMany([65, 66, 67]) - -let length1 = "abcde"->Js.String.length -let length2 = Js.String.length("abcde") - -let get1 = "abcde"->Js.String.get(2) -let get2 = Js.String.get("abcde", 2) - -let normalize1 = "abcde"->Js.String.normalize -let normalize2 = Js.String.normalize("abcde") - -let toLowerCase1 = "ABCDE"->Js.String.toLowerCase -let toLowerCase2 = Js.String.toLowerCase("ABCDE") - -let toUpperCase1 = "abcde"->Js.String.toUpperCase -let toUpperCase2 = Js.String.toUpperCase("abcde") - -let toLocaleLowerCase1 = "ABCDE"->Js.String.toLocaleLowerCase -let toLocaleLowerCase2 = Js.String.toLocaleLowerCase("ABCDE") - -let toLocaleUpperCase1 = "abcde"->Js.String.toLocaleUpperCase -let toLocaleUpperCase2 = Js.String.toLocaleUpperCase("abcde") - -let trim1 = " abcde "->Js.String.trim -let trim2 = Js.String.trim(" abcde ") - -// Type alias migration -let sT: Js.String.t = "abc" diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Js_Types_Interface.res b/tests/tools_tests/src/migrate/StdlibMigration_Js_Types_Interface.res deleted file mode 100644 index 01bd0b8f489..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Js_Types_Interface.res +++ /dev/null @@ -1,9 +0,0 @@ -/* Implementation to satisfy interface build for tests */ - -external nullT: Js.null = "nullT" -external nullableT: Js.nullable = "nullableT" -external nullUndefT: Js.null_undefined = "nullUndefT" - -external symbolT: Js.Types.symbol = "symbolT" -external objValT: Js.Types.obj_val = "objValT" -external functionValT: Js.Types.function_val = "functionValT" diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Js_Types_Interface.resi b/tests/tools_tests/src/migrate/StdlibMigration_Js_Types_Interface.resi deleted file mode 100644 index 541b2560252..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Js_Types_Interface.resi +++ /dev/null @@ -1,11 +0,0 @@ -/* Migration tests for Js.res type deprecations */ - -// Type alias migrations exercised via externals -external nullT: Js.null = "nullT" -external nullableT: Js.nullable = "nullableT" -external nullUndefT: Js.null_undefined = "nullUndefT" - -// Js.Types migrations -external symbolT: Js.Types.symbol = "symbolT" -external objValT: Js.Types.obj_val = "objValT" -external functionValT: Js.Types.function_val = "functionValT" diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Js_Undefined.res b/tests/tools_tests/src/migrate/StdlibMigration_Js_Undefined.res deleted file mode 100644 index 66cc08ae7cc..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Js_Undefined.res +++ /dev/null @@ -1,35 +0,0 @@ -let make1 = "hello"->Js.Undefined.return -let make2 = Js.Undefined.return("hello") - -let empty1 = Js.Undefined.empty - -let getUnsafe1 = Js.Undefined.return(1)->Js.Undefined.getUnsafe -let getUnsafe2 = Js.Undefined.getUnsafe(Js.Undefined.return(1)) - -let getExn1 = Js.Undefined.return(1)->Js.Undefined.getExn -let getExn2 = Js.Undefined.getExn(Js.Undefined.return(1)) - -let map1 = Js.Undefined.return(2)->Js.Undefined.bind(x => x + 1) -let map2 = Js.Undefined.bind(Js.Undefined.return(2), x => x + 1) - -let forEach1 = Js.Undefined.return(2)->Js.Undefined.iter(x => ignore(x)) -let forEach2 = Js.Undefined.iter(Js.Undefined.return(2), x => ignore(x)) - -let fromOption1 = Some("x")->Js.Undefined.fromOption -let fromOption2 = Js.Undefined.fromOption(None) - -let from_opt1 = Some("y")->Js.Undefined.from_opt -let from_opt2 = Js.Undefined.from_opt(None) - -let toOption1 = Js.Undefined.return(3)->Js.Undefined.toOption -let toOption2 = Js.Undefined.toOption(Js.Undefined.return(3)) - -let to_opt1 = Js.Undefined.return(4)->Js.Undefined.to_opt -let to_opt2 = Js.Undefined.to_opt(Js.Undefined.return(4)) - -let test1 = Js.Undefined.empty->Js.Undefined.test -let test2 = Js.Undefined.test(Js.Undefined.empty) -let test3 = Js.Undefined.return(5)->Js.Undefined.bind(v => v)->Js.Undefined.test - -let testAny1 = Js.Undefined.testAny(Js.Undefined.empty) -let testAny2 = Js.Undefined.empty->Js.Undefined.testAny diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Js_typed_array.res b/tests/tools_tests/src/migrate/StdlibMigration_Js_typed_array.res deleted file mode 100644 index fbc29713c2d..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Js_typed_array.res +++ /dev/null @@ -1,7 +0,0 @@ -let arr1 = Js.Typed_array.Int8Array.make([1, 2, 3]) - -let len = arr1->Js.Typed_array.Int8Array.length - -let bytes = Js.Typed_array.Int8Array._BYTES_PER_ELEMENT -let off = Js.Typed_array.Int8Array.fromBufferOffset(ArrayBuffer.make(8), 2) -let range = Js.Typed_array.Int8Array.fromBufferRange(ArrayBuffer.make(8), ~offset=2, ~length=2) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Js_typed_array2.res b/tests/tools_tests/src/migrate/StdlibMigration_Js_typed_array2.res deleted file mode 100644 index 636d79123a1..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Js_typed_array2.res +++ /dev/null @@ -1,22 +0,0 @@ -let arr = Js.TypedArray2.Int8Array.make([1, 2, 3]) - -let len1 = arr->Js.TypedArray2.Int8Array.length -let includes1 = arr->Js.TypedArray2.Int8Array.includes(2) -let idxFrom1 = arr->Js.TypedArray2.Int8Array.indexOfFrom(2, ~from=1) - -let slice1 = arr->Js.TypedArray2.Int8Array.slice(~start=1, ~end_=2) -let sliceFrom1 = arr->Js.TypedArray2.Int8Array.sliceFrom(1) - -let map1 = arr->Js.TypedArray2.Int8Array.map(x => x + 1) -let reduce1 = arr->Js.TypedArray2.Int8Array.reduce((acc, x) => acc + x, 0) - -let bytes = Js.TypedArray2.Int8Array._BYTES_PER_ELEMENT - -let fromBufToEnd = Js.TypedArray2.Int8Array.fromBufferOffset(ArrayBuffer.make(8), 2) -let fromBufRange = Js.TypedArray2.Int8Array.fromBufferRange( - ArrayBuffer.make(8), - ~offset=2, - ~length=2, -) - -let fromLength = Js.TypedArray2.Int8Array.fromLength(3) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Js_typed_array2_Float32.res b/tests/tools_tests/src/migrate/StdlibMigration_Js_typed_array2_Float32.res deleted file mode 100644 index f7b4d6fa5d2..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Js_typed_array2_Float32.res +++ /dev/null @@ -1,22 +0,0 @@ -let arr = Js.TypedArray2.Float32Array.make([1.0, 2.0, 3.0]) - -let len1 = arr->Js.TypedArray2.Float32Array.length -let includes1 = arr->Js.TypedArray2.Float32Array.includes(2.0) -let idxFrom1 = arr->Js.TypedArray2.Float32Array.indexOfFrom(2.0, ~from=1) - -let slice1 = arr->Js.TypedArray2.Float32Array.slice(~start=1, ~end_=2) -let sliceFrom1 = arr->Js.TypedArray2.Float32Array.sliceFrom(1) - -let map1 = arr->Js.TypedArray2.Float32Array.map(x => x +. 1.0) -let reduce1 = arr->Js.TypedArray2.Float32Array.reduce((acc, x) => acc +. x, 0.0) - -let bytes = Js.TypedArray2.Float32Array._BYTES_PER_ELEMENT - -let fromBufToEnd = Js.TypedArray2.Float32Array.fromBufferOffset(ArrayBuffer.make(8), 2) -let fromBufRange = Js.TypedArray2.Float32Array.fromBufferRange( - ArrayBuffer.make(8), - ~offset=2, - ~length=2, -) - -let fromLength = Js.TypedArray2.Float32Array.fromLength(3) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Js_typed_array_Float32_Const.res b/tests/tools_tests/src/migrate/StdlibMigration_Js_typed_array_Float32_Const.res deleted file mode 100644 index f541cfdeafe..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Js_typed_array_Float32_Const.res +++ /dev/null @@ -1,2 +0,0 @@ -// Float32 constants migration coverage for legacy Js.Typed_array -let bytesF32 = Js.Typed_array.Float32Array._BYTES_PER_ELEMENT diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Map.res b/tests/tools_tests/src/migrate/StdlibMigration_Map.res deleted file mode 100644 index 942aea02466..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Map.res +++ /dev/null @@ -1,2 +0,0 @@ -// Type alias migration for Js.Map.t -external m: Js.Map.t = "m" diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Math.res b/tests/tools_tests/src/migrate/StdlibMigration_Math.res deleted file mode 100644 index 4d9e9427bc8..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Math.res +++ /dev/null @@ -1,81 +0,0 @@ -// Exercise migrations from Js.Math to Math - -let e = Js.Math._E -let pi = Js.Math._PI -let ln2 = Js.Math._LN2 -let ln10 = Js.Math._LN10 -let log2e = Js.Math._LOG2E -let log10e = Js.Math._LOG10E -let sqrt_half = Js.Math._SQRT1_2 -let sqrt2c = Js.Math._SQRT2 - -let absInt1 = Js.Math.abs_int(-5) -let absFloat1 = Js.Math.abs_float(-3.5) - -let acos1 = Js.Math.acos(1.0) -let acosh1 = Js.Math.acosh(1.5) -let asinh1 = Js.Math.asinh(1.0) -let asin1 = Js.Math.asin(0.5) -let atan1 = Js.Math.atan(1.0) -let atanh1 = Js.Math.atanh(0.5) - -let atan21 = Js.Math.atan2(~y=0.0, ~x=10.0, ()) - -let cbrt1 = Js.Math.cbrt(27.0) - -let ceilInt1 = Js.Math.unsafe_ceil_int(3.2) -let ceilInt2 = Js.Math.unsafe_ceil_int(3.2) -let ceilFloat1 = Js.Math.ceil_float(3.2) - -let clz1 = Js.Math.clz32(255) - -let cos1 = Js.Math.cos(0.0) -let cosh1 = Js.Math.cosh(0.0) -let exp1 = Js.Math.exp(1.0) -let expm11 = Js.Math.expm1(1.0) -let log1p1 = Js.Math.log1p(1.0) - -let floorInt1 = Js.Math.unsafe_floor_int(3.7) -let floorInt2 = Js.Math.unsafe_floor_int(3.7) -let floorFloat1 = Js.Math.floor_float(3.7) - -let fround1 = Js.Math.fround(5.05) - -let hypot1 = Js.Math.hypot(3.0, 4.0) -let hypotMany1 = Js.Math.hypotMany([3.0, 4.0, 12.0]) - -let imul1 = Js.Math.imul(3, 4) - -let log1 = Js.Math.log(Js.Math._E) -let log10_1 = Js.Math.log10(1000.0) -let log2_1 = Js.Math.log2(512.0) - -let maxInt1 = Js.Math.max_int(1, 2) -let maxIntMany1 = Js.Math.maxMany_int([1, 10, 3]) -let maxFloat1 = Js.Math.max_float(1.5, 2.5) -let maxFloatMany1 = Js.Math.maxMany_float([1.5, 2.5, 0.5]) - -let minInt1 = Js.Math.min_int(1, 2) -let minIntMany1 = Js.Math.minMany_int([1, 10, 3]) -let minFloat1 = Js.Math.min_float(1.5, 2.5) -let minFloatMany1 = Js.Math.minMany_float([1.5, 2.5, 0.5]) - -let powInt1 = Js.Math.pow_int(~base=3, ~exp=4) -let powFloat1 = Js.Math.pow_float(~base=3.0, ~exp=4.0) - -let rand1 = Js.Math.random() - -let roundUnsafe1 = Js.Math.unsafe_round(3.7) -let round1 = Js.Math.round(3.7) - -let signInt1 = Js.Math.sign_int(-5) -let signFloat1 = Js.Math.sign_float(-5.0) - -let sin1 = Js.Math.sin(0.0) -let sinh1 = Js.Math.sinh(0.0) -let sqrt1 = Js.Math.sqrt(9.0) -let tan1 = Js.Math.tan(0.5) -let tanh1 = Js.Math.tanh(0.0) - -let truncUnsafe1 = Js.Math.unsafe_trunc(3.7) -let trunc1 = Js.Math.trunc(3.7) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Null.res b/tests/tools_tests/src/migrate/StdlibMigration_Null.res deleted file mode 100644 index f88c148f5cf..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Null.res +++ /dev/null @@ -1,35 +0,0 @@ -let make1 = "hello"->Js.Null.return -let make2 = Js.Null.return("hello") - -let empty1 = Js.Null.empty - -let getUnsafe1 = Js.Null.return(1)->Js.Null.getUnsafe -let getUnsafe2 = Js.Null.getUnsafe(Js.Null.return(1)) - -let getExn1 = Js.Null.return(1)->Js.Null.getExn -let getExn2 = Js.Null.getExn(Js.Null.return(1)) - -let map1 = Js.Null.return(2)->Js.Null.bind(x => x + 1) -let map2 = Js.Null.bind(Js.Null.return(2), x => x + 1) - -let forEach1 = Js.Null.return(2)->Js.Null.iter(x => ignore(x)) -let forEach2 = Js.Null.iter(Js.Null.return(2), x => ignore(x)) - -let fromOption1 = Some("x")->Js.Null.fromOption -let fromOption2 = Js.Null.fromOption(None) - -let from_opt1 = Some("y")->Js.Null.from_opt -let from_opt2 = Js.Null.from_opt(None) - -let toOption1 = Js.Null.return(3)->Js.Null.toOption -let toOption2 = Js.Null.toOption(Js.Null.return(3)) - -let to_opt1 = Js.Null.return(4)->Js.Null.to_opt -let to_opt2 = Js.Null.to_opt(Js.Null.return(4)) - -let test1 = Js.Null.empty->Js.Null.test -let test2 = Js.Null.test(Js.Null.empty) -let test3 = Js.Null.return(5)->Js.Null.bind(v => v)->Js.Null.test - -// Type alias migration -let nullT: Js.Null.t = Js.Null.return(1) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Nullable.res b/tests/tools_tests/src/migrate/StdlibMigration_Nullable.res deleted file mode 100644 index e709b1b41da..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Nullable.res +++ /dev/null @@ -1,34 +0,0 @@ -let make1 = "hello"->Js.Null_undefined.return -let make2 = Js.Null_undefined.return("hello") - -let null1 = Js.Null_undefined.null -let undefined1 = Js.Null_undefined.undefined - -let isNullable1 = Js.Null_undefined.null->Js.Null_undefined.isNullable -let isNullable2 = Js.Null_undefined.isNullable(Js.Null_undefined.null) - -let map1 = Js.Null_undefined.return(2)->Js.Null_undefined.bind(x => x + 1) -let map2 = Js.Null_undefined.bind(Js.Null_undefined.return(2), x => x + 1) - -let forEach1 = Js.Null_undefined.return(2)->Js.Null_undefined.iter(x => ignore(x)) -let forEach2 = Js.Null_undefined.iter(Js.Null_undefined.return(2), x => ignore(x)) - -let fromOption1 = Some("x")->Js.Null_undefined.fromOption -let fromOption2 = Js.Null_undefined.fromOption(None) - -let from_opt1 = Some("y")->Js.Null_undefined.from_opt -let from_opt2 = Js.Null_undefined.from_opt(None) - -let toOption1 = Js.Null_undefined.return(3)->Js.Null_undefined.toOption -let toOption2 = Js.Null_undefined.toOption(Js.Null_undefined.return(3)) - -let to_opt1 = Js.Null_undefined.return(4)->Js.Null_undefined.to_opt -let to_opt2 = Js.Null_undefined.to_opt(Js.Null_undefined.return(4)) - -let optArrayOfNullableToOptArrayOfOpt: option>> => option< - array>, -> = x => - switch x { - | None => None - | Some(arr) => Some(arr->Belt.Array.map(Js.Nullable.toOption)) - } diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Obj.res b/tests/tools_tests/src/migrate/StdlibMigration_Obj.res deleted file mode 100644 index b7ecb2e6cba..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Obj.res +++ /dev/null @@ -1,7 +0,0 @@ -let empty1 = Js.Obj.empty() - -let assign1 = Js.Obj.empty()->Js.Obj.assign({"a": 1}) -let assign2 = Js.Obj.assign(Js.Obj.empty(), {"a": 1}) - -let keys1 = {"a": 1, "b": 2}->Js.Obj.keys -let keys2 = Js.Obj.keys({"a": 1, "b": 2}) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Option.res b/tests/tools_tests/src/migrate/StdlibMigration_Option.res deleted file mode 100644 index b781219ed3b..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Option.res +++ /dev/null @@ -1,33 +0,0 @@ -let someCall = Js.Option.some(3) -let somePiped = 3->Js.Option.some - -let isSome1 = Some(1)->Js.Option.isSome -let isSome2 = Js.Option.isSome(None) - -let isNone1 = None->Js.Option.isNone -let isNone2 = Js.Option.isNone(Some(2)) - -let eq = (a: int, b: int) => a == b -// let isSomeValue1 = Js.Option.isSomeValue(eq, 2, Some(2)) - -let getExn1 = Js.Option.getExn(Some(3)) -let getExn2 = Some(3)->Js.Option.getExn - -let equal1 = Js.Option.equal(eq, Some(2), Some(2)) - -let f = (x: int) => x > 0 ? Some(x + 1) : None -let andThen1 = Js.Option.andThen(f, Some(2)) - -let map1 = Js.Option.map(x => x * 2, Some(2)) - -let getWithDefault1 = Js.Option.getWithDefault(0, Some(2)) - -let default1 = Js.Option.default(0, Some(2)) - -let filter1 = Js.Option.filter(x => x > 0, Some(1)) - -let firstSome1 = Js.Option.firstSome(Some(1), None) -let firstSome2 = Some(1)->Js.Option.firstSome(None) - -// Type alias migration -let optT: Js.Option.t = Some(1) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Promise.res b/tests/tools_tests/src/migrate/StdlibMigration_Promise.res deleted file mode 100644 index 29f244c0022..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Promise.res +++ /dev/null @@ -1,39 +0,0 @@ -let p1 = Js.Promise.resolve(1) -let p2 = Js.Promise.reject(Failure("err")) - -let all1 = Js.Promise.all([Js.Promise.resolve(1), Js.Promise.resolve(2)]) -let all2 = Js.Promise.all2((Js.Promise.resolve(1), Js.Promise.resolve(2))) -let all3 = Js.Promise.all3((Js.Promise.resolve(1), Js.Promise.resolve(2), Js.Promise.resolve(3))) -let all4 = Js.Promise.all4(( - Js.Promise.resolve(1), - Js.Promise.resolve(2), - Js.Promise.resolve(3), - Js.Promise.resolve(4), -)) -let all5 = Js.Promise.all5(( - Js.Promise.resolve(1), - Js.Promise.resolve(2), - Js.Promise.resolve(3), - Js.Promise.resolve(4), - Js.Promise.resolve(5), -)) -let all6 = Js.Promise.all6(( - Js.Promise.resolve(1), - Js.Promise.resolve(2), - Js.Promise.resolve(3), - Js.Promise.resolve(4), - Js.Promise.resolve(5), - Js.Promise.resolve(6), -)) - -let race1 = Js.Promise.race([Js.Promise.resolve(10), Js.Promise.resolve(20)]) - -// let thenPipe = Js.Promise.resolve(1)->Js.Promise.then_(x => Js.Promise.resolve(x + 1), _) -// let thenDirect = Js.Promise.then_(x => Js.Promise.resolve(x + 1), Js.Promise.resolve(1)) - -// Type alias migration -external p: Js.Promise.t = "p" - -// let catchPipe = Js.Promise.resolve(1)->Js.Promise.catch(_e => Js.Promise.resolve(0), _) -// let catchDirect = Js.Promise.catch(_e => Js.Promise.resolve(0), Js.Promise.resolve(1)) -let make1 = Js.Promise.make((~resolve, ~reject) => resolve(1)) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Promise2.res b/tests/tools_tests/src/migrate/StdlibMigration_Promise2.res deleted file mode 100644 index bb47a1e5958..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Promise2.res +++ /dev/null @@ -1,46 +0,0 @@ -let p1 = Js.Promise2.resolve(1) -let _p2 = Js.Promise2.reject(Failure("err")) - -let all1 = Js.Promise2.all([Js.Promise2.resolve(1), Js.Promise2.resolve(2)]) -let all2 = Js.Promise2.all2((Js.Promise2.resolve(1), Js.Promise2.resolve(2))) -let all3 = Js.Promise2.all3(( - Js.Promise2.resolve(1), - Js.Promise2.resolve(2), - Js.Promise2.resolve(3), -)) - -let all4 = Js.Promise2.all4(( - Js.Promise2.resolve(1), - Js.Promise2.resolve(2), - Js.Promise2.resolve(3), - Js.Promise2.resolve(4), -)) -let all5 = Js.Promise2.all5(( - Js.Promise2.resolve(1), - Js.Promise2.resolve(2), - Js.Promise2.resolve(3), - Js.Promise2.resolve(4), - Js.Promise2.resolve(5), -)) -let all6 = Js.Promise2.all6(( - Js.Promise2.resolve(1), - Js.Promise2.resolve(2), - Js.Promise2.resolve(3), - Js.Promise2.resolve(4), - Js.Promise2.resolve(5), - Js.Promise2.resolve(6), -)) - -let race1 = Js.Promise2.race([Js.Promise2.resolve(10), Js.Promise2.resolve(20)]) - -let thenPipe = Js.Promise2.resolve(1)->Js.Promise2.then(x => Js.Promise2.resolve(x + 1)) -let thenDirect = Js.Promise2.then(Js.Promise2.resolve(1), x => Js.Promise2.resolve(x + 1)) - -// Type alias migration -external p2: Js.Promise2.t = "p2" - -let catchPipe = Js.Promise2.resolve(1)->Js.Promise2.catch(_e => Js.Promise2.resolve(0)) -let catchDirect = Js.Promise2.catch(Js.Promise2.resolve(1), _e => Js.Promise2.resolve(0)) -let make1 = Js.Promise2.make((~resolve, ~reject as _) => resolve(1)) - -let _ = p2->Js.Promise2.then(x => Js.Promise2.resolve(x + 1)) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Result.res b/tests/tools_tests/src/migrate/StdlibMigration_Result.res deleted file mode 100644 index ed79392944a..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Result.res +++ /dev/null @@ -1,2 +0,0 @@ -type r = Js.Result.t -let res: Js.Result.t = Ok(1) diff --git a/tests/tools_tests/src/migrate/StdlibMigration_Set.res b/tests/tools_tests/src/migrate/StdlibMigration_Set.res deleted file mode 100644 index f8818cde872..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_Set.res +++ /dev/null @@ -1,2 +0,0 @@ -// Type alias migration for Js.Set.t -external s: Js.Set.t = "s" diff --git a/tests/tools_tests/src/migrate/StdlibMigration_String.res b/tests/tools_tests/src/migrate/StdlibMigration_String.res deleted file mode 100644 index edf01733c74..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_String.res +++ /dev/null @@ -1,129 +0,0 @@ -let make1 = 1->Js.String2.make -let make2 = Js.String2.make(1) - -let fromCharCode1 = 65->Js.String2.fromCharCode -let fromCharCode2 = Js.String2.fromCharCode(65) - -let fromCharCodeMany1 = [65, 66, 67]->Js.String2.fromCharCodeMany -let fromCharCodeMany2 = Js.String2.fromCharCodeMany([65, 66, 67]) - -let fromCodePoint1 = 65->Js.String2.fromCodePoint -let fromCodePoint2 = Js.String2.fromCodePoint(65) - -let fromCodePointMany1 = [65, 66, 67]->Js.String2.fromCodePointMany -let fromCodePointMany2 = Js.String2.fromCodePointMany([65, 66, 67]) - -let length1 = "abcde"->Js.String2.length -let length2 = Js.String2.length("abcde") - -let get1 = "abcde"->Js.String2.get(2) -let get2 = Js.String2.get("abcde", 2) - -let charAt1 = "abcde"->Js.String2.charAt(2) -let charAt2 = Js.String2.charAt("abcde", 2) - -let charCodeAt1 = "abcde"->Js.String2.charCodeAt(2) -let charCodeAt2 = Js.String2.charCodeAt("abcde", 2) - -let codePointAt1 = "abcde"->Js.String2.codePointAt(2) -let codePointAt2 = Js.String2.codePointAt("abcde", 2) - -let concat1 = "abcde"->Js.String2.concat("fghij") -let concat2 = Js.String2.concat("abcde", "fghij") - -let concatMany1 = "abcde"->Js.String2.concatMany(["fghij", "klmno"]) -let concatMany2 = Js.String2.concatMany("abcde", ["fghij", "klmno"]) - -let endsWith1 = "abcde"->Js.String2.endsWith("de") -let endsWith2 = Js.String2.endsWith("abcde", "de") - -let endsWithFrom1 = "abcde"->Js.String2.endsWithFrom("d", 2) -let endsWithFrom2 = Js.String2.endsWithFrom("abcde", "d", 2) - -let includes1 = "abcde"->Js.String2.includes("de") -let includes2 = Js.String2.includes("abcde", "de") - -let includesFrom1 = "abcde"->Js.String2.includesFrom("d", 2) -let includesFrom2 = Js.String2.includesFrom("abcde", "d", 2) - -let indexOf1 = "abcde"->Js.String2.indexOf("de") -let indexOf2 = Js.String2.indexOf("abcde", "de") - -let indexOfFrom1 = "abcde"->Js.String2.indexOfFrom("d", 2) -let indexOfFrom2 = Js.String2.indexOfFrom("abcde", "d", 2) - -let lastIndexOf1 = "abcde"->Js.String2.lastIndexOf("de") -let lastIndexOf2 = Js.String2.lastIndexOf("abcde", "de") - -let lastIndexOfFrom1 = "abcde"->Js.String2.lastIndexOfFrom("d", 2) -let lastIndexOfFrom2 = Js.String2.lastIndexOfFrom("abcde", "d", 2) - -let localeCompare1 = "abcde"->Js.String2.localeCompare("fghij") -let localeCompare2 = Js.String2.localeCompare("abcde", "fghij") - -let match1 = "abcde"->Js.String2.match_(/d/) -let match2 = Js.String2.match_("abcde", /d/) - -let normalize1 = "abcde"->Js.String2.normalize -let normalize2 = Js.String2.normalize("abcde") - -let repeat1 = "abcde"->Js.String2.repeat(2) -let repeat2 = Js.String2.repeat("abcde", 2) - -let replace1 = "abcde"->Js.String2.replace("d", "f") -let replace2 = Js.String2.replace("abcde", "d", "f") - -let replaceByRe1 = "abcde"->Js.String2.replaceByRe(/d/, "f") -let replaceByRe2 = Js.String2.replaceByRe("abcde", /d/, "f") - -let search1 = "abcde"->Js.String2.search(/d/) -let search2 = Js.String2.search("abcde", /d/) - -let slice1 = "abcde"->Js.String2.slice(~from=1, ~to_=3) -let slice2 = Js.String2.slice("abcde", ~from=1, ~to_=3) - -let sliceToEnd1 = "abcde"->Js.String2.sliceToEnd(~from=1) -let sliceToEnd2 = Js.String2.sliceToEnd("abcde", ~from=1) - -let split1 = "abcde"->Js.String2.split("d") -let split2 = Js.String2.split("abcde", "d") - -let splitAtMost1 = "abcde"->Js.String2.splitAtMost("d", ~limit=2) -let splitAtMost2 = Js.String2.splitAtMost("abcde", "d", ~limit=2) - -let splitByRe1 = "abcde"->Js.String2.splitByRe(/d/) -let splitByRe2 = Js.String2.splitByRe("abcde", /d/) - -let splitByReAtMost1 = "abcde"->Js.String2.splitByReAtMost(/d/, ~limit=2) -let splitByReAtMost2 = Js.String2.splitByReAtMost("abcde", /d/, ~limit=2) - -let startsWith1 = "abcde"->Js.String2.startsWith("ab") -let startsWith2 = Js.String2.startsWith("abcde", "ab") - -let startsWithFrom1 = "abcde"->Js.String2.startsWithFrom("b", 1) -let startsWithFrom2 = Js.String2.startsWithFrom("abcde", "b", 1) - -let substring1 = "abcde"->Js.String2.substring(~from=1, ~to_=3) -let substring2 = Js.String2.substring("abcde", ~from=1, ~to_=3) - -let substringToEnd1 = "abcde"->Js.String2.substringToEnd(~from=1) -let substringToEnd2 = Js.String2.substringToEnd("abcde", ~from=1) - -let toLowerCase1 = "abcde"->Js.String2.toLowerCase -let toLowerCase2 = Js.String2.toLowerCase("abcde") - -let toLocaleLowerCase1 = "abcde"->Js.String2.toLocaleLowerCase -let toLocaleLowerCase2 = Js.String2.toLocaleLowerCase("abcde") - -let toUpperCase1 = "abcde"->Js.String2.toUpperCase -let toUpperCase2 = Js.String2.toUpperCase("abcde") - -let toLocaleUpperCase1 = "abcde"->Js.String2.toLocaleUpperCase -let toLocaleUpperCase2 = Js.String2.toLocaleUpperCase("abcde") - -let trim1 = "abcde"->Js.String2.trim -let trim2 = Js.String2.trim("abcde") - -// Type alias migrations -let sT: Js.String.t = "abc" -let s2T: Js.String2.t = "def" diff --git a/tests/tools_tests/src/migrate/StdlibMigration_WeakMap.res b/tests/tools_tests/src/migrate/StdlibMigration_WeakMap.res deleted file mode 100644 index 0b4cd98ad24..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_WeakMap.res +++ /dev/null @@ -1,2 +0,0 @@ -// Type alias migration for Js.WeakMap.t -external wm: Js.WeakMap.t<{..}, int> = "wm" diff --git a/tests/tools_tests/src/migrate/StdlibMigration_WeakSet.res b/tests/tools_tests/src/migrate/StdlibMigration_WeakSet.res deleted file mode 100644 index 35d811fc183..00000000000 --- a/tests/tools_tests/src/migrate/StdlibMigration_WeakSet.res +++ /dev/null @@ -1,2 +0,0 @@ -// Type alias migration for Js.WeakSet.t -external ws: Js.WeakSet.t<{..}> = "ws" diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Array.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Array.res deleted file mode 100644 index 8349d0dfa50..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Array.res +++ /dev/null @@ -1,177 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Array.res. -let shift1 = [1, 2, 3]->Array.shift -let shift2 = Array.shift([1, 2, 3]) - -let slice1 = [1, 2, 3]->Array.slice(~start=1, ~end=2) -let slice2 = Array.slice([1, 2, 3], ~start=1, ~end=2) - -external someArrayLike: Array.arrayLike = "whatever" - -let from1 = someArrayLike->Array.fromArrayLike -let from2 = Array.fromArrayLike(someArrayLike) - -let fromMap1 = someArrayLike->Array.fromArrayLikeWithMap(s => s ++ "!") -let fromMap2 = Array.fromArrayLikeWithMap(someArrayLike, s => s ++ "!") - -let isArray1 = [1, 2, 3]->Array.isArray -let isArray2 = Array.isArray([1, 2, 3]) - -let length1 = [1, 2, 3]->Array.length -let length2 = Array.length([1, 2, 3]) - -let fillInPlace1 = [1, 2, 3]->Array.fillAll(0) -let fillInPlace2 = Array.fillAll([1, 2, 3], 0) - -let fillFromInPlace1 = [1, 2, 3, 4]->Array.fillToEnd(0, ~start=2) -let fillFromInPlace2 = Array.fillToEnd([1, 2, 3, 4], 0, ~start=2) - -let fillRangeInPlace1 = [1, 2, 3, 4]->Array.fill(0, ~start=1, ~end=3) -let fillRangeInPlace2 = Array.fill([1, 2, 3, 4], 0, ~start=1, ~end=3) - -let pop1 = [1, 2, 3]->Array.pop -let pop2 = Array.pop([1, 2, 3]) - -let reverseInPlace1 = [1, 2, 3]->Array.reverse -let reverseInPlace2 = Array.reverse([1, 2, 3]) - -let concat1 = [1, 2]->Array.concat([3, 4]) -let concat2 = Array.concat([1, 2], [3, 4]) - -let concatMany1 = [1, 2]->Array.concatMany([[3, 4], [5, 6]]) -let concatMany2 = Array.concatMany([1, 2], [[3, 4], [5, 6]]) - -let includes1 = [1, 2, 3]->Array.includes(2) -let includes2 = Array.includes([1, 2, 3], 2) - -let indexOf1 = [1, 2, 3]->Array.indexOf(2) -let indexOf2 = Array.indexOf([1, 2, 3], 2) - -let indexOfFrom1 = [1, 2, 1, 3]->Array.indexOfFrom(1, 2) -let indexOfFrom2 = Array.indexOfFrom([1, 2, 1, 3], 1, 2) - -let joinWith1 = [1, 2, 3]->Array.joinUnsafe(",") -let joinWith2 = Array.joinUnsafe([1, 2, 3], ",") - -let lastIndexOf1 = [1, 2, 1, 3]->Array.lastIndexOf(1) -let lastIndexOf2 = Array.lastIndexOf([1, 2, 1, 3], 1) - -let lastIndexOfFrom1 = [1, 2, 1, 3, 1]->Array.lastIndexOfFrom(1, 3) -let lastIndexOfFrom2 = Array.lastIndexOfFrom([1, 2, 1, 3, 1], 1, 3) - -let copy1 = [1, 2, 3]->Array.copy -let copy2 = Array.copy([1, 2, 3]) - -let sliceFrom1 = [1, 2, 3, 4]->Array.slice(~start=2) -let sliceFrom2 = Array.slice([1, 2, 3, 4], ~start=2) - -let toString1 = [1, 2, 3]->Array.toString -let toString2 = Array.toString([1, 2, 3]) - -let toLocaleString1 = [1, 2, 3]->Array.toLocaleString -let toLocaleString2 = Array.toLocaleString([1, 2, 3]) - -let every1 = [2, 4, 6]->Array.every(x => mod(x, 2) == 0) -let every2 = Array.every([2, 4, 6], x => mod(x, 2) == 0) - -let everyi1 = [0, 1, 2]->Array.everyWithIndex((x, i) => x == i) -let everyi2 = Array.everyWithIndex([0, 1, 2], (x, i) => x == i) - -let filter1 = [1, 2, 3, 4]->Array.filter(x => x > 2) -let filter2 = Array.filter([1, 2, 3, 4], x => x > 2) - -let filteri1 = [0, 1, 2, 3]->Array.filterWithIndex((_x, i) => i > 1) -let filteri2 = Array.filterWithIndex([0, 1, 2, 3], (_x, i) => i > 1) - -let find1 = [1, 2, 3, 4]->Array.find(x => x > 2) -let find2 = Array.find([1, 2, 3, 4], x => x > 2) - -let findi1 = [0, 1, 2, 3]->Array.findWithIndex((_x, i) => i > 1) -let findi2 = Array.findWithIndex([0, 1, 2, 3], (_x, i) => i > 1) - -let findIndex1 = [1, 2, 3, 4]->Array.findIndex(x => x > 2) -let findIndex2 = Array.findIndex([1, 2, 3, 4], x => x > 2) - -let findIndexi1 = [0, 1, 2, 3]->Array.findIndexWithIndex((_x, i) => i > 1) -let findIndexi2 = Array.findIndexWithIndex([0, 1, 2, 3], (_x, i) => i > 1) - -let forEach1 = [1, 2, 3]->Array.forEach(x => ignore(x)) -let forEach2 = Array.forEach([1, 2, 3], x => ignore(x)) - -let forEachi1 = [1, 2, 3]->Array.forEachWithIndex((x, i) => ignore(x + i)) -let forEachi2 = Array.forEachWithIndex([1, 2, 3], (x, i) => ignore(x + i)) - -let map1 = [1, 2, 3]->Array.map(x => x * 2) -let map2 = Array.map([1, 2, 3], x => x * 2) - -let mapi1 = [1, 2, 3]->Array.mapWithIndex((x, i) => x + i) -let mapi2 = Array.mapWithIndex([1, 2, 3], (x, i) => x + i) - -let some1 = [1, 2, 3, 4]->Array.some(x => x > 3) -let some2 = Array.some([1, 2, 3, 4], x => x > 3) - -let somei1 = [0, 1, 2, 3]->Array.someWithIndex((_x, i) => i > 2) -let somei2 = Array.someWithIndex([0, 1, 2, 3], (_x, i) => i > 2) - -let unsafeGet1 = [1, 2, 3]->Array.getUnsafe(1) -let unsafeGet2 = Array.getUnsafe([1, 2, 3], 1) - -let unsafeSet1 = [1, 2, 3]->Array.setUnsafe(1, 5) -let unsafeSet2 = Array.setUnsafe([1, 2, 3], 1, 5) - -let copyWithin1 = [1, 2, 3, 4, 5]->Array.copyAllWithin(~target=2) -let copyWithin2 = Array.copyAllWithin([1, 2, 3, 4, 5], ~target=2) - -let copyWithinFrom1 = [1, 2, 3, 4, 5]->Array.copyWithinToEnd(~target=0, ~start=2) -let copyWithinFrom2 = Array.copyWithinToEnd([1, 2, 3, 4, 5], ~target=0, ~start=2) - -let copyWithinFromRange1 = [1, 2, 3, 4, 5, 6]->Array.copyWithin(~start=2, ~target=1, ~end=5) -let copyWithinFromRange2 = Array.copyWithin([1, 2, 3, 4, 5, 6], ~start=2, ~target=1, ~end=5) - -let push1 = [1, 2, 3]->Array.push(4) -let push2 = Array.push([1, 2, 3], 4) - -let pushMany1 = [1, 2, 3]->Array.pushMany([4, 5]) -let pushMany2 = Array.pushMany([1, 2, 3], [4, 5]) - -let sortInPlace1 = - ["c", "a", "b"]->Array.toSorted((_a, _b) => - %todo("This needs a comparator function. Use `String.compare` for strings, etc.") - ) -let sortInPlace2 = Array.toSorted(["c", "a", "b"], (_a, _b) => - %todo("This needs a comparator function. Use `String.compare` for strings, etc.") -) - -let unshift1 = [1, 2, 3]->Array.unshift(4) -let unshift2 = Array.unshift([1, 2, 3], 4) - -let unshiftMany1 = [1, 2, 3]->Array.unshiftMany([4, 5]) -let unshiftMany2 = Array.unshiftMany([1, 2, 3], [4, 5]) - -let reduce1 = [1, 2, 3]->Array.reduce(0, (acc, x) => acc + x) -let reduce2 = Array.reduce([1, 2, 3], 0, (acc, x) => acc + x) - -let spliceInPlace1 = [1, 2, 3]->Array.splice(~start=1, ~remove=1, ~insert=[4, 5]) -let spliceInPlace2 = Array.splice([1, 2, 3], ~start=1, ~remove=1, ~insert=[4, 5]) - -let removeFromInPlace1 = [1, 2, 3]->Array.removeInPlace(1) -let removeFromInPlace2 = Array.removeInPlace([1, 2, 3], 1) - -let removeCountInPlace1 = [1, 2, 3]->Array.splice(~start=1, ~remove=1, ~insert=[]) -let removeCountInPlace2 = Array.splice([1, 2, 3], ~start=1, ~remove=1, ~insert=[]) - -let reducei1 = [1, 2, 3]->Array.reduceWithIndex(0, (acc, x, i) => acc + x + i) -let reducei2 = Array.reduceWithIndex([1, 2, 3], 0, (acc, x, i) => acc + x + i) - -let reduceRight1 = [1, 2, 3]->Array.reduceRight(0, (acc, x) => acc + x) -let reduceRight2 = Array.reduceRight([1, 2, 3], 0, (acc, x) => acc + x) - -let reduceRighti1 = [1, 2, 3]->Array.reduceRightWithIndex(0, (acc, x, i) => acc + x + i) -let reduceRighti2 = Array.reduceRightWithIndex([1, 2, 3], 0, (acc, x, i) => acc + x + i) - -let pipeChain = - [1, 2, 3]->Array.map(x => x * 2)->Array.filter(x => x > 2)->Array.reduce(0, (acc, x) => acc + x) - -// Type alias migrations -let arrT: array = [1, 2, 3] -let arr2T: array = [1, 2, 3] diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_BigInt.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_BigInt.res deleted file mode 100644 index 3e18bfe309e..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_BigInt.res +++ /dev/null @@ -1,50 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_BigInt.res. -let fromStringExn1 = "123"->BigInt.fromStringOrThrow -let fromStringExn2 = BigInt.fromStringOrThrow("123") - -let land1 = 7n &&& 4n -let land2 = 7n &&& 4n -let land3 = 7n->BigInt.toString->BigInt.fromStringOrThrow->BigInt.bitwiseAnd(4n) - -let lor1 = 7n ||| 4n -let lor2 = 7n ||| 4n - -let lxor1 = 7n ^^^ 4n -let lxor2 = 7n ^^^ 4n - -let lnot1 = 2n->Js.BigInt.lnot -let lnot2 = Js.BigInt.lnot(2n) - -let lsl1 = 4n << 1n -let lsl2 = 4n << 1n - -let asr1 = 8n >> 1n -let asr2 = 8n >> 1n - -let toString1 = 123n->BigInt.toString -let toString2 = BigInt.toString(123n) - -let toLocaleString1 = 123n->BigInt.toLocaleString -let toLocaleString2 = BigInt.toLocaleString(123n) - -// From the stdlib module -let stdlib_fromStringExn1 = "123"->BigInt.fromStringOrThrow -let stdlib_fromStringExn2 = BigInt.fromStringOrThrow("123") - -let stdlib_land1 = 7n &&& 4n -let stdlib_land2 = 7n &&& 4n - -let stdlib_lor1 = 7n ||| 4n - -let stdlib_lxor1 = 7n ^^^ 4n -let stdlib_lxor2 = 7n ^^^ 4n - -let stdlib_lnot1 = ~~~2n -let stdlib_lnot2 = ~~~2n - -let stdlib_lsl1 = 4n << 1n -let stdlib_lsl2 = 4n << 1n - -let stdlib_asr1 = 8n >> 1n -let stdlib_asr2 = 8n >> 1n diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Console.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Console.res deleted file mode 100644 index d539a855609..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Console.res +++ /dev/null @@ -1,30 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Console.res. -let log = Console.log("Hello, World!") -let log2 = Console.log2("Hello", "World") -let log3 = Console.log3("Hello", "World", "!") -let log4 = Console.log4("Hello", "World", "!", "!") -let logMany = Console.logMany(["Hello", "World"]) - -let info = Console.info("Hello, World!") -let info2 = Console.info2("Hello", "World") -let info3 = Console.info3("Hello", "World", "!") -let info4 = Console.info4("Hello", "World", "!", "!") -let infoMany = Console.infoMany(["Hello", "World"]) - -let warn = Console.warn("Hello, World!") -let warn2 = Console.warn2("Hello", "World") -let warn3 = Console.warn3("Hello", "World", "!") -let warn4 = Console.warn4("Hello", "World", "!", "!") -let warnMany = Console.warnMany(["Hello", "World"]) - -let error = Console.error("Hello, World!") -let error2 = Console.error2("Hello", "World") -let error3 = Console.error3("Hello", "World", "!") -let error4 = Console.error4("Hello", "World", "!", "!") -let errorMany = Console.errorMany(["Hello", "World"]) - -let trace = Console.trace() -let timeStart = Console.time("Hello, World!") -let timeEnd = Console.timeEnd("Hello, World!") -let table = Console.table(["Hello", "World"]) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Date.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Date.res deleted file mode 100644 index 2df5dd3ff59..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Date.res +++ /dev/null @@ -1,192 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Date.res. -let d1 = Date.make() -let d2 = Date.fromString("1973-11-29T21:30:54.321Z") -let d3 = Date.fromTime(123456789.0) - -let msNow = Date.now() - -let v1 = d2->Date.getTime -let v2 = Date.getTime(d2) - -let y = d2->Date.getFullYear -let mo = d2->Date.getMonth -let dayOfMonth = d2->Date.getDate -let dayOfWeek = d2->Date.getDay -let h = d2->Date.getHours -let mi = d2->Date.getMinutes -let s = d2->Date.getSeconds -let ms = d2->Date.getMilliseconds -let tz = d2->Date.getTimezoneOffset - -let uy = d2->Date.getUTCFullYear -let um = d2->Date.getUTCMonth -let ud = d2->Date.getUTCDate -let uday = d2->Date.getUTCDay -let uh = d2->Date.getUTCHours -let umi = d2->Date.getUTCMinutes -let us = d2->Date.getUTCSeconds -let ums = d2->Date.getUTCMilliseconds - -let s1 = d2->Date.toISOString -let s2 = d2->Date.toUTCString -let s3 = d2->Date.toString -let s4 = d2->Date.toTimeString -let s5 = d2->Date.toDateString -let s6 = d2->Date.toLocaleString -let s7 = d2->Date.toLocaleDateString -let s8 = d2->Date.toLocaleTimeString - -/* Additional deprecated APIs to exercise migration */ - -/* getters and legacy variants */ -let t = d2->Date.getTime -let y2 = d2->Date.getFullYear - -/* constructors with components */ -let mym = Date.makeWithYM(~year=Float.toInt(2020.0), ~month=Float.toInt(10.0)) -let mymd = Date.makeWithYMD( - ~year=Float.toInt(1973.0), - ~month=Float.toInt(10.0), - ~day=Float.toInt(29.0), -) -let mymdh = Date.makeWithYMDH( - ~year=Float.toInt(1973.0), - ~month=Float.toInt(10.0), - ~day=Float.toInt(29.0), - ~hours=Float.toInt(21.0), -) -let mymdhm = Date.makeWithYMDHM( - ~year=Float.toInt(1973.0), - ~month=Float.toInt(10.0), - ~day=Float.toInt(29.0), - ~hours=Float.toInt(21.0), - ~minutes=Float.toInt(30.0), -) -let mymdhms = Date.makeWithYMDHMS( - ~year=Float.toInt(1973.0), - ~month=Float.toInt(10.0), - ~day=Float.toInt(29.0), - ~hours=Float.toInt(21.0), - ~minutes=Float.toInt(30.0), - ~seconds=Float.toInt(54.0), -) - -/* Date.UTC variants */ -let uym = Date.UTC.makeWithYM(~year=Float.toInt(2020.0), ~month=Float.toInt(10.0)) -let uymd = Date.UTC.makeWithYMD( - ~year=Float.toInt(1973.0), - ~month=Float.toInt(10.0), - ~day=Float.toInt(29.0), -) -let uymdh = Date.UTC.makeWithYMDH( - ~year=Float.toInt(1973.0), - ~month=Float.toInt(10.0), - ~day=Float.toInt(29.0), - ~hours=Float.toInt(21.0), -) -let uymdhm = Date.UTC.makeWithYMDHM( - ~year=Float.toInt(1973.0), - ~month=Float.toInt(10.0), - ~day=Float.toInt(29.0), - ~hours=Float.toInt(21.0), - ~minutes=Float.toInt(30.0), -) -let uymdhms = Date.UTC.makeWithYMDHMS( - ~year=Float.toInt(1973.0), - ~month=Float.toInt(10.0), - ~day=Float.toInt(29.0), - ~hours=Float.toInt(21.0), - ~minutes=Float.toInt(30.0), - ~seconds=Float.toInt(54.0), -) - -/* parse APIs */ -let p = Date.fromString("1973-11-29T21:30:54.321Z") -let pf = Date.getTime(Date.fromString("1973-11-29T21:30:54.321Z")) - -/* setters (local time) */ -let setD = d2->Date.setDate(Float.toInt(15.0)) -let setFY = d2->Date.setFullYear(Float.toInt(1974.0)) - -let setFYM = d2->Date.setFullYearM(~year=Float.toInt(1974.0), ~month=Float.toInt(0.0)) -let setFYMD = - d2->Date.setFullYearMD(~year=Float.toInt(1974.0), ~month=Float.toInt(0.0), ~day=Float.toInt(7.0)) -let setH = d2->Date.setHours(Float.toInt(22.0)) -let setHM = d2->Date.setHoursM(~hours=Float.toInt(22.0), ~minutes=Float.toInt(46.0)) -let setHMS = - d2->Date.setHoursMS( - ~hours=Float.toInt(22.0), - ~minutes=Float.toInt(46.0), - ~seconds=Float.toInt(37.0), - ) -let setHMSMs = - d2->Date.setHoursMSMs( - ~hours=Float.toInt(22.0), - ~minutes=Float.toInt(46.0), - ~seconds=Float.toInt(37.0), - ~milliseconds=Float.toInt(494.0), - ) -let setMs = d2->Date.setMilliseconds(Float.toInt(494.0)) -let setMin = d2->Date.setMinutes(Float.toInt(34.0)) -let setMinS = d2->Date.setMinutesS(~minutes=Float.toInt(34.0), ~seconds=Float.toInt(56.0)) -let setMinSMs = - d2->Date.setMinutesSMs( - ~minutes=Float.toInt(34.0), - ~seconds=Float.toInt(56.0), - ~milliseconds=Float.toInt(789.0), - ) -let setMon = d2->Date.setMonth(Float.toInt(11.0)) -let setMonD = d2->Js.Date.setMonthD(~month=11.0, ~date=8.0, ()) -let setSec = d2->Date.setSeconds(Float.toInt(56.0)) -let setSecMs = d2->Date.setSecondsMs(~seconds=Float.toInt(56.0), ~milliseconds=Float.toInt(789.0)) - -/* setters (UTC) */ -let setUD = d2->Date.setUTCDate(Float.toInt(15.0)) -let setUFY = d2->Date.setUTCFullYear(Float.toInt(1974.0)) -let setUFYM = d2->Date.setUTCFullYearM(~year=Float.toInt(1974.0), ~month=Float.toInt(0.0)) -let setUFYMD = - d2->Date.setUTCFullYearMD( - ~year=Float.toInt(1974.0), - ~month=Float.toInt(0.0), - ~day=Float.toInt(7.0), - ) -let setUH = d2->Date.setUTCHours(Float.toInt(22.0)) -let setUHM = d2->Date.setUTCHoursM(~hours=Float.toInt(22.0), ~minutes=Float.toInt(46.0)) -let setUHMS = - d2->Date.setUTCHoursMS( - ~hours=Float.toInt(22.0), - ~minutes=Float.toInt(46.0), - ~seconds=Float.toInt(37.0), - ) -let setUHMSMs = - d2->Date.setUTCHoursMSMs( - ~hours=Float.toInt(22.0), - ~minutes=Float.toInt(46.0), - ~seconds=Float.toInt(37.0), - ~milliseconds=Float.toInt(494.0), - ) -let setUMs = d2->Date.setUTCMilliseconds(Float.toInt(494.0)) -let setUMin = d2->Date.setUTCMinutes(Float.toInt(34.0)) -let setUMinS = d2->Date.setUTCMinutesS(~minutes=Float.toInt(34.0), ~seconds=Float.toInt(56.0)) -let setUMinSMs = - d2->Date.setUTCMinutesSMs( - ~minutes=Float.toInt(34.0), - ~seconds=Float.toInt(56.0), - ~milliseconds=Float.toInt(789.0), - ) -let setUMon = d2->Date.setUTCMonth(Float.toInt(11.0)) -let setUMonD = d2->Js.Date.setUTCMonthD(~month=11.0, ~date=8.0, ()) -let setUSec = d2->Date.setUTCSeconds(Float.toInt(56.0)) -let setUSecMs = - d2->Date.setUTCSecondsMs(~seconds=Float.toInt(56.0), ~milliseconds=Float.toInt(789.0)) -let setUT = d2->Js.Date.setUTCTime(198765432101.0) -let setYr = d2->Js.Date.setYear(1999.0) - -/* other string conversions */ -let s9 = d2->Date.toUTCString -let j1 = d2->Date.toJSON -let j2 = d2->Date.toJSON - -// Type alias migration -external someDate: Date.t = "someDate" diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Dict.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Dict.res deleted file mode 100644 index 990ab3b5e0a..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Dict.res +++ /dev/null @@ -1,35 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Dict.res. -let d = Dict.make() - -let get1 = d->Dict.get("k") -let get2 = Dict.get(d, "k") - -let unsafeGet1 = d->Dict.getUnsafe("k") -let unsafeGet2 = Dict.getUnsafe(d, "k") - -let set1 = d->Dict.set("k", 1) -let set2 = Dict.set(d, "k", 1) - -let keys1 = d->Dict.keysToArray -let keys2 = Dict.keysToArray(d) - -let values1 = d->Dict.valuesToArray -let values2 = Dict.valuesToArray(d) - -let entries1 = d->Dict.toArray -let entries2 = Dict.toArray(d) - -let dStr: dict = Dict.make() -let del1 = dStr->Dict.delete("k") -let del2 = Dict.delete(dStr, "k") - -let empty1: dict = Dict.make() - -let fromArray1 = [("a", 1), ("b", 2)]->Dict.fromArray -let fromArray2 = Dict.fromArray([("a", 1), ("b", 2)]) - -let fromList1 = list{("a", 1), ("b", 2)}->Js.Dict.fromList -let fromList2 = Js.Dict.fromList(list{("a", 1), ("b", 2)}) - -let map2 = Dict.mapValues(d, x => x + 1) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Extern.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Extern.res deleted file mode 100644 index fc60d7b0c08..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Extern.res +++ /dev/null @@ -1,8 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Extern.res. -// Exercise migrations from Js_extern to new Stdlib APIs - -let isNullish = Nullable.isNullable(%raw("null")) -let n = Nullable.null -let u = Nullable.undefined -let ty = Type.typeof("hello") diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Float.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Float.res deleted file mode 100644 index d4bdcc1a15d..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Float.res +++ /dev/null @@ -1,36 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Float.res. -let nan1 = Float.Constants.nan - -let isNaN1 = Float.Constants.nan->Float.isNaN -let isNaN2 = Float.isNaN(Float.Constants.nan) - -let isFinite1 = 1234.0->Float.isFinite -let isFinite2 = Float.isFinite(1234.0) - -let toExponential1 = 77.1234->Float.toExponential -let toExponential2 = Float.toExponential(77.1234) - -let toExponentialWithPrecision1 = 77.1234->Float.toExponential(~digits=2) -let toExponentialWithPrecision2 = Float.toExponential(77.1234, ~digits=2) - -let toFixed1 = 12345.6789->Float.toFixed -let toFixed2 = Float.toFixed(12345.6789) - -let toFixedWithPrecision1 = 12345.6789->Float.toFixed(~digits=1) -let toFixedWithPrecision2 = Float.toFixed(12345.6789, ~digits=1) - -let toPrecision1 = 12345.6789->Float.toPrecision -let toPrecision2 = Float.toPrecision(12345.6789) - -let toPrecisionWithPrecision1 = 12345.6789->Float.toPrecision(~digits=2) -let toPrecisionWithPrecision2 = Float.toPrecision(12345.6789, ~digits=2) - -let toString1 = 12345.6789->Float.toString -let toString2 = Float.toString(12345.6789) - -let toStringWithRadix1 = 6.0->Float.toString(~radix=2) -let toStringWithRadix2 = Float.toString(6.0, ~radix=2) - -let parse1 = "123"->Float.parseFloat -let parse2 = Float.parseFloat("123") diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Global.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Global.res deleted file mode 100644 index 80e8767e681..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Global.res +++ /dev/null @@ -1,17 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Global.res. -let t1: timeoutId = setTimeout(() => (), 1000) -let t2: timeoutId = setTimeoutFloat(() => (), 1000.0) - -clearTimeout(t1) - -let i1: intervalId = setInterval(() => (), 2000) -let i2: intervalId = setIntervalFloat(() => (), 2000.0) - -clearInterval(i1) - -let e1 = encodeURI("https://rescript-lang.org?array=[someValue]") -let d1 = decodeURI("https://rescript-lang.org?array=%5BsomeValue%5D") - -let e2 = encodeURIComponent("array=[someValue]") -let d2 = decodeURIComponent("array%3D%5BsomeValue%5D") diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Interface.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Interface.res deleted file mode 100644 index 5c10829b6d3..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Interface.res +++ /dev/null @@ -1,10 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Interface.res. -/* Implementation to satisfy interface build for tests */ - -external arr: array = "arr" -external reT: RegExp.t = "re" -external json: JSON.t = "json" -external nestedArr: array = "nestedArr" - -external useSet: Set.t => unit = "useSet" diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_JSON.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_JSON.res deleted file mode 100644 index 54e72a78cec..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_JSON.res +++ /dev/null @@ -1,24 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_JSON.res. -external someJson: JSON.t = "someJson" -external strToJson: string => JSON.t = "strToJson" - -let decodeString1 = someJson->JSON.Decode.string -let decodeString2 = JSON.Decode.string(someJson) -let decodeString3 = - [1, 2, 3]->Array.map(v => v->Int.toString)->Array.join(" ")->strToJson->JSON.Decode.string - -let decodeNumber1 = someJson->JSON.Decode.float -let decodeNumber2 = JSON.Decode.float(someJson) - -let decodeObject1 = someJson->JSON.Decode.object -let decodeObject2 = JSON.Decode.object(someJson) - -let decodeArray1 = someJson->JSON.Decode.array -let decodeArray2 = JSON.Decode.array(someJson) - -let decodeBoolean1 = someJson->JSON.Decode.bool -let decodeBoolean2 = JSON.Decode.bool(someJson) - -let decodeNull1 = someJson->JSON.Decode.null -let decodeNull2 = JSON.Decode.null(someJson) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js.res deleted file mode 100644 index 87922b75211..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js.res +++ /dev/null @@ -1,7 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Js.res. -let consoleLog1 = Console.log("Hello") -let consoleLog2 = Console.log2("Hello", "World") -let consoleLog3 = Console.log3("Hello", "World", "!") -let consoleLog4 = Console.log4("Hello", "World", "!", "!") -let consoleLogMany = Console.logMany(["Hello", "World"]) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_Array.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_Array.res deleted file mode 100644 index f5f2bf86c2e..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_Array.res +++ /dev/null @@ -1,35 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Js_Array.res. -// Migration tests for Js.Array (old) -> Array module - -external someArrayLike: Array.arrayLike = "whatever" - -let from1 = someArrayLike->Array.fromArrayLike -let from2 = Array.fromArrayLike(someArrayLike) - -let fromMap1 = someArrayLike->Array.fromArrayLikeWithMap(s => s ++ "!") -let fromMap2 = Array.fromArrayLikeWithMap(someArrayLike, s => s ++ "!") - -let isArray1 = [1, 2, 3]->Array.isArray -let isArray2 = Array.isArray([1, 2, 3]) - -let length1 = [1, 2, 3]->Array.length -let length2 = Array.length([1, 2, 3]) - -let pop1 = [1, 2, 3]->Array.pop -let pop2 = Array.pop([1, 2, 3]) - -let reverseInPlace1 = [1, 2, 3]->Array.reverse -let reverseInPlace2 = Array.reverse([1, 2, 3]) - -let shift1 = [1, 2, 3]->Array.shift -let shift2 = Array.shift([1, 2, 3]) - -let toString1 = [1, 2, 3]->Array.toString -let toString2 = Array.toString([1, 2, 3]) - -let toLocaleString1 = [1, 2, 3]->Array.toLocaleString -let toLocaleString2 = Array.toLocaleString([1, 2, 3]) - -// Type alias migration -let arrT: array = [1, 2, 3] diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_Int.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_Int.res deleted file mode 100644 index 379b142ce9b..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_Int.res +++ /dev/null @@ -1,25 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Js_Int.res. -let toExponential1 = 77->Int.toExponential -let toExponential2 = Int.toExponential(77) - -let toExponentialWithPrecision1 = 77->Int.toExponential(~digits=2) -let toExponentialWithPrecision2 = Int.toExponential(77, ~digits=2) - -let toPrecision1 = 123456789->Int.toPrecision -let toPrecision2 = Int.toPrecision(123456789) - -let toPrecisionWithPrecision1 = 123456789->Int.toPrecision(~digits=2) -let toPrecisionWithPrecision2 = Int.toPrecision(123456789, ~digits=2) - -let toString1 = 123456789->Int.toString -let toString2 = Int.toString(123456789) - -let toStringWithRadix1 = 373592855->Int.toString(~radix=16) -let toStringWithRadix2 = Int.toString(373592855, ~radix=16) - -let toFloat1 = 42->Int.toFloat -let toFloat2 = Int.toFloat(42) - -let equal1 = Js.Int.equal(1, 1) -let equal2 = 1->Js.Int.equal(2) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_More.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_More.res deleted file mode 100644 index 816136577fe..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_More.res +++ /dev/null @@ -1,9 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Js_More.res. -// Migration tests for new deprecations in packages/@rescript/runtime/Js.res - -// typeof migration -let tyNum = typeof(1) - -// nullToOption -let nToOpt = Null.toOption(Null.make(1)) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_Re.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_Re.res deleted file mode 100644 index d059c10e9c7..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_Re.res +++ /dev/null @@ -1,52 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Js_Re.res. -let re1 = RegExp.fromString("foo") -let re2 = RegExp.fromString("foo", ~flags="gi") - -let flags1 = re2->RegExp.flags -let flags2 = RegExp.flags(re2) - -let g1 = re2->RegExp.global -let g2 = RegExp.global(re2) - -let ic1 = re2->RegExp.ignoreCase -let ic2 = RegExp.ignoreCase(re2) - -let m1 = re2->RegExp.multiline -let m2 = RegExp.multiline(re2) - -let u1 = re2->RegExp.unicode -let u2 = RegExp.unicode(re2) - -let y1 = re2->RegExp.sticky -let y2 = RegExp.sticky(re2) - -let src1 = re2->RegExp.source -let src2 = RegExp.source(re2) - -let li1 = re2->RegExp.lastIndex -let () = re2->RegExp.setLastIndex(0) - -let exec1 = re2->RegExp.exec("Foo bar") -let exec2 = RegExp.exec(re2, "Foo bar") - -let test1 = re2->RegExp.test("Foo bar") -let test2 = RegExp.test(re2, "Foo bar") - -// Type alias migration -external reT: RegExp.t = "re" - -let matches_access = switch re2->RegExp.exec("Foo bar") { -| None => 0 -| Some(r) => RegExp.Result.matches(r)->Array.length -} - -let result_index = switch re2->RegExp.exec("Foo bar") { -| None => 0 -| Some(r) => RegExp.Result.index(r) -} - -let result_input = switch re2->RegExp.exec("Foo bar") { -| None => "" -| Some(r) => RegExp.Result.input(r) -} diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_String.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_String.res deleted file mode 100644 index ac0d02099f8..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_String.res +++ /dev/null @@ -1,45 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Js_String.res. -// Migration tests for Js.String (old) -> String module - -let make1 = 1->String.make -let make2 = String.make(1) - -let fromCharCode1 = 65->String.fromCharCode -let fromCharCode2 = String.fromCharCode(65) - -let fromCharCodeMany1 = [65, 66, 67]->String.fromCharCodeMany -let fromCharCodeMany2 = String.fromCharCodeMany([65, 66, 67]) - -let fromCodePoint1 = 65->String.fromCodePoint -let fromCodePoint2 = String.fromCodePoint(65) - -let fromCodePointMany1 = [65, 66, 67]->String.fromCodePointMany -let fromCodePointMany2 = String.fromCodePointMany([65, 66, 67]) - -let length1 = "abcde"->String.length -let length2 = String.length("abcde") - -let get1 = "abcde"->String.get(2) -let get2 = String.get("abcde", 2) - -let normalize1 = "abcde"->String.normalize -let normalize2 = String.normalize("abcde") - -let toLowerCase1 = "ABCDE"->String.toLowerCase -let toLowerCase2 = String.toLowerCase("ABCDE") - -let toUpperCase1 = "abcde"->String.toUpperCase -let toUpperCase2 = String.toUpperCase("abcde") - -let toLocaleLowerCase1 = "ABCDE"->String.toLocaleLowerCase -let toLocaleLowerCase2 = String.toLocaleLowerCase("ABCDE") - -let toLocaleUpperCase1 = "abcde"->String.toLocaleUpperCase -let toLocaleUpperCase2 = String.toLocaleUpperCase("abcde") - -let trim1 = " abcde "->String.trim -let trim2 = String.trim(" abcde ") - -// Type alias migration -let sT: string = "abc" diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_Types_Interface.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_Types_Interface.res deleted file mode 100644 index ee622cfb461..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_Types_Interface.res +++ /dev/null @@ -1,11 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Js_Types_Interface.res. -/* Implementation to satisfy interface build for tests */ - -external nullT: Null.t = "nullT" -external nullableT: Nullable.t = "nullableT" -external nullUndefT: Nullable.t = "nullUndefT" - -external symbolT: Symbol.t = "symbolT" -external objValT: Type.Classify.object = "objValT" -external functionValT: Type.Classify.function = "functionValT" diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_Undefined.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_Undefined.res deleted file mode 100644 index 47a7a236879..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_Undefined.res +++ /dev/null @@ -1,37 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Js_Undefined.res. -let make1 = "hello"->Nullable.make -let make2 = Nullable.make("hello") - -let empty1 = Nullable.undefined - -let getUnsafe1 = Nullable.make(1)->Nullable.getUnsafe -let getUnsafe2 = Nullable.getUnsafe(Nullable.make(1)) - -let getExn1 = Nullable.make(1)->Nullable.getOrThrow -let getExn2 = Nullable.getOrThrow(Nullable.make(1)) - -let map1 = Nullable.make(2)->Nullable.map(x => x + 1) -let map2 = Nullable.map(Nullable.make(2), x => x + 1) - -let forEach1 = Nullable.make(2)->Nullable.forEach(x => ignore(x)) -let forEach2 = Nullable.forEach(Nullable.make(2), x => ignore(x)) - -let fromOption1 = Some("x")->Nullable.fromOption -let fromOption2 = Nullable.fromOption(None) - -let from_opt1 = Some("y")->Nullable.fromOption -let from_opt2 = Nullable.fromOption(None) - -let toOption1 = Nullable.make(3)->Nullable.toOption -let toOption2 = Nullable.toOption(Nullable.make(3)) - -let to_opt1 = Nullable.make(4)->Nullable.toOption -let to_opt2 = Nullable.toOption(Nullable.make(4)) - -let test1 = Js.Undefined.empty->Js.Undefined.test -let test2 = Js.Undefined.test(Js.Undefined.empty) -let test3 = Js.Undefined.return(5)->Js.Undefined.bind(v => v)->Js.Undefined.test - -let testAny1 = Js.Undefined.testAny(Js.Undefined.empty) -let testAny2 = Js.Undefined.empty->Js.Undefined.testAny diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_typed_array.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_typed_array.res deleted file mode 100644 index 3020b2501f9..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_typed_array.res +++ /dev/null @@ -1,9 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Js_typed_array.res. -let arr1 = Int8Array.fromArray([1, 2, 3]) - -let len = arr1->TypedArray.length - -let bytes = Int8Array.Constants.bytesPerElement -let off = Int8Array.fromBufferToEnd(ArrayBuffer.make(8), ~byteOffset=2) -let range = Int8Array.fromBufferWithRange(ArrayBuffer.make(8), ~byteOffset=2, ~length=2) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_typed_array2.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_typed_array2.res deleted file mode 100644 index 5b48a436243..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_typed_array2.res +++ /dev/null @@ -1,20 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Js_typed_array2.res. -let arr = Int8Array.fromArray([1, 2, 3]) - -let len1 = arr->TypedArray.length -let includes1 = arr->TypedArray.includes(2) -let idxFrom1 = arr->TypedArray.indexOfFrom(2, 1) - -let slice1 = arr->TypedArray.slice(~start=1, ~end=2) -let sliceFrom1 = arr->TypedArray.sliceToEnd(~start=1) - -let map1 = arr->TypedArray.map(x => x + 1) -let reduce1 = arr->TypedArray.reduce((acc, x) => acc + x, 0) - -let bytes = Int8Array.Constants.bytesPerElement - -let fromBufToEnd = Int8Array.fromBufferToEnd(ArrayBuffer.make(8), ~byteOffset=2) -let fromBufRange = Int8Array.fromBufferWithRange(ArrayBuffer.make(8), ~byteOffset=2, ~length=2) - -let fromLength = Int8Array.fromLength(3) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_typed_array2_Float32.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_typed_array2_Float32.res deleted file mode 100644 index 086550b6c55..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_typed_array2_Float32.res +++ /dev/null @@ -1,20 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Js_typed_array2_Float32.res. -let arr = Float32Array.fromArray([1.0, 2.0, 3.0]) - -let len1 = arr->TypedArray.length -let includes1 = arr->TypedArray.includes(2.0) -let idxFrom1 = arr->TypedArray.indexOfFrom(2.0, 1) - -let slice1 = arr->TypedArray.slice(~start=1, ~end=2) -let sliceFrom1 = arr->TypedArray.sliceToEnd(~start=1) - -let map1 = arr->TypedArray.map(x => x +. 1.0) -let reduce1 = arr->TypedArray.reduce((acc, x) => acc +. x, 0.0) - -let bytes = Float32Array.Constants.bytesPerElement - -let fromBufToEnd = Float32Array.fromBufferToEnd(ArrayBuffer.make(8), ~byteOffset=2) -let fromBufRange = Float32Array.fromBufferWithRange(ArrayBuffer.make(8), ~byteOffset=2, ~length=2) - -let fromLength = Float32Array.fromLength(3) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_typed_array_Float32_Const.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_typed_array_Float32_Const.res deleted file mode 100644 index 38edff97815..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Js_typed_array_Float32_Const.res +++ /dev/null @@ -1,4 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Js_typed_array_Float32_Const.res. -// Float32 constants migration coverage for legacy Js.Typed_array -let bytesF32 = Float32Array.Constants.bytesPerElement diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Map.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Map.res deleted file mode 100644 index 5100bef0708..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Map.res +++ /dev/null @@ -1,4 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Map.res. -// Type alias migration for Js.Map.t -external m: Map.t = "m" diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Math.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Math.res deleted file mode 100644 index e6cda4a09a9..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Math.res +++ /dev/null @@ -1,83 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Math.res. -// Exercise migrations from Js.Math to Math - -let e = Math.Constants.e -let pi = Math.Constants.pi -let ln2 = Math.Constants.ln2 -let ln10 = Math.Constants.ln10 -let log2e = Math.Constants.log2e -let log10e = Math.Constants.log10e -let sqrt_half = Math.Constants.sqrt1_2 -let sqrt2c = Math.Constants.sqrt2 - -let absInt1 = Math.Int.abs(-5) -let absFloat1 = Math.abs(-3.5) - -let acos1 = Math.acos(1.0) -let acosh1 = Math.acosh(1.5) -let asinh1 = Math.asinh(1.0) -let asin1 = Math.asin(0.5) -let atan1 = Math.atan(1.0) -let atanh1 = Math.atanh(0.5) - -let atan21 = Math.atan2(~y=0.0, ~x=10.0) - -let cbrt1 = Math.cbrt(27.0) - -let ceilInt1 = Math.Int.ceil(3.2) -let ceilInt2 = Math.Int.ceil(3.2) -let ceilFloat1 = Math.ceil(3.2) - -let clz1 = Math.Int.clz32(255) - -let cos1 = Math.cos(0.0) -let cosh1 = Math.cosh(0.0) -let exp1 = Math.exp(1.0) -let expm11 = Math.expm1(1.0) -let log1p1 = Math.log1p(1.0) - -let floorInt1 = Math.Int.floor(3.7) -let floorInt2 = Math.Int.floor(3.7) -let floorFloat1 = Math.floor(3.7) - -let fround1 = Math.fround(5.05) - -let hypot1 = Math.hypot(3.0, 4.0) -let hypotMany1 = Math.hypotMany([3.0, 4.0, 12.0]) - -let imul1 = Math.Int.imul(3, 4) - -let log1 = Math.log(Math.Constants.e) -let log10_1 = Math.log10(1000.0) -let log2_1 = Math.log2(512.0) - -let maxInt1 = Math.Int.max(1, 2) -let maxIntMany1 = Math.Int.maxMany([1, 10, 3]) -let maxFloat1 = Math.max(1.5, 2.5) -let maxFloatMany1 = Math.maxMany([1.5, 2.5, 0.5]) - -let minInt1 = Math.Int.min(1, 2) -let minIntMany1 = Math.Int.minMany([1, 10, 3]) -let minFloat1 = Math.min(1.5, 2.5) -let minFloatMany1 = Math.minMany([1.5, 2.5, 0.5]) - -let powInt1 = Math.Int.pow(3, ~exp=4) -let powFloat1 = Math.pow(3.0, ~exp=4.0) - -let rand1 = Math.random() - -let roundUnsafe1 = Float.toInt(Math.round(3.7)) -let round1 = Math.round(3.7) - -let signInt1 = Math.Int.sign(-5) -let signFloat1 = Math.sign(-5.0) - -let sin1 = Math.sin(0.0) -let sinh1 = Math.sinh(0.0) -let sqrt1 = Math.sqrt(9.0) -let tan1 = Math.tan(0.5) -let tanh1 = Math.tanh(0.0) - -let truncUnsafe1 = Float.toInt(Math.trunc(3.7)) -let trunc1 = Math.trunc(3.7) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Null.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Null.res deleted file mode 100644 index d521447c8f7..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Null.res +++ /dev/null @@ -1,37 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Null.res. -let make1 = "hello"->Null.make -let make2 = Null.make("hello") - -let empty1 = Null.null - -let getUnsafe1 = Null.make(1)->Null.getUnsafe -let getUnsafe2 = Null.getUnsafe(Null.make(1)) - -let getExn1 = Null.make(1)->Null.getOrThrow -let getExn2 = Null.getOrThrow(Null.make(1)) - -let map1 = Null.make(2)->Null.map(x => x + 1) -let map2 = Null.map(Null.make(2), x => x + 1) - -let forEach1 = Null.make(2)->Null.forEach(x => ignore(x)) -let forEach2 = Null.forEach(Null.make(2), x => ignore(x)) - -let fromOption1 = Some("x")->Null.fromOption -let fromOption2 = Null.fromOption(None) - -let from_opt1 = Some("y")->Null.fromOption -let from_opt2 = Null.fromOption(None) - -let toOption1 = Null.make(3)->Null.toOption -let toOption2 = Null.toOption(Null.make(3)) - -let to_opt1 = Null.make(4)->Null.toOption -let to_opt2 = Null.toOption(Null.make(4)) - -let test1 = Null.null === Null.null -let test2 = Null.null === Null.null -let test3 = Null.make(5)->Null.map(v => v)->Null.equal(Null, (a, b) => a === b) - -// Type alias migration -let nullT: Null.t = Null.make(1) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Nullable.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Nullable.res deleted file mode 100644 index a22592aa5e2..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Nullable.res +++ /dev/null @@ -1,36 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Nullable.res. -let make1 = "hello"->Nullable.make -let make2 = Nullable.make("hello") - -let null1 = Nullable.null -let undefined1 = Nullable.undefined - -let isNullable1 = Nullable.null->Nullable.isNullable -let isNullable2 = Nullable.isNullable(Nullable.null) - -let map1 = Nullable.make(2)->Nullable.map(x => x + 1) -let map2 = Nullable.map(Nullable.make(2), x => x + 1) - -let forEach1 = Nullable.make(2)->Nullable.forEach(x => ignore(x)) -let forEach2 = Nullable.forEach(Nullable.make(2), x => ignore(x)) - -let fromOption1 = Some("x")->Nullable.fromOption -let fromOption2 = Nullable.fromOption(None) - -let from_opt1 = Some("y")->Nullable.fromOption -let from_opt2 = Nullable.fromOption(None) - -let toOption1 = Nullable.make(3)->Nullable.toOption -let toOption2 = Nullable.toOption(Nullable.make(3)) - -let to_opt1 = Nullable.make(4)->Nullable.toOption -let to_opt2 = Nullable.toOption(Nullable.make(4)) - -let optArrayOfNullableToOptArrayOfOpt: option>> => option< - array>, -> = x => - switch x { - | None => None - | Some(arr) => Some(arr->Belt.Array.map(Nullable.toOption)) - } diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Obj.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Obj.res deleted file mode 100644 index 8a9f1f5ad11..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Obj.res +++ /dev/null @@ -1,9 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Obj.res. -let empty1 = Object.make() - -let assign1 = Object.make()->Object.assign({"a": 1}) -let assign2 = Object.assign(Object.make(), {"a": 1}) - -let keys1 = {"a": 1, "b": 2}->Object.keysToArray -let keys2 = Object.keysToArray({"a": 1, "b": 2}) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Option.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Option.res deleted file mode 100644 index ecd5f7f4a90..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Option.res +++ /dev/null @@ -1,35 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Option.res. -let someCall = Js.Option.some(3) -let somePiped = 3->Js.Option.some - -let isSome1 = Some(1)->Option.isSome -let isSome2 = Option.isSome(None) - -let isNone1 = None->Option.isNone -let isNone2 = Option.isNone(Some(2)) - -let eq = (a: int, b: int) => a == b -// let isSomeValue1 = Js.Option.isSomeValue(eq, 2, Some(2)) - -let getExn1 = Option.getOrThrow(Some(3)) -let getExn2 = Some(3)->Option.getOrThrow - -let equal1 = Option.equal(Some(2), Some(2), eq) - -let f = (x: int) => x > 0 ? Some(x + 1) : None -let andThen1 = Option.flatMap(Some(2), f) - -let map1 = Option.map(Some(2), x => x * 2) - -let getWithDefault1 = Option.getOr(Some(2), 0) - -let default1 = Option.getOr(Some(2), 0) - -let filter1 = Option.filter(Some(1), x => x > 0) - -let firstSome1 = Option.orElse(Some(1), None) -let firstSome2 = Option.orElse(Some(1), None) - -// Type alias migration -let optT: option = Some(1) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Promise.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Promise.res deleted file mode 100644 index 3c811ac007f..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Promise.res +++ /dev/null @@ -1,41 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Promise.res. -let p1 = Promise.resolve(1) -let p2 = Promise.reject(Failure("err")) - -let all1 = Promise.all([Promise.resolve(1), Promise.resolve(2)]) -let all2 = Promise.all2((Promise.resolve(1), Promise.resolve(2))) -let all3 = Promise.all3((Promise.resolve(1), Promise.resolve(2), Promise.resolve(3))) -let all4 = Promise.all4(( - Promise.resolve(1), - Promise.resolve(2), - Promise.resolve(3), - Promise.resolve(4), -)) -let all5 = Promise.all5(( - Promise.resolve(1), - Promise.resolve(2), - Promise.resolve(3), - Promise.resolve(4), - Promise.resolve(5), -)) -let all6 = Promise.all6(( - Promise.resolve(1), - Promise.resolve(2), - Promise.resolve(3), - Promise.resolve(4), - Promise.resolve(5), - Promise.resolve(6), -)) - -let race1 = Promise.race([Promise.resolve(10), Promise.resolve(20)]) - -// let thenPipe = Js.Promise.resolve(1)->Js.Promise.then_(x => Js.Promise.resolve(x + 1), _) -// let thenDirect = Js.Promise.then_(x => Js.Promise.resolve(x + 1), Js.Promise.resolve(1)) - -// Type alias migration -external p: promise = "p" - -// let catchPipe = Js.Promise.resolve(1)->Js.Promise.catch(_e => Js.Promise.resolve(0), _) -// let catchDirect = Js.Promise.catch(_e => Js.Promise.resolve(0), Js.Promise.resolve(1)) -let make1 = Promise.make((resolve, reject) => resolve(1)) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Promise2.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Promise2.res deleted file mode 100644 index 79860dd1c29..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Promise2.res +++ /dev/null @@ -1,44 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Promise2.res. -let p1 = Promise.resolve(1) -let _p2 = Promise.reject(Failure("err")) - -let all1 = Promise.all([Promise.resolve(1), Promise.resolve(2)]) -let all2 = Promise.all2((Promise.resolve(1), Promise.resolve(2))) -let all3 = Promise.all3((Promise.resolve(1), Promise.resolve(2), Promise.resolve(3))) - -let all4 = Promise.all4(( - Promise.resolve(1), - Promise.resolve(2), - Promise.resolve(3), - Promise.resolve(4), -)) -let all5 = Promise.all5(( - Promise.resolve(1), - Promise.resolve(2), - Promise.resolve(3), - Promise.resolve(4), - Promise.resolve(5), -)) -let all6 = Promise.all6(( - Promise.resolve(1), - Promise.resolve(2), - Promise.resolve(3), - Promise.resolve(4), - Promise.resolve(5), - Promise.resolve(6), -)) - -let race1 = Promise.race([Promise.resolve(10), Promise.resolve(20)]) - -let thenPipe = Promise.resolve(1)->Promise.then(x => Promise.resolve(x + 1)) -let thenDirect = Promise.then(Promise.resolve(1), x => Promise.resolve(x + 1)) - -// Type alias migration -external p2: promise = "p2" - -let catchPipe = Promise.resolve(1)->Promise.catch(_e => Promise.resolve(0)) -let catchDirect = Promise.catch(Promise.resolve(1), _e => Promise.resolve(0)) -let make1 = Promise.make((resolve, _) => resolve(1)) - -let _ = p2->Promise.then(x => Promise.resolve(x + 1)) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Result.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Result.res deleted file mode 100644 index 8047545816d..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Result.res +++ /dev/null @@ -1,4 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Result.res. -type r = result -let res: result = Ok(1) diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Set.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Set.res deleted file mode 100644 index 7d1576ebee1..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_Set.res +++ /dev/null @@ -1,4 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_Set.res. -// Type alias migration for Js.Set.t -external s: Set.t = "s" diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_String.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_String.res deleted file mode 100644 index 8b1b6b7ddfb..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_String.res +++ /dev/null @@ -1,131 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_String.res. -let make1 = 1->String.make -let make2 = String.make(1) - -let fromCharCode1 = 65->String.fromCharCode -let fromCharCode2 = String.fromCharCode(65) - -let fromCharCodeMany1 = [65, 66, 67]->String.fromCharCodeMany -let fromCharCodeMany2 = String.fromCharCodeMany([65, 66, 67]) - -let fromCodePoint1 = 65->String.fromCodePoint -let fromCodePoint2 = String.fromCodePoint(65) - -let fromCodePointMany1 = [65, 66, 67]->String.fromCodePointMany -let fromCodePointMany2 = String.fromCodePointMany([65, 66, 67]) - -let length1 = "abcde"->String.length -let length2 = String.length("abcde") - -let get1 = "abcde"->String.getUnsafe(2) -let get2 = String.getUnsafe("abcde", 2) - -let charAt1 = "abcde"->String.charAt(2) -let charAt2 = String.charAt("abcde", 2) - -let charCodeAt1 = "abcde"->String.charCodeAt(2) -let charCodeAt2 = String.charCodeAt("abcde", 2) - -let codePointAt1 = "abcde"->String.codePointAt(2) -let codePointAt2 = String.codePointAt("abcde", 2) - -let concat1 = "abcde"->String.concat("fghij") -let concat2 = String.concat("abcde", "fghij") - -let concatMany1 = "abcde"->String.concatMany(["fghij", "klmno"]) -let concatMany2 = String.concatMany("abcde", ["fghij", "klmno"]) - -let endsWith1 = "abcde"->String.endsWith("de") -let endsWith2 = String.endsWith("abcde", "de") - -let endsWithFrom1 = "abcde"->String.endsWithFrom("d", 2) -let endsWithFrom2 = String.endsWithFrom("abcde", "d", 2) - -let includes1 = "abcde"->String.includes("de") -let includes2 = String.includes("abcde", "de") - -let includesFrom1 = "abcde"->String.includesFrom("d", 2) -let includesFrom2 = String.includesFrom("abcde", "d", 2) - -let indexOf1 = "abcde"->String.indexOf("de") -let indexOf2 = String.indexOf("abcde", "de") - -let indexOfFrom1 = "abcde"->String.indexOfFrom("d", 2) -let indexOfFrom2 = String.indexOfFrom("abcde", "d", 2) - -let lastIndexOf1 = "abcde"->String.lastIndexOf("de") -let lastIndexOf2 = String.lastIndexOf("abcde", "de") - -let lastIndexOfFrom1 = "abcde"->String.lastIndexOfFrom("d", 2) -let lastIndexOfFrom2 = String.lastIndexOfFrom("abcde", "d", 2) - -let localeCompare1 = "abcde"->String.localeCompare("fghij") -let localeCompare2 = String.localeCompare("abcde", "fghij") - -let match1 = "abcde"->String.match(/d/) -let match2 = String.match("abcde", /d/) - -let normalize1 = "abcde"->String.normalize -let normalize2 = String.normalize("abcde") - -let repeat1 = "abcde"->String.repeat(2) -let repeat2 = String.repeat("abcde", 2) - -let replace1 = "abcde"->String.replace("d", "f") -let replace2 = String.replace("abcde", "d", "f") - -let replaceByRe1 = "abcde"->String.replaceRegExp(/d/, "f") -let replaceByRe2 = String.replaceRegExp("abcde", /d/, "f") - -let search1 = "abcde"->String.search(/d/) -let search2 = String.search("abcde", /d/) - -let slice1 = "abcde"->String.slice(~start=1, ~end=3) -let slice2 = String.slice("abcde", ~start=1, ~end=3) - -let sliceToEnd1 = "abcde"->String.slice(~start=1) -let sliceToEnd2 = String.slice("abcde", ~start=1) - -let split1 = "abcde"->String.split("d") -let split2 = String.split("abcde", "d") - -let splitAtMost1 = "abcde"->String.splitAtMost("d", ~limit=2) -let splitAtMost2 = String.splitAtMost("abcde", "d", ~limit=2) - -let splitByRe1 = "abcde"->String.splitByRegExp(/d/) -let splitByRe2 = String.splitByRegExp("abcde", /d/) - -let splitByReAtMost1 = "abcde"->String.splitByRegExpAtMost(/d/, ~limit=2) -let splitByReAtMost2 = String.splitByRegExpAtMost("abcde", /d/, ~limit=2) - -let startsWith1 = "abcde"->String.startsWith("ab") -let startsWith2 = String.startsWith("abcde", "ab") - -let startsWithFrom1 = "abcde"->String.startsWithFrom("b", 1) -let startsWithFrom2 = String.startsWithFrom("abcde", "b", 1) - -let substring1 = "abcde"->String.substring(~start=1, ~end=3) -let substring2 = String.substring("abcde", ~start=1, ~end=3) - -let substringToEnd1 = "abcde"->String.substringToEnd(~start=1) -let substringToEnd2 = String.substringToEnd("abcde", ~start=1) - -let toLowerCase1 = "abcde"->String.toLowerCase -let toLowerCase2 = String.toLowerCase("abcde") - -let toLocaleLowerCase1 = "abcde"->String.toLocaleLowerCase -let toLocaleLowerCase2 = String.toLocaleLowerCase("abcde") - -let toUpperCase1 = "abcde"->String.toUpperCase -let toUpperCase2 = String.toUpperCase("abcde") - -let toLocaleUpperCase1 = "abcde"->String.toLocaleUpperCase -let toLocaleUpperCase2 = String.toLocaleUpperCase("abcde") - -let trim1 = "abcde"->String.trim -let trim2 = String.trim("abcde") - -// Type alias migrations -let sT: string = "abc" -let s2T: string = "def" diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_WeakMap.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_WeakMap.res deleted file mode 100644 index afb50c990c5..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_WeakMap.res +++ /dev/null @@ -1,4 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_WeakMap.res. -// Type alias migration for Js.WeakMap.t -external wm: WeakMap.t<{..}, int> = "wm" diff --git a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_WeakSet.res b/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_WeakSet.res deleted file mode 100644 index af9ad046c20..00000000000 --- a/tests/tools_tests/src/migrate/migrated/Migrated_StdlibMigration_WeakSet.res +++ /dev/null @@ -1,4 +0,0 @@ -// This file is autogenerated so it can be type checked. -// It's the migrated version of src/migrate/StdlibMigration_WeakSet.res. -// Type alias migration for Js.WeakSet.t -external ws: WeakSet.t<{..}> = "ws" diff --git a/tests/tools_tests/test.sh b/tests/tools_tests/test.sh index 4e44f421708..ebfd596060b 100755 --- a/tests/tools_tests/test.sh +++ b/tests/tools_tests/test.sh @@ -1,3 +1,5 @@ +shopt -s nullglob + for file in src/*.{res,resi}; do output="$(dirname $file)/expected/$(basename $file).json" ../../_build/install/default/bin/rescript-tools doc $file > $output diff --git a/tools/README.md b/tools/README.md index 8b7ecb3214e..da681035519 100644 --- a/tools/README.md +++ b/tools/README.md @@ -41,6 +41,6 @@ Add to `bs-dev-dependencies`: ``` ```rescript -// Read JSON file and parse with `Js.Json.parseExn` +// Read JSON file and parse with `JSON.parseOrThrow` json->RescriptTools.Docgen.decodeFromJson ```